I have a light sensor that measures light in w/m2. I want to automate switching on outdoor lighting at sunset “OR” during a period 30 minutes BEFORE and UP TO sunset if the light level drops below 4 m/m2. I have no problem running an automation which is triggered by sunset but cannot figure out how to include the light condition and the time period from 30 minutes before and up to sunset. This is my suggestion:
alias: Switch on outside lighting at sunset
description: Switch on outside lighting at sunset or 30 before if light levels are low
trigger:
- platform: sun
event: sunset
condition:
condition: and
conditions:- condition: sun
before: sunset - condition: sun
before: sunset
before_offset: ”" - condition: or
- condition: sun
before: sunset - condition: sun
before: sunset
before_offset: ”-00:30:00"- condition: state
- condition: numeric_state
entity_id: sensor.lallerod_562_orust_solar_rad
below: ‘4’
attribute: friendly_name
- condition: sun
action:
# Switch on
- type: turn_on
device_id: 67bb2c974e90d08547c8b90d5301cce5
entity_id: switch.shelly_shsw_1_8caab5055beb
domain: switch
mode: single