I use a motion sensor to switch on a light, but this should happen corresponding to the environment and the time. So during the evening/morning hours, it should turn on at 100% and during the night the brightness is reduced.
So it has been set to start at 20:00h for a while, but during summer I had to adjust the starting time like two or three times, simply because the sun was still there and switching on the lights was not needed.
So basically, I just wanted to have the motion sensor to turn on the light between 30 mins before the sun sets until 2:00h during the night.
In order to get that, I removed the condition time 20h-02h and just entered the condition sun. But this did not work, because I guess the condition was not met. It was not always 30 mins before sunset.
action:
- choose:
- conditions:
- condition: time
after: '20:00'
before: 02:00
- condition: sun
before: sunset
before_offset: 00:30:00
What do I miss? Can I specify a negative offset like:
- condition: sun
after: sunset
before_offset: 00:30:00
That would mean, focus on the time after sunset, but start already 30mins before. Does it work or is there a better way to do this?
I think the problem is that all you conditions are AND’d by default and can never all be true at the same time, you probably need to make the first condition an OR then list your individual conditions as follows:
condition:
- condition: or
conditions:
- condition: time
after: 20:00:00
- condition: time
before: 02:00:00
- condition: sun
before: sunset
before_offset: 00:30:00
The trigger is the motion sensor, but the action should consider all circumstances.
So, I’d like to replace:
- condition: time
after: '20:00'
before: 02:00
with something adapting itself dynamically like:
- condition: sun
after: sunset
before_offset: 00:30:00
This is just to avoid modifying the automation every two weeks, because the sunset is sometimes at 5h or at 10h in the evening.
So if the motion sensor is triggered, it should switch the light on between 30 mins before the sun sets until 2h in the night. Best would be if the motion sensor would be more sensitive concerning the currently available light, but it isn’t. So I need to somehow do this manually.
Thanks a lot. This documentation is what I was looking for. I’ll change my automation accordingly and we’ll see later today, whether it worked out nor not.