There’s nothing wrong with either your template trigger our your binary sensor (and you don’t need the extra set of parentheses.)
The problem is more than likely neither sensor.temp_sensor1 nor sensor.temp_sensor2 are changing. A template trigger only gets evaluated, and potentially fires, when one of the referenced entities changes state. Same thing goes for a template binary sensor – a referenced entity has to change state for the binary sensor to update.
If you want the automation to trigger when HA starts, even before either of the sensors updates, then you could do this:
The automation will trigger when either of the sensors changes state, or when HA has started. When any of these happen the condition will then be checked, and if true, the action(s) will run.
Just be aware that if either of the sensors does not have a valid numeric state when the condition is evaluated, the corresponding float filter will return zero. To guard against the actions running when one of the sensors isn’t valid yet, you could change the template to use the float filter’s default parameter:
Thanks heaps. The comments here have got me almost there.
There were multiple issues and they were way more stupid than one would reasonably expect. The HA install was on Docker. Somehow a restart had taken the config from /user/drive/folder to /user/drive/folder/config - leaving config that looked identical in a folder and in its parent. I was only updating files in the parent folder, so it wasn’t being used. Knowing the config was good led to me finding the issue.
The other issue was a duplicate entry from ESPHome, which is quite hard to fix but I eventually found a duplicate config for a device in .storage.
Thanks again - I have learnt a few things here.
I’m new to HA, also new to this type of script writing (prefer C++ so please be patient with me!
So, my problem is almost the same what this topic is about. I would like to control a fan (relay) that can heat or cool down a room depending on 3 temperature: inner, outer and set temp. Hardware side is working perfectly, HA can get temperatures and control relay, the only problem is the automation/script. I have read several topics, tried many things but none of them worked. I can’t even save my automation, throws error. I am using newest HA OS on an rpi.
My full automation code is the following: