Experiencing delay in ambient light sensor

I am testing motion triggered lighting using HA Green, SkyConnect dongle, Everything Presence One and an Aqara H1 switch (with neutral). I have two automations, one to turn “light on” when occupancy detected and illuminance < 2lx. A second automation to turn “light off” when occupancy clear detected. The basic functionality is working.

However, there is an (irregular) delay (of seconds) before the illuminance reading adapts to a new light level. After the “light off” automation the illuminance also briefly gives an interim reading (working down towards the actual ambient light level). This interim reading is above the actual light level. The result of the delay and interim reading is that immediately after “light off” runs there is a short period of time (up to 4 secs) before the illuminance reading is adjusted to the new light level, and if the “light on” automation is run in this period then the illuminance condition is not met, and so the light does not come back on.

How might this race be resolved?

I can raise the “Below” lux entry in the “light on” illuminance condition but this results in the light otherwise often coming on when not needed (i.e. when ambient light is bright enough). Hopefully there is a better solution than this workaround. I think I could add a second condition related to daylight time but, although a better workaround, it will not allow for the nuance of dark cloudy days sometime before dusk. But maybe these are the compromises automation insists upon. Ideally I would like the illuminance entity to report on a light change immediately.

Can I get the illuminance entity to report a new light level immediately? Or is this delay down to the ESP32 ambient light sensor, and if so, is it common to all illuminance sensors (or can I get a light sensor that reacts immediately)?

This is my very first step into HA, and indeed any automation, so no solution is too obvious, and apologies for any ignorance I display here. I have searched without luck for terms like “everything presence” and “illuminance delay”. I found a post about the ESP32 WIFI power saving mode but this seems irrelevant because the lag is not there on other entities (eg PIR).

Thanks
Phil

I’ll reply to myself just in case someone else taking their first HA steps ever reads this.

I guess the solution is to have a separate light sensor away from the lights being turned on and off. Maybe one dedicated ambient light sensor pointing towards a window to read the outside light which can be used by all light automations. Doh!