I have a thermostat type test which fires an automation if temp A (sensor measure) is < temp B (another entity, actually a template which changes over time) for 1 minute.
It only fires if temp A changes (up OR down) and is below temp B at the time. If I change temp B (raise the threshold) it does not fire. I guess the 60 second times does not start. Is that expected behaviour??
Without you yaml properly formatted you will only get guesses at best. But it is probably the fact that it will only trigger when the temp goes past the setting not whether it is above or below, just guess as its impossible to have a clue without your workings.
The question is whether it is testing against the static value of the lower limit, or whether it fires if the lower limit (being template) changes too. The yaml won’t answer the question, but here it is anyway ..
I would say that this probably is expected behavior. The trigger only checks for state changes on temp A, not temp B. If you want the automation to also react when temp B changes to be above temp A, I would assume you need to add a second trigger:
Rather than using a legacy numeric_state trigger, you may also want to look into the newer purpose specific temperature.crossed_threshold trigger, which may or may not behave differently…
It is exactly the expected behaviour. I brought this up when it was introduced. The only way to get it to monitor both the value and threshold for changes is with a template trigger.
This is an often misunderstood concept - triggers vs. conditions.
Suppose you want something to happen in cold nights. So you make trigger=cold, condition=night.
But when it’s already been cold before night falls, this never triggers. So you also need trigger=night and condition=cold.
These two can sit in the same automation - two triggers, two conditions. This works because HA checks the conditions after one of the triggers fired.
So in your case - two triggers for “tempA<tempB” and “tempB>tempA” looks mathematically stupid but is logically what you need. Don’t even begin to think about what happens when both change at the exact same time.
Because this is just part of the automation (there are other triggers), I don’t want thermostat items like hysteresis, and I am not firing a simple switch, which is what the thermostat integrations typically do.
Anyway thanks for answering the question - basically, as I suspected, the trigger treats ‘temp B’ (entity 2) as static value to be checked against, and changes in it are not causes for the trigger timer to start.
Any of the proposed solutions will work - the template one is probably neater, as the two A less than B and B>A triggers will fire twice (when A finally change and the system discovers it is now less than B, even though it alredy fired for B>A some time earlier, assuming B was moved upwards).
A thermostat can be part of an automation too.
I have thermostats that are controlled by weather, window sensors, occupancy and even a playstation being on or off (it heats up the room very nicely).
What are you trying to do? You will get much better answers if you are more detailed.
As a general rule I have found that when controlling temperature it’s generally worth the time to do the work to setup climate entities (which includes generic thermostats), sure you have to do some upfront work to integrate them, but the payback is:
You get a control you can put on dashboards.
They remember some state (such as your target temp).
They handle edge cases such as moving the target temp boundary over the current temp.
They play nice with other triggers/automations - you can just check the current state of climate device rather than looking at the underlying temp or controlled switch.
In short they are predictable and don’t burn you down the road.
Template Triggers or TBS
===
Beyond that I typically use template triggers in preference to most other types, because I understand the model:
If the template changes from False → True the trigger fires.
If I have a complex condition that I need to reuse (either in the same or across multiple automations) I create a template binary sensor. Then in automations I can trigger on state changes to the TBS (depending upon my use case, with/without guards for specific states) and/or use the same TBS in conditions.
Trigger Documenation
===
As a general rule you can view all HA triggers as also being conditions, in that the underlying condition is true at the moment the trigger fired. Noted that some conditions can be viewed as instantaneous, such as a time trigger or sunset (they are only true for that one infinitesimal instant).
When looking at it through this lens, all built in triggers have a set of conditions necessary for them to fire and at least one “item” that they are monitoring for changes, so for the trigger to fire a monitored item needs to change and all conditions need to be true.
The problem is that what items are being monitored and what isn’t being monitored is not well documented, which is why I like template triggers, in my experience as long as it’s in the template it’s being monitored.
TL;DR - It’s not “expected” behavior unless it’s documented…