diff --git a/README.md b/README.md index 42762c7..1382262 100644 --- a/README.md +++ b/README.md @@ -432,5 +432,19 @@ Some of [my lovelace plugins](https://github.com/thomasloven/hass-config/wiki/My Basically, just replace `service_data` with `data` or `data_template`, whichever fits your needs. +### My Fully Kiosk Browser device goes unavailable after the screen has been turned off for five minutes + +This seems to be a problem with Android, and not much to do about it. +As a workaround you can add the following to your configuration: + +```yaml +browser_mod: + devices: + d2fc860c-16379d23: # DeviceID of your FKB device + force_stay_awake: true +``` + +That will make the screen turn on and off again for a second regularly to stop the five minute timer from running out. + --- Buy Me A Coffee diff --git a/js/fullyKiosk.js b/js/fullyKiosk.js index 1d4aaf0..8688d42 100644 --- a/js/fullyKiosk.js +++ b/js/fullyKiosk.js @@ -11,15 +11,33 @@ export const FullyKioskMixin = (C) => class extends C { this._fullyMotion = false; this._motionTimeout = undefined; - for (const event of ["screenOn", "screenOff", "pluggedAC", "pluggedUSB", "onBatteryLevelChanged", "unplugged", "networkReconnect"]) { - fully.bind(event, "window.browser_mod.fully_update();"); + for (const ev of ["screenOn", "screenOff", "pluggedAC", "pluggedUSB", "onBatteryLevelChanged", "unplugged", "networkReconnect", "onMotion"]) { + window.fully.bind(ev, `window.browser_mod.fully_update("${ev}");`); } - window.fully.bind("onMotion", "window.browser_mod.fullyMotionTriggered();"); + this._keepingAlive = false; } - fully_update() { + fully_update(event) { if(!this.isFully) return + if(event === "screenOn") { + window.clearTimeout(this._keepAliveTimer); + if(!this._keepingAlive) + this.screen_update(); + } else if (event === "screenOff") { + this.screen_update(); + this._keepingAlive = false; + if(this.config.force_stay_awake) { + this._keepAliveTimer = window.setTimeout(() => { + this._keepingAlive = true; + window.fully.turnScreenOn(); + window.fully.turnScreenOff(); + }, 270000); + } + } else if (event === "onMotion") { + this.fullyMotionTriggered(); + } + this.sendUpdate({fully: { battery: window.fully.getBatteryLevel(), charging: window.fully.isPlugged(), diff --git a/js/main.js b/js/main.js index 8dff9f8..6ddb413 100644 --- a/js/main.js +++ b/js/main.js @@ -95,6 +95,7 @@ class BrowserMod extends ext(BrowserModConnection, [ if(msg.camera) { this.setup_camera(); } + this.config = {...this.config, ...msg}; } this.player_update(); this.fully_update(); diff --git a/js/popups.js b/js/popups.js index 96f86f8..d34b28c 100644 --- a/js/popups.js +++ b/js/popups.js @@ -42,7 +42,7 @@ export const BrowserModPopupsMixin = (C) => class extends C { const open = () => { popUp( - cfg.tile, + cfg.title, cfg.card, cfg.large, cfg.style, diff --git a/js/screensaver.js b/js/screensaver.js index 8aa9c5a..462d878 100644 --- a/js/screensaver.js +++ b/js/screensaver.js @@ -29,10 +29,6 @@ export const BrowserModScreensaverMixin = (C) => class extends C { `; document.body.appendChild(this._blackout_panel); - if(this.isFully) { - window.fully.bind("screenOn", "window.browser_mod.screen_update();"); - window.fully.bind("screenOff", "window.browser_mod.screen_update();"); - } } screensaver_set(fn, clearfn, time) { @@ -92,7 +88,7 @@ export const BrowserModScreensaverMixin = (C) => class extends C { this.screensaver_set( () => { if(this.isFully) - window.fully.turnScreenOff(); + window.fully.turnScreenOff(true); else this._blackout_panel.style.display = "block"; this.screen_update(); @@ -109,6 +105,8 @@ export const BrowserModScreensaverMixin = (C) => class extends C { } no_blackout() { + if(this.isFully) + window.fully.turnScreenOn(); this.screensaver_stop(); } diff --git a/package.json b/package.json index 4e4220e..eb20480 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "browser_mod", "private": true, - "version": "1.2.0", + "version": "1.2.1", "description": "", "scripts": { "build": "webpack", diff --git a/test/configuration.yaml b/test/configuration.yaml index a4b67ba..0fbdffb 100644 --- a/test/configuration.yaml +++ b/test/configuration.yaml @@ -8,6 +8,8 @@ browser_mod: camera: true testdevice: alias: test + fully: + force_stay_awake: true lovelace: