I just installed HASS and am getting things set up. I’ve set up an automation that works fine, but it seems really cumbersome. Is this really the most efficient way to set this up? For example you’ll see the time 22:00:00 several times. I originally had midnight, but decided to change it … in all three places.
The goal is to have the outside lights turn on at a default brightness of 70 at sunset, and then off at 10pm. Also, any motion detected between dusk and dawn causes the lights to go to full brightness (and then return to the default value once motion ends).
Is there a way to streamline this? Can I at least declare constants, something like:
#define NIGHT_BRIGHTNESS 70
#define LIGHTS_OFF 22:00:00
So that I have one place to edit these values and keep things working consistently?
Thanks for any help, and apologies in advance if this is obvious and I simply missed reading the relevant documentation.
-Greg
automation:
# Turns outside lights on at sunset
- alias: 'Outside lights on in the evening'
trigger:
- platform: sun
event: sunset
action:
service: homeassistant.turn_on
entity_id: light.frontdoorlight_level_4_0
data:
brightness: 70
# Turns outside lights off at 10pm
- alias: 'Outside lights off at 10pm'
trigger:
- platform: time
after: '22:00:00'
action:
service: homeassistant.turn_off
entity_id: light.frontdoorlight_level_4_0
# Set Front Door Light to full brightness upon motion
- alias: 'Front door motion'
trigger:
- platform: state
entity_id: sensor.vision_zp3102_pir_motion_sensor_burglar_3_10
to: '8'
condition:
condition: sun
after: sunset
action:
service: homeassistant.turn_on
entity_id: light.frontdoorlight_level_4_0
data:
brightness: 255
# Set Front Door Light back to normal brightness upon no motion
- alias: 'Front door no motion - dim'
trigger:
- platform: state
entity_id: sensor.vision_zp3102_pir_motion_sensor_burglar_3_10
to: '0'
condition:
condition: and
conditions:
- condition: time
after: '16:00:00'
before: '22:00:00'
- condition: sun
after: sunset
action:
service: homeassistant.turn_on
entity_id: light.frontdoorlight_level_4_0
data:
brightness: 70
# Set Front Door Light back to off upon no motion
- alias: 'Front door no motion - off'
trigger:
- platform: state
entity_id: sensor.vision_zp3102_pir_motion_sensor_burglar_3_10
to: '0'
condition:
condition: or
conditions:
- condition: time
after: '22:00:00'
before: '10:00:00'
- condition: sun
before: sunset
action:
service: homeassistant.turn_off
entity_id: light.frontdoorlight_level_4_0