Hi I have several automated lights with pir senses with the condition after and before sunset, which initially works fine until after 12 o’clock midnight it stops working , no longer triggering the light to turn on. Is it an internal problem or a configuration problem need some help please thanks
- alias: BedRoom1 Motion turn on lamp
initial_state: True
trigger:
- platform: state
entity_id: binary_sensor.BedRoom1_motion
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: sun
after: sunset
- condition: state
entity_id: light.BedRoom1_light
state: 'off'
action:
service: light.turn_on
entity_id: light.BedRoom1_light
Mike_D
(Mike D.)
April 25, 2017, 3:52pm
2
I think what happens is midnight “resets” the clock. Now according to HA its before sunset.
You probably want to use below_horizon instead. I believe that should survive the switch at midnight.
1 Like
Ohhh I did not know this … is this confirmed? That may have affected many of mine automation.
WHich is the command, also after???
condition:
- condition: sun
after: below_horizon
Mike_D
(Mike D.)
April 25, 2017, 4:17pm
5
Midnight starts a new day so technically sunset for that day hasn’t happened yet. Below is how you would use below_horizon as a condition.
(formatting might need adjusted)
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
Yes, I realize that you are right formally, just wondering if it really works so the component.
Nevertheless I changed to below_horizon some automations
Mike_D
(Mike D.)
April 25, 2017, 4:20pm
7
Ahh gotcha. Yeah just theory on my part. Someone with a little more insight to the component will have to answer that.
Thanks guys for your suggestions are tried a couple of them now I suppose you could also use Date and time of the next dawn.
Tinkerer
(aka DubhAd on GitHub)
April 25, 2017, 5:36pm
9
Everybody’s experience is that midnight is a reset, so before sunset covers from midnight to sunset, and after sunset covers from sunset to midnight.
You can of course instead simply check for an elevation of below zero, via a template:
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: 0
That will then always apply between sunset and sunrise.
Tinkerer:
You can of course instead simply check for an elevation of below zero, via a template:
condition: numeric_state
entity_id: sun.sun
value_template: ‘{{ state.attributes.elevation }}’
below: 0
That will then always apply between sunset and sunrise.
is this different from below_horizon??
Tinkerer
(aka DubhAd on GitHub)
April 25, 2017, 7:24pm
12
Not at zero, but I personally use -5, which is just before civil dusk/dawn. Under “normal” conditions, that’s about right (for me) in terms of lack of light.
1 Like
Tinkerer:
Not at zero, but I personally use -5, which is just before civil dusk/dawn. Under “normal” conditions, that’s about right (for me) in terms of lack of light.
so you use like this, because below zero would meano 0 and not -5, correct?
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: -5
I still wish I can manage with a light sensor (for those gray days), but still no luck with the right sensor
Tinkerer
(aka DubhAd on GitHub)
April 26, 2017, 5:46pm
15
That’s exactly how I use it.
As for outdoor light sensors, the Aeon labs ones can be used outdoors, if suitably sheltered.
Stimo
(Niklas)
April 27, 2017, 6:42pm
16
The sunset trigger have stoped working for me to suddently, did it help to use below_horizon
instead?
below_horizon works fine.