Skip to content

Commit

Permalink
Disable screen saver when exiting the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
j-a-n committed Aug 27, 2022
1 parent 2c80d15 commit 04152b5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions wallpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
}

const version = "2.5";
const version = "2.6";
const defaultConfig = {
enabled: false,
debug: false,
Expand Down Expand Up @@ -434,7 +434,7 @@ class WallpanelView extends HuiView {

// Whenever the state changes, a new `hass` object is set.
set hass(hass) {
if (!config.enabled) {
if (!config.enabled || !activePanelUrl) {
return;
}
if (config.debug) console.debug("Update hass");
Expand Down Expand Up @@ -497,6 +497,9 @@ class WallpanelView extends HuiView {
}

timer() {
if (!config.enabled || !activePanelUrl) {
return;
}
if (this.screensaverStartedAt) {
this.updateScreensaver();
}
Expand Down Expand Up @@ -1183,7 +1186,14 @@ document.body.appendChild(wallpanel);

window.setInterval(() => {
let pl = getHaPanelLovelace();
if (pl && pl.panel && pl.panel.url_path && activePanelUrl != pl.panel.url_path) {
if (!pl && activePanelUrl) {
if (config.debug) console.debug("No dashboard active");
activePanelUrl = null;
if (wallpanel.screensaverStartedAt > 0) {
wallpanel.stopScreensaver();
}
}
else if (pl && pl.panel && pl.panel.url_path && activePanelUrl != pl.panel.url_path) {
if (config.debug) console.debug(`Active panel switched from '${activePanelUrl}' to '${pl.panel.url_path}'`);
activePanelUrl = pl.panel.url_path;
updateConfig();
Expand Down

0 comments on commit 04152b5

Please sign in to comment.