Xiaomi Human / Body / Motion Sensor - Timeout

Are you aware of this conflusion:

Can you please post the latest updated code. Thanks

Sure, no problem.

- id: '1541182668961'
  alias: Lampen aan bij beweging in hal
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx59
    from: 'off'
    platform: state
    to: 'on'
  condition:
    condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.illumination_xxa6
      below: 10
    - condition: or
      conditions:
      - condition: time
        after: '06:00'
        before: '23:59'
      - condition: time
        after: '00:00'
        before: '01:00'
  action:
  - data:
      entity_id: light.hal
    service: light.turn_on
  - condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.motion_sensor_xxf6
      state: 'off'
    - condition: time
      after: '01:00'
      before: '10:00'
  - data:
      entity_id: input_boolean.kamer_lampen_aan_door_hal_sensor
    service: input_boolean.turn_on
  - data:
      entity_id: group.tradfri_lr_lights
    service: homeassistant.turn_on
- id: '1541264176539'
  alias: Lamp uit na sensor hal uit
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx59
    from: 'on'
    platform: state
    to: 'off'
  action:
  - data:
      entity_id: light.hal
    service: light.turn_off
  - condition: state
    entity_id: input_boolean.kamer_lampen_aan_door_hal_sensor
    state: 'on'
  - data:
      entity_id: group.tradfri_lr_lights
    service: homeassistant.turn_off
  - data:
      entity_id: input_boolean.kamer_lampen_aan_door_hal_sensor
    service: input_boolean.turn_off
- id: '1542306632487'
  alias: Lamp aan na beweging op overloop
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx33
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ states.sensor.period_of_day.state != "day" }}'
  action:
  - data_template:
      entity_id: '{% if not( "01:00" < states.sensor.time.state < "06:00") %} light.overloop {% else %} light.hal
        {% endif %}'
    service: light.turn_on
- id: '1541858493516'
  alias: Lamp uit na overloop sensor uit
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx33
    from: 'on'
    platform: state
    to: 'off'
  condition:
    condition: state
    entity_id: binary_sensor.motion_sensor_xx07
    state: 'off'
  action:
  - data_template:
      entity_id: '{% if states.light.hal.state == "on" %} light.hal {% else %} light.overloop {% endif %}'
    service: light.turn_off
- id: '1544867834009'
  alias: Lamp aan na beweging op zolder
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx07
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ states.sensor.period_of_day.state != "day" }}'
  action:
  - data_template:
      entity_id: '{% if not( "01:00" < states.sensor.time.state < "04:00") %} light.overloop {% else %} light.hal
        {% endif %}'
    service: light.turn_on
- id: '1546163155123'
  alias: Lamp uit na zolder sensor uit
  trigger:
  - entity_id: binary_sensor.motion_sensor_xx07
    from: 'on'
    platform: state
    to: 'off'
  condition:
    condition: state
    entity_id: binary_sensor.motion_sensor_xx33
    state: 'off'
  action:
  - data_template:
      entity_id: '{% if states.light.hal.state == "on" %} light.hal {% else %} light.overloop {% endif %}'
    service: light.turn_off

The first set of two automations control a light in the hallway and a set of lights in the living room.
The lights are switched on and off based on the state of the motion sensor xx59 and several other conditions.

The 2nd and 3rd set of two automations control a light on the 1st floor and the light in the hallway (the same as controlled in the first set of automations), depending on the time of evening/night.

This work pretty well for me but still now and then some of the lights don’t switch off.
So I’m still trying to make improvements.
Feel free to comment on my code :slight_smile:

2 Likes

If the light doesn’t turn off could you check the state of your motion sensor? If the state is off something is wrong with your automation because HA is aware of “no motion”. If the state is stuck at on there is something wrong.

Yes,

I try to reduce the “no motion” from 120 second to 65 second. I added custom component with ```
SCAN_INTERVAL = timedelta(seconds=5)
but the sensor still only report “no motion” after 120s

What is the correct way to update no_motion from 120s to 65 secs ?

Maybe I missed something, please correct me…
Appreciate your help .

Could you provide the content (file listing) of your custom_components folder? I cannot recommend to reduce the scan interval to 5 seconds. It will drain the battery of the motion sensor probably. You are trying to increase the zigbee traffic by factor 6 per device.

I am pretty sure the custom component is loaded correct. When I start HA, this is the warning along with my other customer component

2019-01-05 22:17:29 WARNING (MainThread) [homeassistant.loader] You are using a custom component for binary_sensor.xiaomi_aqara which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

I am under impression the motion sensor sent update to gateway after 60 sec and gateway send broadcast on the change after 120 sec. The scan interval action is to pull the data from the gateway every 5 seconds which has nothing to do with the motion sensor. correct me if I am wrong.

I must admit I don’t know how the gateway handles the read instruction. Both versions are possible: Polling the ZigBee device vs. just read the last known state.

let me activate debug and see what is happening behind the scene… thanks syssi…

I’ve enabled the debug output of the component and underlying library by:

# configuration.yaml

logger:
  default: warn
  logs:
    xiaomi_gateway: debug
    homeassistant.components.xiaomi_aqara: debug
    custom_components.xiaomi_aqara: debug
    custom_components.binary_sensor.xiaomi_aqara: debug

This is the log (with scan interval = 5secs):

2019-01-05 16:38:59 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"lux":"8"}', 'cmd': 'report', 'model': 'sensor_motion.aq2'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 72.0>: {'lux': '8'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: off>: {'lux': '8'}
2019-01-05 16:38:59 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"status":"motion"}', 'cmd': 'report', 'model': 'sensor_motion.aq2'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'status': 'motion'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: off>: {'status': 'motion'}
2019-01-05 16:39:01 DEBUG (Thread-2) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:01 DEBUG (Thread-2) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:01 DEBUG (Thread-2) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:01 DEBUG (Thread-2) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:01 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:01 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:07 DEBUG (Thread-11) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:07 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:07 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:07 DEBUG (Thread-11) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:07 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:07 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:13 DEBUG (Thread-22) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:13 DEBUG (Thread-22) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:13 DEBUG (Thread-22) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:13 DEBUG (Thread-22) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:13 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:13 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:19 DEBUG (Thread-12) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:19 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:19 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:19 DEBUG (Thread-12) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:19 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:19 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:25 DEBUG (Thread-8) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:25 DEBUG (Thread-8) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:25 DEBUG (Thread-8) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:25 DEBUG (Thread-8) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:25 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:25 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:31 DEBUG (Thread-6) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:31 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:31 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:31 DEBUG (Thread-6) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:31 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:31 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:37 DEBUG (Thread-19) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:37 DEBUG (Thread-19) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:37 DEBUG (Thread-19) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:37 DEBUG (Thread-19) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:37 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:37 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:43 DEBUG (Thread-10) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:43 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:43 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:43 DEBUG (Thread-10) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:43 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:43 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:49 DEBUG (Thread-6) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:49 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:49 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:49 DEBUG (Thread-6) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:49 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:49 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:55 DEBUG (Thread-21) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:39:55 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:39:55 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:55 DEBUG (Thread-21) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:39:55 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:39:55 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:00 DEBUG (Thread-10) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:00 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:00 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:00 DEBUG (Thread-10) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:00 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:00 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:06 DEBUG (Thread-16) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:06 DEBUG (Thread-16) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:06 DEBUG (Thread-16) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:06 DEBUG (Thread-16) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:06 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:06 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:12 DEBUG (Thread-21) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:12 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:12 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:12 DEBUG (Thread-21) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:12 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:12 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:18 DEBUG (Thread-6) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:18 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:18 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:18 DEBUG (Thread-6) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:18 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:18 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:24 DEBUG (Thread-7) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:24 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:24 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:24 DEBUG (Thread-7) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:24 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:24 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:30 DEBUG (Thread-12) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:30 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:30 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:30 DEBUG (Thread-12) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:30 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:30 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:36 DEBUG (Thread-11) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:36 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:36 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:36 DEBUG (Thread-11) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:36 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:36 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:42 DEBUG (Thread-4) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:42 DEBUG (Thread-4) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:42 DEBUG (Thread-4) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:42 DEBUG (Thread-4) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:42 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:42 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:47 DEBUG (Thread-11) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:47 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:47 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:47 DEBUG (Thread-11) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:47 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:47 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:53 DEBUG (Thread-18) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:53 DEBUG (Thread-18) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:53 DEBUG (Thread-18) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:53 DEBUG (Thread-18) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:53 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:53 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:59 DEBUG (Thread-12) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:40:59 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:40:59 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:59 DEBUG (Thread-12) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:40:59 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"no_motion":"120"}', 'cmd': 'report', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'no_motion': '120'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'no_motion': '120'}
2019-01-05 16:41:05 DEBUG (Thread-10) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0002254951
2019-01-05 16:41:05 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002254951"}'
2019-01-05 16:41:05 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd resp << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:41:05 DEBUG (Thread-10) [xiaomi_gateway] read_ack << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"voltage":3025,"lux":"8"}', 'cmd': 'read_ack', 'model': 'sensor_motion.aq2'}
2019-01-05 16:41:05 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'voltage': 3025, 'lux': '8'}
2019-01-05 16:41:05 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: off>: {'voltage': 3025, 'lux': '8'}

The motion sensor is one of the second generation (with lux). Do you see the state change after the black off interval of 2min?

The same capture of a 1gen motion sensor:

2019-01-05 16:53:45 DEBUG (Thread-21) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:53:45 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:53:45 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:45 DEBUG (Thread-21) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:45 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: off>: {'voltage': 3005}
2019-01-05 16:53:49 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"status":"motion"}', 'cmd': 'report', 'model': 'motion'}
2019-01-05 16:53:49 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: off>: {'status': 'motion'}
2019-01-05 16:53:51 DEBUG (Thread-16) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:53:51 DEBUG (Thread-16) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:53:51 DEBUG (Thread-16) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:51 DEBUG (Thread-16) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:51 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:53:57 DEBUG (Thread-7) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:53:57 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:53:57 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:57 DEBUG (Thread-7) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:53:57 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:03 DEBUG (Thread-12) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:03 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:03 DEBUG (Thread-12) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:03 DEBUG (Thread-12) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:03 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:09 DEBUG (Thread-5) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:09 DEBUG (Thread-5) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:09 DEBUG (Thread-5) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:09 DEBUG (Thread-5) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:09 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:15 DEBUG (Thread-7) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:15 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:15 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:15 DEBUG (Thread-7) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:15 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:21 DEBUG (Thread-3) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:21 DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:21 DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:21 DEBUG (Thread-3) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:21 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:27 DEBUG (Thread-6) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:27 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:27 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:27 DEBUG (Thread-6) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:27 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:33 DEBUG (Thread-4) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:33 DEBUG (Thread-4) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:33 DEBUG (Thread-4) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:33 DEBUG (Thread-4) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:33 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:39 DEBUG (Thread-22) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:39 DEBUG (Thread-22) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:39 DEBUG (Thread-22) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:39 DEBUG (Thread-22) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:39 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:45 DEBUG (Thread-5) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:45 DEBUG (Thread-5) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:45 DEBUG (Thread-5) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:45 DEBUG (Thread-5) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:45 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:51 DEBUG (Thread-8) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:51 DEBUG (Thread-8) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:51 DEBUG (Thread-8) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:51 DEBUG (Thread-8) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:51 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:54:57 DEBUG (Thread-17) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:54:57 DEBUG (Thread-17) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:54:57 DEBUG (Thread-17) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:57 DEBUG (Thread-17) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:54:57 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:03 DEBUG (Thread-2) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:03 DEBUG (Thread-2) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:03 DEBUG (Thread-2) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:03 DEBUG (Thread-2) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:03 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:09 DEBUG (Thread-21) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:09 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:09 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:09 DEBUG (Thread-21) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:09 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:15 DEBUG (Thread-10) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:15 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:15 DEBUG (Thread-10) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:15 DEBUG (Thread-10) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:15 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:21 DEBUG (Thread-20) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:21 DEBUG (Thread-20) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:21 DEBUG (Thread-20) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:21 DEBUG (Thread-20) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:21 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:27 DEBUG (Thread-7) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:27 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:27 DEBUG (Thread-7) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:27 DEBUG (Thread-7) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:27 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:33 DEBUG (Thread-3) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:33 DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:33 DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:33 DEBUG (Thread-3) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:33 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:39 DEBUG (Thread-21) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:39 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:39 DEBUG (Thread-21) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:39 DEBUG (Thread-21) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:39 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:45 DEBUG (Thread-11) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:45 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:45 DEBUG (Thread-11) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:45 DEBUG (Thread-11) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:45 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'voltage': 3005}
2019-01-05 16:55:48 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"no_motion":"120"}', 'cmd': 'report', 'model': 'motion'}
2019-01-05 16:55:48 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'no_motion': '120'}
2019-01-05 16:55:51 DEBUG (Thread-6) [custom_components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling: 158d0001b159f8
2019-01-05 16:55:51 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0001b159f8"}'
2019-01-05 16:55:51 DEBUG (Thread-6) [xiaomi_gateway] _send_cmd resp << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:51 DEBUG (Thread-6) [xiaomi_gateway] read_ack << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"voltage":3005}', 'cmd': 'read_ack', 'model': 'motion'}
2019-01-05 16:55:51 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: off>: {'voltage': 3005}

Motion event: 16:53:49
No motion event: 16:55:48

-> Same 2min back off period like the 2gen sensor.

New insight: Polling is useless for this case. All requests ({ "cmd":"read","sid":"158d0002254951"}) will be answered by

'data': '{"voltage":3025,"lux":"8"}'
# or
'data': '{"voltage":3005}'

Motion and “no_motion” is reported as MCAST message always:

2019-01-05 16:38:59 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"status":"motion"}', 'cmd': 'report', 'model': 'sensor_motion.aq2'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'status': 'motion'}
2019-01-05 16:38:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: off>: {'status': 'motion'}
[...] 
2019-01-05 16:40:59 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 16075, 'sid': '158d0002254951', 'data': '{"no_motion":"120"}', 'cmd': 'report', 'model': 'sensor_motion.aq2'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Illumination_158d0002254951: 8.0>: {'no_motion': '120'}
2019-01-05 16:40:59 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0002254951: on>: {'no_motion': '120'}
$ egrep "status|no_motion" motion-1gen.txt
2019-01-05 16:53:49 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"status":"motion"}', 'cmd': 'report', 'model': 'motion'}
2019-01-05 16:53:49 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: off>: {'status': 'motion'}
2019-01-05 16:55:48 DEBUG (Thread-23) [xiaomi_gateway] MCAST (report) << {'short_id': 26331, 'sid': '158d0001b159f8', 'data': '{"no_motion":"120"}', 'cmd': 'report', 'model': 'motion'}
2019-01-05 16:55:48 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Motion Sensor_158d0001b159f8: on>: {'no_motion': '120'}

Yup, I am seeing the same result. only after 120 min it PUSH the ‘no motion’. Regardless how much you pull in between does not give you the stats change. So I guess below 120 mins is not possible. I am not sure if anyone else has done it.

Thanks so much for looking in to this again. SCAN_INTERVAL dont change anything.

Someone managed to hardware mod it to 5 secs. Well hardware mod is not my way. I going to live with 120 second. This definitely impact the battery life.

2 Likes

This mod triggers the “calibration/position mode” of the sensor (always). It’s normally used once to find a good position for the motion sensor.

1 Like

The poster says that after 1 year they still work

I managed to apply this mod using graphite pencil and now mi home app detect motion every 5 seconds, but HA still need about 1-2 minutes to update status of the motion sensor. I tried to do SCAN_INTERVAL = timedelta(seconds=10) but still no luck. Does anybody know how to manage this to work properly?

Which gateway do you own? acpartner.v3 or the lumi gateway?

I have lumi gateway.

May be the connection between the two contacts didn’t work property. Could you try to press the button instead? Does it work now for some minutes?