Hey there,
currently im struggling to find a way to turn on the lights using hue motion sensors, but only in the time between sunset and sunrise, and from midnight to sunrise the light should be dimmed to XX%
Short version:
daytime: no trigger
sunset - midnight: trigger, 100%
midnight - sunrise: trigger, 10%
Would be really helpful to get some hints on how to extend the stock “Motion-activated Light” automation with my conditions, since I still struggle with the syntax in yaml-files.
You can use the gui, why would you want this in yaml?
trigger on motion sensor
add action ‘choose’
a. Option 1: condition after sunset and time < 23:25 …action: device … light.abc, briogthness 100
b. Option 2: condition: before sunrise and time > 0:00 …action: device … light.abc, briogthness 10
thanks for the help. I guess I’m coming up much with yaml configuration cause you find many people doing it that way, I didn’t know the GUI is that mighty. Then many of my problems won’t be one anymore.
One question left: If i choose the device “motion sensor” and use as a trigger “detect motion”, can I add a second trigger with “no motion detected” in the same automation to turn the lamps off again?
Okay, I’ve tried many different things but I can’t get it to work like I want to. I try to put it just into words and write my yaml after, maybe someone of you can fix it and tell me what I did wrong. I’ve used the virtual editor for this. thanks alot for your help!
after sunset until midnight turn on the light 100%
after midnight until 3am turn on the light 30%
turn the light always on when the contactsensor of the door opens
Thanks for your answer. I’ve just tried the long and short version, both aren’t working. In the automation tab I see the long version gets triggered, but the light doesn’t turn on. I’ve looked up the entity sun.sun, which says “under the horizont”. I’ve also removed the part with getting triggered after sunset, still no lights with motion detection, nor door opening…
Thanks for your edits, tried those aswell and it seems to work… ALMOST. The silly door sensor doesn’t seem to trigger the light. I’ve been toodeling around all day already and ended running two automations, one for the motion sensor and a second one for the contact sensor. Not the best solution, but I can’t find a better way right now.
EDIT
To explain what I’ve tried to do… The light acted very stiff. So once it gets triggered it stayed on for 30 seconds and went off, ignoring if someone is still around or not. Thats why I’ve added the “binary_sensor” state “off” for 30 secs.
Thanks for your code. It took a while for me to understand whats happening in the last line, but I got it. So basically it waits for the binary_sensor state to change from on to off, else it goes 100%, if later than 16:00 it goes 30%. I’ll give it a try, tbh I liked previous solutions better cause I could understand them easier - tho this is the cleanest way to write it
Your requirements are to have a motion detector turn on a light the moment when motion is detected and turn it off if no motion is detected for at least 30 seconds. The only added twist is that when it turns on the light, it sets brightness to less than 100% if the current time is before 16:00.
The automation I posted meets those requirements and works like this:
It’s triggered by the binary sensor’s state changing to on or to off.
The condition confirms the current time is between sunset and sunrise.
The action is simply one service call:
If the binary sensor’s state changed to off it turns off the light by setting brightness_pct to zero.
If the binary sensor’s state changed to on it turns on the light and sets brightness_pct to either 100 (if the current hour is greater than or equal to 16) or 30.
Thanks for the explanation, that really helped me since I’m new to HA. Does it make sense to implement the door sensor in it or is it fine to run two automations for that? I don’t know if they will interrupt each other.
Like:
door sensor open = light 100% if time inbetween sunset and midnight, turn off after 30 secs if motion = off
If the door sensor is supposed to control the light in the same way as the motion sensor, you can add simply add it to the first State Trigger.
- platform: state
entity_id:
- binary_sensor.flur_hue_bm_motion
- binary_sensor.lumi_lumi_sensor_magnet_aq2_opening
from: 'off'
to: 'on'
You don’t have to add the door sensor to the second State Trigger (unless you also want it to turn off the light after the door is closed for 30 seconds) because the motion sensor can take care of doing that on its own.