I have a temperature sensor and a space heater connected to a switch in a room that’s consistently colder than the rest of the home. I’m trying to set triggers and conditions for an automation based on the target temperature set for the rest of the home from the thermostat.
How do I reference the target temperature from the thermostat to set the “below” and “above” attributes in my numeric_state conditions for the temperature sensor?
My thermostat entity id is ‘climate.upstairs’. If the target temperature were 19, I’d like to set that as the below threshold to turn on the switch for the heater, and if it goes above 19 + 1, I’d like to turn off the switch.
I assume I’ll need to use a template of some sort of this, but I’m having trouble finding info on how to get the target temperature from the climate entity using templates.
Any help or suggestions for another way to go about this would be appreciated.
I just discovered the template tab in the developer tools, and I can see the template in my last message returns “19.5” as a string. How do I convert the string to a float?
You don’t need to. If the below option supported templates the template you have would work. However below does not support templates. You can use input_numbers, but not templates:
I think I got it now, but I’ll have to do some testing later. I couldn’t replace the “below” value for my numeric_state condition, but I could use a template condition
Thanks for pointing me in the right direction! I never knew about the Developer tools, and I’ll need to get more familiar with where/when I can use templates.
This is the logic I ended up with after a bit of clean up. I was repeating the conditions in the triggers and the actions so I tried using trigger IDs for the first time and that seemed to work well:
I ran into an issue where I previously had a automation condition that my ‘spatial_state’ was home, but I found the template triggers were only triggering when the template value changed from false to true… so it wouldn’t trigger when my ‘spatial_state’ changed from ‘away’ to ‘home’. So I ended up adding in the check on the ‘spatial_state’ in the value template for the triggers so they would get re-evaluated when the spatial_state changed.
It seemed to work when the temperature went above target and the switch turned off… Is there a more efficient way to test other than waiting for the test cases to naturally present themselves? i.e. is there a way I can “stub” the temperature sensor / climate target temp / spatial state values to test the triggers and conditions for a specific automation, without affecting/triggering all the other automations that are also impacted by those values?