Hi, I need an automation in which a light comes on at sunset and goes off at 7:30 in the morning.
I was able to create two automations, one that turned on and one that turned off, then I tried to create just one, and now I can’t anymore.
How about something like this:
description: "My automation"
mode: single
trigger:
- platform: sun
event: sunset
offset: 0
id: At Sunset
- platform: time
at: "07:30:00"
id: At 7.30
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: At Sunset
sequence:
- service: light.turn_on
data:
brightness_pct: 100
target:
entity_id: light.hall_table_light_level_on_off
- conditions:
- condition: trigger
id: At 7.30
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.hall_table_light_level_on_off
You could use the automation I’ve sent you and adapt it. Try changing the triggers and then change the actions performed in the Choose action.
You will benefit from learning how to do this stuff. One way to learn is to take something and adapt it.
perfect ok thanks
unfortunately it does not work, it does not turn off
Ugo
Here is my code for a sunset-sunrise switch. It works no issues. You need sun: listed in your config file. Obviously you need to change the names of entities for yours.
alias: undercover mozzie zapper
description: ""
trigger:
- platform: sun
event: sunset
offset: 0
- platform: sun
event: sunrise
offset: 0
condition: []
action:
- if:
- condition: sun
after: sunset
then:
- service: switch.turn_on
data: {}
target:
entity_id: switch.undercovermozziezapper
else:
- service: switch.turn_off
data: {}
target:
entity_id: switch.undercovermozziezapper
mode: single
Pat
Something like this?
alias: undercover mozzie zapper
description: ""
trigger:
- platform: sun
event: sunset
offset: 0
id: AtSunset
- platform: time
at: "07:30:00"
id: At7.30
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: AtSunset
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.undercovermozziezapper
- conditions:
- condition: trigger
id: At7.30
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.undercovermozziezapper
mode: single