I have configured HA to switch on an outdoor light at sundown. Quite often the ambient light in the evening is low before sundown and i want HA to switch on the light either at sundown or at any moment during a period from one hour before sundown when the ambient light has a value of less than 4 w/m2 (my weather station provides this information). I have two questions, 1 - Is the logic in the following code correct? 2 - Can someone describe a good way to test code like this. Obviously its a bit hard to have to wait until the conditions required actually occur!
- id: '1617954555299'
alias: Switch on lighting at sundown and also in low daylight one hour before sundown
description: Switch on lights at sundown or up to 1 hour earlier if ambient light
is less than 4 w/m2
trigger:
- platform: sun
event: sunset
- platform: sun
event: sunset
offset: -01:00:00
- platform: state
entity_id: sensor.lallerod_562_orust_solar_rad
attribute: friendly_name
from: 0 w/m2
to: 4 w/m2
condition:
- condition: or
conditions:
- condition: sun
after: sunset
- condition: and
conditions:
- condition: sun
after: sunset
after_offset: '- 01:00:00'
- condition: state
entity_id: sensor.lallerod_562_orust_solar_rad
state: < 4 w/m2
attribute: friendly_name
action:
- type: turn_on
device_id: 2c9ce9c1f0927fc846a2f4f508c88d4f
entity_id: switch.ikea_vagguttag
domain: switch
mode: single