RunRunRun
(Alex)
September 13, 2018, 1:46pm
1
Hello, I was thinking about turning on one of the light in the bedroom with a specific color based on daily temperature.
I made a template to test it and it should return a string value based on outside temperature, here it is:
- platform: template
sensors:
rgbtemperature:
friendly_name: RGB Temp
value_template: >-
{% if states('sensor.pws_temp_high_1d_c_2')|float > 28 %}
Hot
{% elif states('sensor.pws_temp_high_1d_c_2')|float < 19 %}
Cold
{% else %}
Good
{% endif %}
Right now the sensor.pws_temp_high_1d_c_2 is at 33 but i keep getting âColdâ as output, why?
lolouk44
(lolouk44)
September 13, 2018, 2:38pm
2
2 things Iâd test.
parenthesis
I wonder if itâs because itâs that string within a string thing.
What does that return?
- platform: template
sensors:
rgbtemperature:
friendly_name: RGB Temp
value_template: >-
{% if (states('sensor.pws_temp_high_1d_c_2')|float) > 28 %}
Hot
{% elif (states('sensor.pws_temp_high_1d_c_2')|float) < 19 %}
Cold
{% else %}
Good
{% endif %}
and if still no good, what does that return?
- platform: template
sensors:
rgbtemperature:
friendly_name: RGB Temp
value_template: >-
{% if (states.sensor.pws_temp_high_1d_c_2.state | float) > 28 %}
Hot
{% elif (states.sensor.pws_temp_high_1d_c_2.state | float) < 19 %}
Cold
{% else %}
Good
{% endif %}
Last but not least, to confirm what happens when temp equals 28 or 19? You want it to display âgoodâ right?
Honestly, @lolouk44 , I donât think any of those would be issues.
Seems to me that itâs probably a typo in the sensor entity_id. The states() function will return âunknownâ if the entity doesnât exist. And the float filter will return 0.0 if the input string is not a number, which of course, âunknownâ isnât. So, if thereâs a typo in the entity_id, the result of this template would be âColdâ.
2 Likes
RunRunRun
(Alex)
September 14, 2018, 6:59am
4
Wow! looks like @pnbruckner was right. Today everithing is working fine right now is 28°C and output is Good
Thanks @lolouk44 for the help