Automation with time condition is not firing

Hello,

can anyone help me with this automation? It’s not firing with the time condition. If I remove the time condition it’s working:

- alias: 'Close the window'
  hide_entity: True
  trigger:
    platform: state
    entity_id: binary_sensor.jmd4004141_state
    state: 'on'

  condition:
      condition: state
      entity_id: binary_sensor.jmd4004141_state
      state: 'on'
      for:
        hours: 0
        minutes: 0
        seconds: 5
  action:
      service: notify.pushbullet
      data_template:
        title: "Jarvis"
        message: "Close the window!"

Try:

- alias: 'Close the window'
  hide_entity: True
  trigger:
    platform: state
    entity_id: binary_sensor.jmd4004141_state
    state: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 5
  action:
      service: notify.pushbullet
      data_template:
        title: "Jarvis"
        message: "Close the window!"
1 Like

Thanks! That worked! :+1:

Did I misunderstand the documentation or is the documentation just wrong?
https://home-assistant.io/getting-started/scripts-conditions/

Btw, The homeassistant documentation is full of examples that do not work.

The docs are right, however…

  1. The automation triggers when binary_sensor.jmd4004141_state turns on
  2. You immediately check to see if binary_sensor.jmd4004141_state has been on for 5 seconds

The condition can never be true, because the automation triggers the moment the sensor turns on, so by the time the condition is checked, not enough time can have passed.

I just find triggers (or conditions) with time checking not 100% reliable. Which is not good.

Then submit an edit to correct them, or raise an issue so that others can look into it. Obviously we prefer the first :wink:

If you’ve got details, please raise an issue. The hardware you’re running on will matter. It’s not something I’ve seen, but I’ve only got a handful that trigger at fixed times.

Will do when I come across. I have used some examples previously from the docs, that
has not worked well. Mostly regarding time triggers/conditions. I’ve got a lot of time checks in conditions, not so many time triggers. It’s especially when using before and after checks, which seems somewhat unreliable.

I just upgraded to the latest PI 3 B+ last night, so ill see if that makes a difference.