Triggers question

I want to send an “Alarm” notification when an input_boolean stays in the “on” state for 10 seconds. I have an automation trigger that looks like this but it doesn’t appear to be working… the input_boolean has been “on” for more than 10 seconds but this automation doesn’t appear to be firing. Anything wrong with this?

For this to trigger two things are required:

  1. The automation has to be on.
  2. input_boolean.alarm_activated has to transition from off to on, and then stay on (without changing to anything else) for 10 seconds.

So, either the automation is off for some reason, or the input_boolean hasn’t changed from off to on.

Maybe i’m testing this wrong… This is my automations.yaml

- id: '1549904651294'
  alias: Sound alarm
  - platform: state
    entity_id: input_boolean.alarm_activated
    to: 'on'
      seconds: 10
  - data:
      message: alarm!!!
      service: notify.notify

in the UI, I go to “states” and after verifying the state is currently off, i click it and toggle it to “on”. wait 10 seconds… no alert…


Now go to the “states” page in the UI and check the state of the automation itself. Is it on?

Thanks Phil!! That did it. Odd, I don’t remember having to turn any of my other automations “on” before. Anyway thanks again.

1 Like

There was some breaking change at some point. Look for the initial_state value in the automation section of the documentation. I just figured this out too

I think people are jumping to the wrong conclusion that they have to add initial_state to their automations. Yes, you can do that if you always want all of your automations on when HA starts/restarts. However, you don’t have to add initial_state.

Yes, I believe there was one version update that caused a one-time issue with automations (potentially???) getting turned off. And you have to make sure that after restarting HA you don’t restart it again too quickly, because if you do it’s possible that automations may get turned off. But once you’ve dealt with the one-time “glitch”, and if you’re careful not to restart HA too quickly multiple times in a row, then you don’t need to add initial_state, especially if you want to sometimes have certain automations off, and have them stay off through restarts. This is what I do and it works just fine.

Point taken that maybe I oversold the imperative of having it.

I meant to say that people should read about initial_state and decide if they want to set it to be true, which I think applies in 90%+ of the cases. I’m not sure why this isn’t the default setting. Only recently has the functionality of initial_state become explicitly clear in the documentation, which I think is helpful.

1 Like

Seems to me automations created using the UI should have initial_state set to true (or a section of the UI that asks about this specifically…)

1 Like