lit templates in button card #1183
lisz8
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is something I accidentally "discovered" and have been using for a while: the
htmltag function fromlitis available in your template code. You can use it to create a field or embed another lit-template as part of your field.I'll start with the latter, e.g.
helpers.relativeTimereturns a lit-template, and if you try to embed it in text, it won't work:The fix is super easy, just wrap the whole thing as a lit-template:
The
htmlfunction allows the use of lit-expressions. The main benefit is the ability to use Home Assistant components, especially those that require initial configuration, such as passing ahassobject. The following example demonstrates this. It uses the ha-entity-picker to enable the selection of a weather entity. This entity's attributes are then displayed through another part of the lit-template.Details
All reactions