Don't understand sunrise sunset automation

id: '1713810042481'
alias: Pohyb Kancelar svetlo LED
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.zone_pracovna_pir_open
    to: 'on'
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: switch.rpi_pico_remote_gpio15
        state: 'off'
      - condition: sun
        before: sunset
        before_offset: '-00:30:00'
        after: sunrise
action:
  - service: switch.turn_on
    target:
      entity_id: switch.rpi_pico_remote_gpio15
    data: {}
mode: single

Log:

Executed: May 2, 2024 at 09:19:45
Result:
result: true
conditions/0
Executed: May 2, 2024 at 09:19:45
Result:
result: true
conditions/0/entity_id/0
Executed: May 2, 2024 at 09:19:45
Result:
result: true
state: 'off'
wanted_state: 'off'
conditions/1
Executed: May 2, 2024 at 09:19:45
Result:
wanted_time_before: '2024-05-02T17:40:33.668419+00:00'
wanted_time_after: '2024-05-02T03:26:38.169092+00:00'
result: true

Why it was executed if it’s not 30minutes before sunset?

If you search the forums you will find a lot of answers to this issue.

You need to use “below horizon” as the condition.

see

1 Like

Because it was after sunrise ?

2 Likes

That condition will be true from sunrise to 30 minutes before sunset.

in your case from 3:26 AM to 5:40 PM. It was close to 9:20 AM which falls in that range, so the condition passed.

What condition do you actually want?

1 Like

Omg guyz sorry, was reading the tutorial but i didn’t realize it… Thank you everybody <3

alias: Pohyb Kancelar svetlo LED
description: “”
trigger:

  • platform: state
    entity_id:
    • binary_sensor.zone_pracovna_pir_open
      to: “on”
      condition:
  • condition: and
    conditions:
    • condition: state
      entity_id: switch.rpi_pico_remote_gpio15
      state: “off”
    • condition: sun
      before: sunrise
      before_offset: “+00:10:00”
      after: sunset
      after_offset: “-00:10:00”
      action:
  • service: switch.turn_on
    target:
    entity_id: switch.rpi_pico_remote_gpio15
    data: {}
    mode: single