Automation not running as expected

Hallo,

I have created the automation in the image below.

If temperature top buffer less than 60°C

Only if

SOC Battery house > 98

6:30 h before Sunet

Then

Switch on heating rod

So, what happens.

If the battery is charged (SCO > 98%) and it is more than 6:30 before sunset, and the temperature falls below 60°, it is switched on. Ok, so far

If the temperature falls below 60°C and SOC < 98°, it is not switched on, ok. If SOC rises to > 98% and the temperature is still < 60°C, it is not switched on. Why not?

The following should actually happen

Switch on if Temp <60° and SCO>98% and if it is 6:30 min before sunset.

What went wrong?

Thanks

BR

Haase

https://photos.app.goo.gl/VfkNKyvXEH9mdCHg6

An automation trigger is an event, not a condition.

In other words, your automation will fire when the temperature changes from above 60°C to below 60°C.

Once the temperature is below 60°C it won’t fire again until it rises above 60°C and falls again.

Automations #1: trigger only fires when it changes from not true to true

Edit: Please post code as preformatted text (</> in the toolbar).

Hallo,

ok, thanks.
How can I realiaze that e.g. every 5 min it shall be checked?
The solution I think is, I will add a 2nd automation anch change the condition, if temp is below 60° to only is and if SOC > 98 to trigger event. Running both in paralel is an or function and should cover both.

Thanks

BR
Haase

Hi.
Add trigger

    trigger:
     - platform: time_pattern
       minutes: "/5"

You can also add additional, second entity state trigger to your automation: SOC Battery house > 98.

Thanks to having 2 triggers, your automation will start on ANY following events:

  • If temperature drops below 60 degrees
  • If battery level will be above 98%

However, if any of your triggers will execute after 6:30, it won’t start (and it won’t wait till next day), so time_pattern trigger every X minutes seems to be better option for a trigger.

Hello,
thanks for the feedback.
I have 2 questions. One, explicitly about my problem, a general one

  1. When I add the lines of code that Vlad has written, a second condition appears, see picture attached. Question: Is it switched on after 5 minutes or is it checked after 5 minutes whether the conditions are fulfilled and switched on after this check?
  2. General question: If I have two switch-on conditions, condition A and condition B. Are these linked with “AND” or “OR”? So, do both have to occur or one?
    Thank you
    Haase

It will check every 5 min

In general, time pattern triggers are a kludge. There’s no reason to keep checking on a fixed interval if some set of conditions are true. Instead, you only need to trigger when any of those conditions change. That will make your automation both more responsive and consume fewer resources. A win-win.

When you want multiple things to be true at the same time, the concept which szymon alluded to is often referred to as “matching triggers and conditions”. Meaning, if you want something to happen when 3 things become true, then you should add all three as separate triggers, and also add all three as separate conditions. That way, once any one of the 3 become true, the automation will then check if all the others are already true, and will only execute the actions if they are.

In your case, you want 3 triggers:

  • SOC rises above 98%
  • midnight
  • Temperature drops below 60°

And you want 3 conditions:

  • SOC > 98%
  • More than 6:30 before sunset (i.e. between midnight and 6:30 before sunset)
  • Temperature < 60°

Note that I choose midnight as a trigger because I’m assuming that is the earliest time that you’d consider being “before sunset” instead of “after sunset”