Add support for displaying time listeners (#7220)

This commit is contained in:
J. Nick Koston 2020-10-19 12:43:04 -05:00 committed by GitHub
parent eec4a91ad8
commit 9f41f80a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,7 @@ interface TemplateListeners {
all: boolean;
domains: string[];
entities: string[];
time: boolean;
}
export const subscribeRenderTemplate = (

View File

@ -151,6 +151,15 @@ class HaPanelDevTemplate extends LitElement {
class="rendered ${classMap({ error: Boolean(this._error) })}"
><!-- display: block -->${this._error}${this._templateResult
?.result}</pre>
${this._templateResult?.listeners.time
? html`
<h3>
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.time"
)}
</h3>
`
: ""}
${!this._templateResult?.listeners
? ""
: this._templateResult.listeners.all

View File

@ -144,7 +144,7 @@ export class HuiMarkdownCard extends LitElement implements LovelaceCard {
} catch (_err) {
this._templateResult = {
result: this._config!.content,
listeners: { all: false, domains: [], entities: [] },
listeners: { all: false, domains: [], entities: [], time: false },
};
this._unsubRenderTemplate = undefined;
}

View File

@ -2949,6 +2949,7 @@
"jinja_documentation": "Jinja2 template documentation",
"template_extensions": "Home Assistant template extensions",
"unknown_error_template": "Unknown error rendering template",
"time": "This template updates every 60 seconds after the last state changed event.",
"all_listeners": "This template listens for all state changed events.",
"no_listeners": "This template does not listen for any state changed events and will not update automatically.",
"listeners": "This template listens for the following state changed events:",