Hi community,
I am new here and to home-assistant and I am trying to wrap my head around the concept of “value_templating”, especially in context of the “homeassistant-attributes” component (https://github.com/pilotak/homeassistant-attributes/)…
What I want to achieve:
- get sensors for the valve positions of all my thermostats. Those are within the ‘level’ attribute of the thermostat as a number between 0 and 1.
- Get the value not as a number between 0 and 1 but between 0% and 100%
- I dont want to create a sensor definition for each one of them. (I know how to do that with the desired outcome, but I would like to do that elegantely with the homeassistant-attributes component.
Problem:
the value_template definition of the component does not produce any number, whatever definition I use:
sensor:
- platform: attributes
friendly_name: "Ventilposition"
attribute: "level"
unit_of_measurement: "%"
**value_template: "{{ (value*100) | float }}"**
entities:
- climate.heizkoerper_arbeitszimmer
- climate.heizkoerper_bad
- climate.heizkoerper_kueche
- climate.heizkoerper_schlafzimmer
- climate.heizkoerper_wohnzimmer
sensor:
- platform: attributes
friendly_name: "Ventilposition"
attribute: "level"
unit_of_measurement: "%"
**value_template: "{{ (value | float *100) }}"**
entities:
- climate.heizkoerper_arbeitszimmer
- climate.heizkoerper_bad
- climate.heizkoerper_kueche
- climate.heizkoerper_schlafzimmer
- climate.heizkoerper_wohnzimmer
These are all producing “unknown” as a result. My guess was that I cannot use something like
value_template: "{{ (state_attr(climate.heizkoerper_bad, 'level')| float *100) }}
as this would defeat the purpose of the generic setup of this component, so there should be some kind of generic reference “value” for each entity. Am I correct, or is that supposed to be used in a different way.
The help text is actually not very helpful in this case:
- value_template ( Optional ): In case you need to do a math with the value ie. offset, bit gain, etc. (will be the same for all entities specified) .
Thanks!
Ben