Logic game in Home Assistant :) I really need a physicist!

Hello everyone!

I bought this light sensor (https://www.amazon.it/Multimode-Gateway-supporto-Bluetooth-Homekit/dp/B082YZQ2SW/ref=sr_1_7?__mk_it_IT=ÅMÅŽÕÑ&dchild=1&keywords=light%2Bsensor&qid=1625065033&sr=8-7&th=1) and this Hue motion sensor (https://www.amazon.it/gp/product/B0748NCMNW/ref=ppx_yo_dt_b_asin_image_o01_s00?ie=UTF8&psc=1).

I was able to integrate them perfectly on Home Assistant thanks to the ConBee II usb and using DeConz addon.

My goal was to create an automation that would turn on the lights in the room when it detected movements and ONLY if the brightness (detected from the light sensor) was lower than a certain set value. There are, however, two important factors to consider:

  1. The Hue motion sensor has an update time of only 15 seconds
  2. The brightness sensor only updates 10 seconds after a large change in brightness

This poses a major problem in running the automation.

Let me explain with a practical example:

  • I walk into a dark room. The automation starts, because the motion sensor detects me (trigger) and because the brightness is lower than the set cut-off (condition).

  • Meanwhile I move to another room. The motion sensor waits 15 seconds before analyzing the area again (as mentioned above). After 15 seconds, the motion sensor checks the area and sees no movement, so it turns off the lights in the room (thanks to another simple automation I created).

  • However, 10 seconds pass from the moment the lights go out to when the brightness sensor transmits the new value to Home Assistant.

  • In these 10 seconds I go back to the room, which is now dark. However, as already mentioned, the brightness value in HA has not yet been updated, because 10 seconds have not yet elapsed. As a result, the automation fails! Because the motion sensor detects movement (trigger) but the brightness value present in the room (condition) is still the old one it was when the light was on and therefore is greater than the cut-off.

Can anyone help me? How could I solve this problem? How can I bypass this issue?

In your lights off automation, after turning the lights off, try forcing an update of your brightness sensor with the homeassistant.update_entity service.

This may or may not work, depending on the actual brightness sensor having a new value to send.

If it does not work there may be another (messy) way around it using an input boolean.

I am using Aqara sensors which has built in motion and illuminance support. So whenever motion is detected, it also updates its illuminance and you will get up to date data all the time.