Timer not working in 2024.1

I have noticed on 2024.1 that if a condition is set be it, if it is CHOOSE or IF, the timer that comes with it isnt working. Like if i set to to notify me after 10 secs, the script does nothing. If i remove the timer, it works fine… Anyone else?

Post the automation or script that contains the problem.

Ensure it’s posted as formatted YAML.

FAQ Guideline 11 - Format it properly

1 Like
alias: door checks
description: Check the door state and send a notfication
trigger:
  - platform: state
    entity_id:
      - binary_sensor.garage_door_sensor_open
      - binary_sensor.front_door_sensor_open
      - binary_sensor.outdoor_garage_sensor_open
      - binary_sensor.back_door_sensor_open
    from: null
    to: null
    for:
      hours: 0
      minutes: 0
      seconds: 0
    id: "0909"
condition:
  - condition: trigger
    id:
      - "0909"
action:
  - alias: Check Back Door
    if:
      - condition: state
        entity_id: binary_sensor.back_door_sensor_open
        state: "on"
        for:
          hours: 0
          minutes: 0
          seconds: 15
    then:
      - service: notify.notify
        metadata: {}
        data:
          message: The back door has been opened for over 15 seconds
          title: Back Door Notification
  - alias: Check garage door
    if:
      - condition: state
        entity_id: binary_sensor.garage_door_sensor_open
        for:
          hours: 0
          minutes: 0
          seconds: 10
        state: "on"
    then:
      - service: notify.notify
        metadata: {}
        data:
          message: Garage Door has been opened for over 10 seconds
          title: Garage Door Notification
  - if:
      - condition: state
        entity_id: binary_sensor.outdoor_garage_sensor_open
        state: "on"
        for:
          hours: 0
          minutes: 10
          seconds: 0
    then:
      - service: notify.notify
        metadata: {}
        data:
          message: The Garage door has been opened for over 10 minutes
          title: Garage Door Notification
    alias: Check Main Garage Door
  - alias: Check Front Door
    if:
      - condition: state
        entity_id: binary_sensor.front_door_sensor_open
        state: "on"
        for:
          hours: 0
          minutes: 0
          seconds: 10
    then:
      - service: notify.notify
        metadata: {}
        data:
          message: The front door has been opened for over 10 seconds
          title: Front Door Notification
  - stop: Checked all doors
trace:
  stored_traces: 12
mode: restart

If i remove the timer or set it to 0, it works, and instantly as expected

In Home Assistant, this is a timer.

I believe what you call “timer” is the State Condition’s for option.

The reason why it works when you remove the for option, or set it to 0, is because you’re failing to understand how the automation you created actually works.

You designed the automation to trigger at the instant when any of four doors is opened (or closed). Then you check if the door was open for at least 10 or 15 seconds (depending on which door). It cannot possibly be open for that much time because it just opened microseconds ago.

Effectively, you created this:

When the door opens, check it has been open for at least the past 10 seconds.

It cannot be “open for the past 10 seconds” because it just opened a fraction of second earlier.

I suggest you move the for option into the State Trigger.

Example

alias: door checks
description: Check the door state and send a notfication
trigger:
  - platform: state
    entity_id:
      - binary_sensor.garage_door_sensor_open
      - binary_sensor.front_door_sensor_open
      - binary_sensor.outdoor_garage_sensor_open
    from: 'off' 
    to: 'on' 
    for:
      seconds: 10
  - platform: state
    entity_id:
      - binary_sensor.back_door_sensor_open
    from: 'off' 
    to: 'on' 
    for:
      seconds: 15
condition: []
action:
  - variables:
      door: "{{ trigger.to_state.name }}"
  - service: notify.notify
    metadata: {}
    data:
      message: 'The {{ door | lower }} has been opened for over {{ trigger.for.seconds }} seconds'
      title: '{{ door }} Notification'
mode: queued
1 Like

Thanks very much I will give it a try and report back :slight_smile:

Works great Taras … Thank you very much. Actually, you are right! what you stated above is what i tried to do. It was my mistake

1 Like