Motion sensors and lux change

I’m currently moving my motion sensor logic from Hue, to Home Assistant.

I got just about everything working, triggering different scenes at different times of day, depending on how much light there currently is in the room – if the lights were off.

Now, the way I used to have it, when I would pull down the shades, Hue would notice the lux change, and check again if the lights should have been on. So I tried to recreate this in Home Assistant by creating an automation for lux change specifically. But what I noticed is that it was a lot slower than what I had with Philips Hue. Motion is instant, but lux change takes a few seconds.

I thought the delay may have been the communication between the Hue bridge, and my Linux server with it’s HA container. However, when I added a new motion sensor directly to HA (ZHA with sonoff usb-3 dongle) I did some testing, and the lux value updates a lot slower than it did with the ones connected to the Hue bridge. I even moved that specific sensor to the Hue bridge, and suddenly the delay was reduced, by a lot.

I got this all to work, but the response time is nowhere near as fast as what it was like when I handled this in Philips Hue. It did some testing. Here are response times I got while testing, from pulling down the shades, to the lights coming on:

With Hue: About 1 second
Hue → HA: About 5 seconds
ZHA → HA: 10+ seconds

Does anyone have any tips for reducing this delay, or seeing something I might have messed up – or even know why ZHA was so much slower? Otherwise I’ll probably revert back to handling motion via Hue. I like the flexibility of HA in this case, but the way the motion sensors worked felt very natural when I had it running with Hue.

Here is my “lux changed” automation – the idea was to call the motion automation, if there had been any motion in the last 30 seconds.

alias: 'Luminance: Bad'
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.bad_motion_sensor_illuminance
condition:
  - condition: not
    conditions:
      - type: is_no_motion
        condition: device
        device_id: 02aa0d1845bb7b04d4d6226b4fe5cd01
        entity_id: binary_sensor.bad_motion_sensor_motion
        domain: binary_sensor
        for:
          hours: 0
          minutes: 0
          seconds: 30
    enabled: true
action:
  - service: automation.trigger
    data:
      skip_condition: false
    target:
      entity_id: automation.motion_badet
mode: restart

Here is the motion sensor automation:

description: ''
trigger:
  - type: motion
    platform: device
    device_id: 02aa0d1845bb7b04d4d6226b4fe5cd01
    entity_id: binary_sensor.bad_motion_sensor_motion
    domain: binary_sensor
condition:
  - condition: numeric_state
    entity_id: sensor.bad_motion_sensor_illuminance
    below: '25'
  - condition: state
    entity_id: light.bad_spotter
    state: 'off'
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.parents_bedtime
            state: 'on'
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.badet_nightlight
            metadata: {}
      - conditions:
          - condition: state
            entity_id: input_datetime.bedtime_kids
            state: 'on'
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.badet_dimmed
            metadata: {}
    default:
      - service: scene.turn_on
        target:
          entity_id: scene.badet_bright
        metadata: {}
mode: restart

I have noticed the same delay in fact longer delays for the Lux to change, did you find a work around?

I did not, no. Learned to live with it