Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templating in custom labels #11

Closed
rklueber opened this issue Feb 15, 2021 · 2 comments
Closed

Templating in custom labels #11

rklueber opened this issue Feb 15, 2021 · 2 comments

Comments

@rklueber
Copy link

Before I throw in a suggestion, please let me thank you for creating this. This is awesome. The channel back from HA to SD was missing so far and you closed that gap. Thank you.

I like the possibility to feed back values from HA onto the SD keyboard.

May I suggest adding full templating possibilities. Think of showing the volume for a media_player with
{{volume_level}} showing a value between 0 and one like 0.38. Can we improve that ideally with making use of the templating engine which exists in HA.

Think of {{ (state_attr('media_player.ralf', 'volume_level') * 10) | round(0) * 10 }} . Possibilities would be endless.

@cgiesche
Copy link
Owner

I love your idea. Currently, i use handlebars as templating engine, which is very basic and clean but lacks some features that would be very useful in context of this project.

I will take a look at https://github.com/sstur/jinja-js, which is a javascript implementation of the templating engine that home-assistant uses.

An architectural challenge is, that (currently) in context of a button, i only have access to the state of a single entity. I think combining the states of different entities would be great, too, but would require a rework of big portions of the code.

I will create two issues:

  1. Replace handlebars by jinja-js to be able to do calculations etc. in templates (may happen soon)
  2. Redesign internal state architecture to be able to access cross-entity-states inside templates (may take some time ;) )

@cgiesche
Copy link
Owner

cgiesche commented Feb 16, 2021

(Spoiler) Replacing handlebars by jinja looks promising:
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants