Skip to content

Commit

Permalink
Fix popup title. Add option to force fully to stay awake
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Oct 26, 2020
1 parent b1e64c3 commit f970105
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 16 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---
<a href="https://www.buymeacoffee.com/uqD6KHCdJ" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/white_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
10 changes: 5 additions & 5 deletions custom_components/browser_mod/browser_mod.js

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions js/fullyKiosk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class BrowserMod extends ext(BrowserModConnection, [
if(msg.camera) {
this.setup_camera();
}
this.config = {...this.config, ...msg};
}
this.player_update();
this.fully_update();
Expand Down
2 changes: 1 addition & 1 deletion js/popups.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const BrowserModPopupsMixin = (C) => class extends C {

const open = () => {
popUp(
cfg.tile,
cfg.title,
cfg.card,
cfg.large,
cfg.style,
Expand Down
8 changes: 3 additions & 5 deletions js/screensaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -109,6 +105,8 @@ export const BrowserModScreensaverMixin = (C) => class extends C {
}

no_blackout() {
if(this.isFully)
window.fully.turnScreenOn();
this.screensaver_stop();
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "browser_mod",
"private": true,
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"scripts": {
"build": "webpack",
Expand Down
2 changes: 2 additions & 0 deletions test/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ browser_mod:
camera: true
testdevice:
alias: test
fully:
force_stay_awake: true


lovelace:
Expand Down

0 comments on commit f970105

Please sign in to comment.