Add refresh timer for re-rendering displayTemplate

Add refresh timer for re-rendering displayTemplate
This commit is contained in:
Brian Towles
2023-10-25 08:02:00 -05:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -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.refreshTimer) {
setInterval(()=> {
this.renderTemplates("timeout");
this.updateDom();
}, section.refreshTimer * 1000);
}
}
}
this.renderTemplates("foo");

View File

@@ -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 `<div>` 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 seconds to re-render this section's displayTemplate, regardless of whether or not an entity has changed states. |
#### Note