Hi all, I have this automation set to run within 3 hours of sunset if the light gets too low due to cloud/rain, but it doesn’t seem to work at all. Why am I having so many issues with the sun condition??
- alias: Cloudy Light On
initial_state: 'on'
trigger:
platform: numeric_state
entity_id: sensor.illumination_7811dcb06eb9
below: "350.0"
condition:
condition: and
conditions:
- condition: state
entity_id: input_select.occupancy
state: 'Home'
- condition: state
entity_id: light.living
state: 'off'
- condition: sun
before: sunset
before_offset: "-03:00:00"
- condition: or
conditions:
- condition: state
entity_id: sensor.cloud_cover
state: "Cloudy"
- condition: state
entity_id: sensor.cloud_cover
state: "Mostly Cloudy"
- condition: state
entity_id: sensor.cloud_cover
state: "Partly Cloudy"
action:
- service: homeassistant.turn_on
entity_id: script.cloudy
My understanding of your configuration is that your sun condition evaluates to true before sunset only, and more specifically until 3 hours before sunset.
Example: Let’s say sunset at your location is at 6pm, then this condition is true during the day until 3pm.
If you want the condition to be true from three hours before sunset until after dark, you need to go with after: sunset and after_offset: “-03:00:00”.
you need to specify a range, using @exxamalte’s after, will only account for after the sunset -3 hours. From what you are saying, you want it between 3 hours before sunset and sunset. You don’t want this firing after sunset do you? Anyways, you just need to add another condition on top of @exxamalte if you want that functionality. And if I miss understood your intentions, ignore this whole comment.
- condition: sun
after: sunset
after_offset: "-03:00:00"
- condition: sun
before: sunset
before_offset: "+00:30:00"