Automation with time condition not firing as suposed

Hi there! I have an automation that is not working as I intended and I cannot find the reason. It’s supposed to be fired at 22.00 hours if a contact sensor is closed or between 22.00 and 12.00 if the sensor is closed, but the first part (triggering at 22.00 if the contact sensor is off) is not working. If I open and close the contact sensor, then it triggers, but not if the contact is closed before 22.00 hours.

- id: '1607801351756'
  alias: Start the washer
  description: ''
  - type: not_opened
    platform: device
    device_id: 7b7444a7b6d26221115969e4abe70e6b
    entity_id: binary_sensor.washer_contact
    domain: binary_sensor
  - condition: time
    after: '22:00'
    before: '12:00'
  - service: switch.turn_on
    data: {}
    entity_id: switch.washer
  mode: restart

It’s possible that they’ve redone time conditions to account for your situation but I don’t think so. The issue, I think, is that on any given day, the time will never be after 2200 and before 1200. (It spans two days.) To fix it, do a compound condition as follows:

    condition: or
        - condition: time
          after: '22:00'
          before: '23:59'
        - condition: time
          after: '00:00'
          before: '12:00'

My outdoor light sensor automation works which is after 19:00 and before 06:00

i.e. between 7pm and 6am

12:00 in 24 hour time is midday or noon e.g. 1 minute after 11:59am that is. In 24 hour time midnight (1 minute after 11:59pm is 00:00). Maybe you are looking for any time afte 22:00 and any time before 00:00 ?

No, I don’t think that’s the problem because if I close the contact sensor at any time between 22:00 and 12:00 of the next day it fires ok. It only fails to fire at 22:00 if the sensor is closed

No, I’m looking it to fire between 22:00 and 12:00 of the nex day (midday), so it’s properly set. It will fire without problem if I close the sensor, but not if the sensor is already closed before 22:00

you need to add another trigger at 22:00 and another condition that the binary sensor is “not_opened” to be able to catch both events.


Yes, I think this should work! I will try it today and will get back to you. Thanks!!

Thanks! That did the trick!

1 Like