Hi,
It’s my second day using HA and I’m trying to setup an automation which I’m not quite sure if I got the concept right.
Tried to search for examples and asked ChatGPT but would appreciate if someone could review the code and tell me if it does the following scenario I’m trying to configure:
- Before sunset = motion detection off, lights off
- After sunset = turn on motion detection, lights on 50%
- If motion detected (during night): turn on lights 100% for 5min, then go back to 50% brightness.
- At sunrise = turn off motion detection, lights off.
So far, I got this code, does it seem correct? I am getting many different type of results with ChatGPT so not sure if I can trust it
alias: Carport sensor automation
description: ""
trigger:
- platform: state
entity_id: update.carport_sensor
to: "on"
- platform: sun
event: sunset
- platform: sun
event: sunrise
condition:
- condition: or
conditions:
- condition: sun
before: sunset
after: sunrise
action:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- service: light.turn_on
data:
brightness_pct: 50
kelvin: 2000
target:
device_id: 8d914bef0c3392074127e279eeb33bd7
- conditions:
- condition: state
entity_id: update.carport_sensor
state: "on"
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- service: light.turn_on
data:
brightness_pct: 100
kelvin: 6500
target:
device_id: 8d914bef0c3392074127e279eeb33bd7
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- service: light.turn_on
target:
device_id:
- 8d914bef0c3392074127e279eeb33bd7
data:
kelvin: 2000
brightness_pct: 40
- conditions:
- condition: state
entity_id: sun.sun
state: above_horizon
sequence:
- service: homeassistant.turn_off
data: {}
target:
entity_id: update.carport_sensor
device_id:
- 2007a232996a31b01729422c2233e253
- 66deb9be8b6447188f2637e1b8868c89
- 0b60a473957c6f98da10c51f28af1010
Thanks!