Tinkerer explained that if the temperature rises above 23before09:30, the automation will trigger but will not execute the action because the condition only permits it between 09:30 and 21:30. That is expected. However, the trigger only occurs at the moment the temperature crosses the threshold value of 23. If after triggering, the temperature remains at 23 or continues to increase, it will not trigger the automation again. So the temperature might increase to 24 when it becomes 09:30 but it will not trigger the automation.
That’s how a Numeric State Trigger works (or Numeric Device Action). It only triggers when the threshold value is crossed. In your example, after increasing above the threshold, it must first decrease below it, then rise above it again in order to re-trigger the automation.
The example I posted compensates for this behavior and ensures the automation is triggered appropriately.
Use a State Trigger. However, that’s not the optimal way to do what you want. It will trigger for every temperature change and your automation will need a condition to confirm it exceeds 23. In addition, if it changes from 23 to 24 it will execute the action again (and again and again if the temperature continues to increase). You would need to add another condition to prevent executing the action if the cover’s position is already 30 (unless you don’t mind needlessly sending the set_position command to a cover that is already in the correct position).
The example I posted avoids all of that and will trigger only when necessary. It also handles the situation where Home Assistant might be offline at 09:30. Whenever Home Assistant starts, the automation is triggered and, if the time is within the desired range and the temperature exceeds 23 it will execute the action.
Humm, from your explanation i understood that at 9:31 or when the temperature changes to a value above 23ºC (just the 1st time) it triggers the automation, but really my complete automation includes also a differente related to the outside temperature, so, between 9:30 and 21:00 this can trigger more than once.
And in fact i want it to do so, because i have another one with “open cover” condition, so that throughout the year it manages the opening and closing to maintain the inside temperature optimal.
The issue you are experiencing has been encountered by numerous other users who have had the same complaint that their automation has failed to trigger as expected. The root cause has been their misunderstanding of how a Numeric State Trigger, or its Device equivalent, operates. Sometimes they also don’t understand the relationship between triggers and conditions.
If you are saying what you posted above is not the actual automation you are using, then you should post it.
represents the temperature difference between outside temperature and inside temperature?
I also assume sensor.temperature_158d00056e4ed5 represents inside temperature?
The way that automation is designed, if the inside temperature rises above 23 before 9:30, and stays above 23, the automation will not be triggered at that moment or later, after 9:30. It will first have to decrease below 23 then rise above it (between 9:30 and 21:00) to execute the action.
In addition, when you restart Home Assistant, between 9:30 and 21:00, the automation will execute the action as long as the temperature difference is above -2. It doesn’t check if inside temperature is above 23, only if the temperature difference is greater than -2.
If everything I described is exactly the way you want it to work, then there’s nothing else to discuss.
If what I described is not how you want it to work, you should use the example I posted. The only addition it needs is to handle sensor.dif_temp_out_in.
Trust me when I say you are not the first person to assume that’s how a Numeric State/Device Trigger works nor the last. It’s natural to assume it will keep triggering as the temperature continues to rise above the threshold … but that’s not how it works.
As you can see, at 9:31 all the conditions should be checked (temp in, diference between temp in/out, and time), but the covers didn’t move. I leave here the “trace timeline”:
I believe the problem may be due to the way you structured the multiple conditions.
You need to review how to use the OR Condition. Compare what you have done with the example in the documentation:
condition:
alias: "Paulus home OR temperature below 20"
condition: or
conditions:
- condition: state
entity_id: "device_tracker.paulus"
state: "home"
- condition: numeric_state
entity_id: "sensor.temperature"
below: 20
The conditions to be logically ORed should all be listed below the condition: or statement under conditions. Effectively, your multiple conditions are still being handled as logically ANDed.