#Automation will not trigger if conditions are met while off, despite still being met once turned on…

1 messages · Page 1 of 1 (latest)

balmy coyote
#

I'm not sure how to word this, but if the trigger condition for an automation is met while the automation is off, once the automation is turned on, if those conditions are still met, the automation will not trigger. The conditions need to go out of scope first, before coming back into scope for the trigger to work.

Eg. Automation is meant to trigger below 20°C. While automation is switched off, temperature falls to 19°C, automation is then switched on below 19°C, and automation will not trigger, even if the temperature falls to 18° c or below.

The only way the automation will trigger, is if the temperature goes above 20°C, and then back down below 20°C while the automation is on.

Is this a bug? Is there a workaround for this?

There are automations that I switch off, so they won't trigger when I'm away from home, but once I return home, and turn the automation back on, if the conditions for them to trigger were met while they were turned off, they will not trigger once I turn them on, until the conditions stop being met, and then are met again while on, which means I manually need to run automations after turning them back on, after manually checking to see if their conditions have already been met.

arctic grove
#

All triggers are events, IE triggered by the event of the change in state. They are not triggered by the state of the state.

balmy coyote
#

it triggers at the crossing of the threshold, as opposed to triggering once the conditions are met, am I understanding that correctly?

arctic grove
#

Currently turning the automation on or off is not considered in the trigger. You are asking for a change to that, well make a feature request would be my suggestion.
Most people don't turn automations off, they just use a condition to ignore the trigger when they don't want it to happen. If you did that instead, you could catch the event of state change, have an automation put that information into a helper, then have it available for when your autromation turns back on (to trigger off of).
Solved...

#

Yes, that's what the triggers do.

balmy coyote
#

I see, ok. so You're saying if I wanted an automation that doesn't trigger when I'm away from home, part of my trigger and criteria should be whether I'm at home or not.

arctic grove
#

Or a condition if you are home or not

balmy coyote
#

what I was thinking of doing was creating a separate automation that turns on and off other automations based on whatever condition, like say being away from home. but it sounds like that's not the best way to do that.

balmy coyote
arctic grove
#

Let it trigger and be killed by conditions

#

I simply have a template sensor or automation or something change the state of a helper, then in the affected automations, the condition is that that helper is on, or off, or whatever.

#
- trigger:
    - trigger: time_pattern
      id: This will it update every night
      hours: "0"
      minutes: "0"
    - trigger: homeassistant
      id: This will update it at HA start
      event: start
  sensor:
    - name: "xmas_season_enable"
      unique_id: c5086efc-dc1c-4f85-b04a-21fa74bba5ab
      state: >
        {% set today = states('sensor.date').split('-') %}
        {% set month = today[1]|int %}
        {% set day = today[2]|int %}
        {{ month > 10 or
            month == 1 and day <= 5 }}
      availability: >-
        {% from 'availability_template.jinja' import avail %}
        {{- avail(['sensor.date']) | bool -}}
      attributes:
        friendly_name: "Christmas Season Enable"

This tells my Christmas lights that they can turn on, it's the season.

balmy coyote
# arctic grove Let it trigger and be killed by conditions

cool, I don't know if that'll work in all the situations I'm thinking of, but I'll give it a shot. I think that'll certainly work in most situations that I'm thinking of. some of them are "manual" events. like scanning a tag to disable an automation, and then scanning it again to re-enable it. but those are very few and far between. The vast majority of them probably can work being blocked by a condition, so I'll see what I can do with that, and circle back later if I'm getting stuck.

balmy coyote
arctic grove
#

And they just turned off 20 minutes ago until next Novermer...

#

Yup

balmy coyote
balmy coyote
# arctic grove Yup

Cool. I'll give that a shot tomorrow. thanks so much for your help! I really appreciate it.

#

and thanks for helping me figure out how to word this thing to actually make it make sense. 😂😂😂

arctic grove
#

(It is currently the 13th day after Christmas here, so I leave them on until the 12 days of Christmas are over.)

balmy coyote
arctic grove
#

They are still up, just dark now. I'm not that good.

balmy coyote
#

Hahahah, fair fair. 😂

#

all right I got to get to bed. thanks so much again for all your help! I really appreciate it. ☺️

balmy coyote
#

Just to close the loop and circle back, I ended up doing this, which I think is what you were talking about?

description: ""
triggers:
  - entity_id:
      - sensor.inside_temperature
    below: 19.51
    trigger: numeric_state
  - trigger: state
    entity_id:
      - automation.heat_house
    from: "off"
    to: "on"
conditions:
  - condition: numeric_state
    entity_id: sensor.inside_temperature
    below: 19.51```

So, it's triggers are both when the temp falls into range, but also if the automation is toggled on, with a condition to verify that the temperature has dropped into range, if it gets triggered by being turned back on.

Not sure if this is what you meant or not, or if this is the best way to do it. Definitely open to feedback.

Hopefully this'll help anyone else that wants to do something similar.
#

Actually, reading your example again, made me realize that I'm not catching times where things fall out of range when HA is off (because the server is rebooting or is being updated or whatnot)! I hadn't thought of that… Hmm… Something to consider…

arctic grove
#

I would expect that to work, did you try it?

balmy coyote
# arctic grove I would expect that to work, did you try it?

Oh yeah, I did, and it seems to work well! I'm just not sure I'm not doing something stupid with unintended side-effects. 😅

One of those, 3 months later you discover it's been messing something else up needlessly, or will fail under a certain infrequent condition, things.

arctic grove
#

No that is proper usage. Def better than turning automations on and off.