Problem in motion sensor + light sensor automation

My entire network consists of Zigbee devices. I have several motion sensors that I use to turn on lights. These sensors also have an integrated light sensor.

I created an initial automation that simply responded to the motion sensor stimulus to turn on the lights. Later, I wanted to improve this automation by including checking the ambient light level. This way, the lights would only turn on if the light level was low. I made this upgrade because at certain times of the day the natural light was sufficient.

However, I noticed that my automation wasn’t working properly. Sometimes the light would turn on and other times it wouldn’t. I monitored it and realized that, at times, the light level recorded by the device was from when the light was still on, even after it had been off for a while.

Looking at the Zigbee message generated by the sensor, it provides all the information at once:

  • Movement
  • LQI (Location Quotient)
  • Last Seem
  • Brightness
  • Etc.

But it seems that Home Assistant breaks down this information by sensor, and some are updated before others. So the automation triggered by motion detection checks for conditions where the brightness is high (even if it isn’t in the current event) and doesn’t turn on the light.

I tried to solve this by reducing the device’s brightness update time. I reduced the interval to 5 minutes. Even so, it’s possible that we might pass by the location in a shorter interval and the automation won’t work. And if I set the device to notify about the brightness every 1 minute, the battery will be consumed quickly, which wouldn’t be ideal.

Ideally, when the sensor sends all the information to Home Assistant, it should be available for real-time validation. That is, before the motion event is triggered, all sensors related to the device should be updated first.

I don’t know if there’s any way to fix this in the device settings or in Home Assistant. Has anyone seen a similar situation before?

I have two types of SONOFF sensors: SNZB-O3P & SNZB-06P

As far as I can tell in both cases the movement/presence sensor is primary and the illumination sensor is secondary.

It appears the the sensors only send updates when the primary status changes (including the illumination status as additional information).

Given my sensors are tied to lights though automations and that the lights being on is sufficient to change the illumination state, in my case the illumination state is rarely accurate (to be clear it was correct when the status was sent - it’s just the status changed shortly after that - when the automation ran either to turn on or off the light).

TL;DR - I don’t use illumination status in any of my automations.


I don’t use it, so I can’t say if this will work, but one thing you might try is to:

  • Remove the illumination check from the conditions section of the automation.
  • Add a short delay as the first action (say 100 ms)
  • Then add a condition to check the illumination as the second action.

This is a bit of a Hail Mary pass, but it might work / worth a try.


PS I do have an old school PIR sensor (not Zigbee compatible) that has a physical switch that won’t detect motion during the day (when light is detected) I am not sure if that is an option with Zigbee sensors, but its another path to investigate.

1 Like

I have a similar issue but don’t want to introduce any delay in the switching logic if I can avoid it.

Instead, I am going to try using a dedicated light sensor set up pointing out of a window to measure external ambient light (should be no light from internal or external lights falling on it.) If I poll it every minute or so, I hope I can use the most recent external ambient level in conditions for any lights-on automations. Each automation can then have an independent, relevant, external lux level at which it will pass.