imv8n
October 14, 2021, 3:57pm
1
I have a turtle tank with basking lights plugged into a smart outlet plug. I would like to lights to turn on at sunrise and turn off at sunset. My current automation will turn lights on but not off
Is it possible to get this one automation to do both on and off?
- id: '1634102183865'
alias: Action - Switch - Schedule - Lucy Tank
description: ''
trigger:
- platform: sun
event: sunrise
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.lucy_tank
- wait_for_trigger:
- platform: sun
event: sunset
- service: switch.turn_off
target:
entity_id: switch.lucy_tank
mode: single
Tinkerer
(aka DubhAd on GitHub)
October 14, 2021, 5:03pm
2
Since 2021.7:
- id: '1634102183865'
alias: Action - Switch - Schedule - Lucy Tank
description: ''
trigger:
- platform: sun
event: sunrise
id: 'on'
- platform: sun
event: sunset
id: 'off'
condition: []
action:
- service: "switch.turn_{{ trigger.id }}"
target:
entity_id: switch.lucy_tank
mode: single
2 Likes
123
(Taras)
October 14, 2021, 5:18pm
4
- id: '1634102183865'
alias: Action - Switch - Schedule - Lucy Tank
description: ''
trigger:
- platform: state
entity_id: sun.sun
condition: []
action:
- service: "switch.turn_{{ 'on' if trigger.to_state.state == 'above_horizon' else 'off' }}"
entity_id: switch.lucy_tank
mode: single
EDIT
Correction. Changed below_horizon
to above_horizon
as per tom_l’s comment below.
1 Like
tom_l
October 14, 2021, 10:31pm
5
Shouldn’t that test be for above_horizon
?
They want the lights on during the day.
1 Like