From 71e13d6ab32daf1fb66f972eb3d41abefbef525e Mon Sep 17 00:00:00 2001 From: RJ Fendricks Date: Sun, 22 Oct 2023 11:50:22 -0400 Subject: [PATCH 1/4] Add a timer to trigger template re-rendering --- MMM-HomeAssistantDisplay.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MMM-HomeAssistantDisplay.js b/MMM-HomeAssistantDisplay.js index 99ffe49..ef20ac0 100755 --- a/MMM-HomeAssistantDisplay.js +++ b/MMM-HomeAssistantDisplay.js @@ -52,6 +52,13 @@ Module.register("MMM-HomeAssistantDisplay", { entity: section.triggerEntities[entity] }); } + // Set up a timer to trigger re-rendering outside of any entity state update + if (section.triggerTimer) { + setInterval(()=> { + this.renderTemplates("timeout"); + this.updateDom(); + }, section.triggerTimer); + } } } this.renderTemplates("foo"); From 7f506931c3d58046ffc5bd62eecfb0f7616b71a5 Mon Sep 17 00:00:00 2001 From: RJ Fendricks Date: Tue, 24 Oct 2023 15:00:49 -0400 Subject: [PATCH 2/4] Add information for triggerTimer in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 890363e..ea7a041 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Templates allow you to output virtually any HTML you want to in the contents of | triggerEntities | The array of entities to watch for state changes to determine if this sections displayTemplate should be re-rendered. | | displayTemplate | The template to send to Home Assistant to render. The results of the render will be displayed as the contents of this section in the module. | | class | The CSS class name to add to the `
` surrounding this section of the module. This is a name you choose yourself, for example "HAValues". You can then style this section by adding a .HAvalues-section in custom.css. | +| triggerTimer | Set a trigger timeout in milliseconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. | #### Note From 805ec290eced7b2dd59bbbbd7eb939a594f5c215 Mon Sep 17 00:00:00 2001 From: RJ Fendricks Date: Tue, 24 Oct 2023 17:13:13 -0400 Subject: [PATCH 3/4] Rename `triggerTimer` to `refreshTimer` --- MMM-HomeAssistantDisplay.js | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MMM-HomeAssistantDisplay.js b/MMM-HomeAssistantDisplay.js index ef20ac0..c34bce6 100755 --- a/MMM-HomeAssistantDisplay.js +++ b/MMM-HomeAssistantDisplay.js @@ -53,11 +53,11 @@ Module.register("MMM-HomeAssistantDisplay", { }); } // Set up a timer to trigger re-rendering outside of any entity state update - if (section.triggerTimer) { + if (section.refreshTimer) { setInterval(()=> { this.renderTemplates("timeout"); this.updateDom(); - }, section.triggerTimer); + }, section.refreshTimer); } } } diff --git a/README.md b/README.md index ea7a041..a855c6b 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Templates allow you to output virtually any HTML you want to in the contents of | triggerEntities | The array of entities to watch for state changes to determine if this sections displayTemplate should be re-rendered. | | displayTemplate | The template to send to Home Assistant to render. The results of the render will be displayed as the contents of this section in the module. | | class | The CSS class name to add to the `
` surrounding this section of the module. This is a name you choose yourself, for example "HAValues". You can then style this section by adding a .HAvalues-section in custom.css. | -| triggerTimer | Set a trigger timeout in milliseconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. | +| refreshTimer | Set a refresh timeout in milliseconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. | #### Note From 4e530bc9ebe040f4269fedcba78d1c72fda7287b Mon Sep 17 00:00:00 2001 From: RJ Fendricks Date: Tue, 24 Oct 2023 21:00:33 -0400 Subject: [PATCH 4/4] Set the refreshTimer to expect seconds --- MMM-HomeAssistantDisplay.js | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MMM-HomeAssistantDisplay.js b/MMM-HomeAssistantDisplay.js index c34bce6..ba53090 100755 --- a/MMM-HomeAssistantDisplay.js +++ b/MMM-HomeAssistantDisplay.js @@ -57,7 +57,7 @@ Module.register("MMM-HomeAssistantDisplay", { setInterval(()=> { this.renderTemplates("timeout"); this.updateDom(); - }, section.refreshTimer); + }, section.refreshTimer * 1000); } } } diff --git a/README.md b/README.md index a855c6b..0c208c1 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Templates allow you to output virtually any HTML you want to in the contents of | triggerEntities | The array of entities to watch for state changes to determine if this sections displayTemplate should be re-rendered. | | displayTemplate | The template to send to Home Assistant to render. The results of the render will be displayed as the contents of this section in the module. | | class | The CSS class name to add to the `
` surrounding this section of the module. This is a name you choose yourself, for example "HAValues". You can then style this section by adding a .HAvalues-section in custom.css. | -| refreshTimer | Set a refresh timeout in milliseconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. | +| refreshTimer | Set a refresh timeout in seconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. | #### Note