For: hours and minutes

Hi there! I don`t understand why this automation doesnt work:

  - alias: light_night_bed_boolean_auto_on
    initial_state: 'on'
    hide_entity: true
    trigger:
    - platform: state
      entity_id: input_boolean.night_light_bed
      to: 'off'
      for:
        hours: 1
    action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.night_light_bed

But If I will change “hours: 1” to “minutes: 1”, than its work like a charm. Whats wrong?

Strange, The only thing I see is;

This should be this, according to the docs;

initial_state: true

this won’t help, and the docs should really be updated. have a look at https://www.home-assistant.io/components/automation/ where initial_state: 'off' is mentioned…

All automations on this side use initial_state: on if really needed and no chances are taken any system error will frustrate restore_state to take care of the automations setting.

iow, @TEDSv doesn’t need to set it to true, and ‘on’ should be perfectly fine.

I do believe, though no sure, and I can’t find the docs for that now, that if you set an hour, you also need to set the minutes and seconds, like the docs do on https://www.home-assistant.io/docs/automation/trigger/#state-trigger

for:
  hours: 1
  minutes: 0
  seconds: 0

wha would happen if you set minutes: 60 ?

1 Like

Thank you! This is working :slight_smile:

Sorry to resurrect this old thread, but it resolved a problem I was having with the “for:” part of a trigger, but there may be an easier way.

I tried the solution @Mariusthvdb posted, adding minutes: and seconds:. Then I went into the GUI automation editor to see how it looked there. The editor changed it to one line:

for: '1:00:00'

That seems a lot easier than four lines. I posted this in case someone else missed that syntax in the documentation, but will find this thread, as I did.