Hi, I fail to understand what am I doing wrong in the below. The automation works for the second option (light.turn_off) but doesn’t work to turn it on. Any hints?
(Basically I want my lights to turn on just when it’s dark enough to need a light and this is typically at around -5 degree sun elevation)
I honestly don’t know why your way didn’t work. My automation that does the same thing (except for the brightness and color_temp) is actually two automations:
alias: Outside Lights off with sun elevation
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: -5.0
action:
service: light.turn_off
entity_id: light.outside
alias: Outside Lights on with sun elevation
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: -5.0
action:
service: light.turn_on
entity_id: light.outside
Based on your entity id names, you are referencing the sun azimut in your conditions and passing it an elevation value. While the elevation can be negative, the azimuth is between 0 and 360º which can explain why the first condition never runs.
To fix it, you can use the sun.sun entity in your conditions and specify an elevation value (elevation attribute).
Other changes you could make are to specify a default condition to your choose action (either turn on or off) and to use -5 in both triggers.
The triggers refer to the sun.sun entity while the condition refers to a different entity called sensor.sun_azimuth.
I assume this is a Template Sensor based upon sun.sun's elevation attribute? If it isn’t, please post its configuration. If it is, why not use it in the trigger?
And here again, a simple logical error that my brain simply woudn’t see. Thanks.
I mistakenly used “sensor_sun_azimuth” instead of the attribute “elevation” from sensor “sun.sun”.
I have read through the instructions and also tried a few things here in the forum, but unfortunately this does not work.
I have 2 door contacts that are supposed to switch on a light when the door/gate is opened after sunset until sunrise.
Unfortunately I don’t know what to do.
(Translation from DeepL)
What you want isn’t what you created. Your automation does this: just before sunrise/sunset it checks if either door contact is open and turns on the light.