How to configure this?

Please share your ideas for this: I have a (very simple) Home Assistant setup in the house. The kitchen sink light is currently configured to come on at the earlier of 17:40 and sunset. (The portion of the yaml file is shown below).

This works great during the summer, but during the winter, when sunset can happen quite early, the light comes on too early. What I would like to do is configure the automation like this: Turn on the switch at the earlier of 19:40 or sunset_time where sunset_time is the later of sunset and 18:30. Would you please suggest how to do this, thanks.

The existing yaml file contents:

alias: Kitchen Sink Light On
trigger:
- platform: sun
  event: sunset
  offset: 0
- platform: time
  at: '19:40:00'
condition: []
action:
- type: turn_on
  device_id: b00a5fc57fcb525d5ff2ed9f00e1e59d
  entity_id: switch.shelly_2
  domain: switch
mode: single

Please use code tags.

Why don’t you choose for it to go on at sunset regardless?

A simple time condition will fix that:

alias: Kitchen Sink Light On
trigger:
  - platform: sun
    event: sunset
    offset: 0
  - platform: time
    at: '19:40:00'
condition: 
  - condition: time
    after: "18:30:00"
action:
  - service: switch.turn_on
    target: 
      entity_id: switch.shelly_2
mode: single

Also try to avoid using device ids. See: Why and how to avoid device_ids in automations and scripts

1 Like

tom_l: Thank you. I made the changes and in just over two weeks, i.e., after DST ends, we’ll see if it works as expected.

It should work as your time trigger is after 18:30, so the only one that will be ignored is the sunset trigger if it is before 18:30.

Just checking though, you don’t want it to come on at 18:30 if sunset is before that do you?

It would seem kind of redundant as you have the other trigger for 19:40.

Here is what I would like:
if sunset earlier than 18:30
light on at 18:30
else
light on earlier of 19:40 or sunset

Ok I can’t help if you keep changing the times you want.

Sorry - I typo’ed. Fixed the mistakes.