I want to create an automation that turns on a fan when the air temperature in the room becomes greater (or two degrees greater) than the set point of the thermostat in the room. What is the best way to do this?
The two entities I have from my thermostat for this are climate.t6_pro_z_wave_programmable_thermostat (set point) and sensor.t6_pro_z_wave_programmable_thermostat_air_temperature (air temp).
The Numeric State trigger seems like one possible way to achieve this but appears to be limited to just x is greater than or less than y. If I want the fan to turn on when the air temp is 2 or more degrees greater than the thermostat set point, it seems like I will need to employ a template. Can anyone provide an example of what the template would look like for this scenario? Thanks!
and the Template Tool returned “True”
Currently the thermo sensor reads 64 and the climate is set to 60. So this makes sense. But if I change the 2 in the template to 10, it still returns True. Shouldn’t the +2 (or whatever number) be on the other side of the > ?
So I tried moving the + 2 to the climate side of the > and it still returns True. Makes sense.
I increased the 2 to 10, still true. Increased it to 64 (current air temp) and get “False.” So it seems like the climate value is being ignored if I add “+ x” after it.
Your “reformatting” looks like guesswork as opposed to trying to understand the original, and introduces a different error. The trouble is that people helping on here are doing it “blind” without access to your entities and system, so much of what we suggest is untested.
Your attempts return true, because the RH side of the equality is the state of a non-existent entity with 0 as a default value:
So your tests reduced to 64 > 2, 64 > 10 and finally 64 > 64.
Much better to very carefully inspect the provided code against the documentation (in this case, for state_attr) to see where the problem is. Even better, the error message pointed you towards the problem: expecting a quote but got temperature.
Thanks. Yeah it was complete guesswork as I have no prior experience with the template syntax. Just starting to learn. Your template worked, except that I think there is still the issue of adding the “+ 2” on the left side of the >. Isn’t that like saying “air temp + 2 is greater than thermostat setting?” What I want to know is when “air temp > thermostat setting + 2.” So would that be correctly coded as below?