VDH
August 14, 2021, 5:10pm
1
Hello,
I am just trying to automatize a tts automization/script. I tried the following in the development tools → template tool:
{% set wave_volume = states.media_player.wave_soundtouch_wohnzimmer.attributes['volume_level'] %}
'{{wave_volume}}'
{{ '{{wave_volume}}' == '0.2' }}
The results is when the volume is 0.2
while it should be true. What am I mixing up here?
Try using the recommended templating example-
{{ state_attr('media_player.wave_soundtouch_wohnzimmer', 'volume_level') == 0.2 }}
OR
{{ is_state_attr('media_player.wave_soundtouch_wohnzimmer', 'volume_level', 0.2) }}
I think the problem occur because volume_level value is number, while by using ‘0.2’ (quotes), you make it as a string. So comparing number to string would not work.
VDH
August 14, 2021, 6:18pm
3
I found another option:
{% set wave_volume = states.media_player.wave_soundtouch_wohnzimmer.attributes['volume_level'] %}
'{{wave_volume}}'
{{ wave_volume == unknown }}
which renders the correct evaluation.