How to stop motion sensors from triggering lights during the day?

I recently installed motion sensors to automatically turn on hallway and kitchen lights when someone walks in. They work great at night but during the day they keep turning on the lights even when there is plenty of natural sunlight.

I have checked the settings but I am not sure if it is an issue with the sensors themselves or if I need to add some kind of daylight sensor/override.

Has anyone here set up motion sensors so they only work in low light conditions? What is the best way to fine tune them so I am not wasting electricity during the day?
Thanks in advance for any suggestions

What sensors are you using. Are they controlled through OpenHAB?

1 Like

Hi James,
I am using generic PIR motion sensors one of them is a Sonoff and yes, they are controlled through OpenHAB. Right now I am just using basic rules to trigger the lights but I haven’t added any lux/light level condition yet.

If you or @denominator have suggestions on how to set up that daylight check in OpenHAB, I do appreciate it.

Use Astro binding, Add a condition to check if sun elevation less than zero.

We should probably add time of day channel (morning, noon, night etc) to Astro to make such checks even easier

2 Likes

Thanks for the tip,
I have not used the Astro binding much yet but checking the sun elevation sounds like exactly what I need. I will try setting a rule so the motion sensor triggers only when the elevation is below zero.

And yes, having a built-in time of day channel in Astro would make these kinds of conditions much simpler to set up.

I asked ai

Times of day based on sunrise and sunset include dawn, sunrise, morning, noon, afternoon, sunset, evening, dusk, and night.

1 Like

https://discourse.openhab.org/t/creating-capabilities-with-rule-templates-time-of-day/127965

This may help

2 Likes

If it’s just this one motion sensor or a small set of motion sensors, this suggestion by @jimtng is going to be the least work overall.

If you have lots more things you want to control based on the time of day, the Time Based State Machine is going to be useful for you. Just note that the tutorial @denominator linked to is a bit old at this point. Since then OH has gained new features that made some stuff that used to have to be done in rules now part of OH itself, such as being able to trigger a rule at the time or datetime in a DateTime Item.

The latest time state machine template is at https://discourse.openhab.org/t/time-based-state-machine-4-0-0-0-5-9-9-9/144208.

1 Like

You also might consider adding a motion sensor with an exposed illuminance item that could also be used to override the astro binding or other time cron lock out approach for low light conditions even say during a dark and cloudy day where the amount of sun light may not be sufficient for the area the lighting illumnates.

2 Likes

That’s a good idea. Then you don’t need to mess with time at all.

If you have a weather binding with a cloudiness value and the Astro binding, there’s even a rule template on the marketplace to create a virtual illuminance sensor. https://discourse.openhab.org/t/virtual-solar-light-sensor-4-0-0-0-5-9-9-9/147023

1 Like

… if it works well. I’ve got a few Shelly BLU Motions, which do declare lux values, but those only get updated when motion is detected (no problem so far) and they’re inconsistent. In the same room, one reads 116 lux, the other one 28 lux.

But they’re in a room without windows. I think they update the lux value that was ‘applicable’ right before the motion, and thus by the time the second device detected motion, there was more light (since they switch the ceiling light). If you use them in a light in which there already is sunlight, that aspect might work better.

1 Like

I had a closer look at the Astro docs, this already exists as phase#name:

SUN_RISE, ASTRO_DAWN, NAUTIC_DAWN, CIVIL_DAWN, CIVIL_DUSK, NAUTIC_DUSK, ASTRO_DUSK, SUN_SET, DAYLIGHT, NOON, NIGHT

With MAP transformation, this can be converted to a Switch item, e.g. ON = Sun is up, OFF = Sun is Down

# Adjust accordingly
# SUN_RISE, ASTRO_DAWN, NAUTIC_DAWN, CIVIL_DAWN, CIVIL_DUSK, NAUTIC_DUSK, ASTRO_DUSK, SUN_SET, DAYLIGHT, NOON, NIGHT

SUN_RISE=ON
DAYLIGHT=ON
NOON=ON
=OFF

But then again, with the correct transformation, one can convert Sun elevation to a switch item.

I use this:

Screenshot from 2025-08-12 09-56-07

I have light sensors, either built into the motion sensor or separate, it doesn’t really matter. I also set up 2 dummy items as threshold ON and threshold OFF. So, for example, if light level 0 is night and light level 60 is with the lights on, I set the threshold ON = 50 and OFF = 65 to avoid an ON-OFF-ON flip-flop. If the light drops below 50 the lights switch on and the level then increases to 60 but the light doesn’t turn off until the ambient light increases further to 65. The threshold levels are controlled by sliders on my UI. I also have a dummy switch named AUTO to override everything. So my rule is basically

if light level < threshold ON turn on lights.

If light level > threshold OFF turn lights off

but only if AUTO ==ON.