Automation executed after wanted_time_before is true

Hello all,

My latest automation (using motion detection from camera to switch lights) is off by 1 hour.
I use two sets of “or” conditions

  1. lights must be off OR timer must be active
  2. time must be before sunrise OR after sunset
    The first condition works as expected.
    The second condition however works with a 1 hour offset?
    In the log the correct times are displayed. Just the outcome is weird!

Executed: 21 februari 2022 07:04:35

wanted_time_before: ‘2022-02-21T06:07:30.908468+00:00’
result: true

It states that 7:04 is before 7:30…

Am I missing something about DST? Or where is the 1 hour offset comming from?



Could you please post your code? I think it’s hard to find a solution without the code.

And I do not understand your posted log. Is this the output by the working or the not working condition? It seems that you are expecting a different output, but 7:04 is before 7:30…

Hello Lars,

Sorry for the typo… 07:04:35 is definitely NOT before 06:07:30.908468.

My code:

id: '1643892487138'
alias: Licht afdak aan op sensor
description: >-
  Licht afdak aan bij bewegingsdetectie camera, wanneer het donker is. Na 2
  minuten weer uit.
  - type: motion
    platform: device
    device_id: 0cdfd0de81b27d3d703defba715b598b
    entity_id: binary_sensor.mymotiondetectorrule_cell_motion_detection_2
    domain: binary_sensor
  - condition: or
      - condition: state
        entity_id: input_boolean.voordeur_active
        state: 'on'
      - condition: state
        entity_id: light.lampen_afdak
        state: 'off'
  - condition: or
      - condition: sun
        before: sunrise
        before_offset: '-00:30:00'
      - condition: sun
        after: sunset
        after_offset: '00:30:00'
  - service: light.turn_on
    data: {}
      entity_id: light.lampen_afdak
  - service: input_boolean.turn_on
    data: {}
        - input_boolean.voordeur_active
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - service: input_boolean.turn_off
    data: {}
        - input_boolean.voordeur_active
  - service: light.turn_off
    data: {}
      entity_id: light.lampen_afdak
mode: restart

I don’t usually use sunrise and sunset conditions but this:

so before sunrise.
I just googled sunrise Amsterdam to get a ballpark figure, 07:42
So before 07:42 with negative offset 30 minutes:

before 07:12?

And 06:07 is before 07:12 so true.

Or do I missunderstand this?

Hello Hellis81,
I didn’t go back to the basics and check the actual sunrise time -30 min.
I checked the log and that still is wrong. Propably a DST bug.
Condition “True” is correct. 7:04:35 is before (sunrise @ 7:42 - 30 =) 7:12.
So automation and switch time are correct.

Senks for pointing that out!