al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.4k stars 615 forks source link

Aqara motion sensors won't shows the motion status #1311

Open litecross91 opened 1 year ago

litecross91 commented 1 year ago

Device model / 设备型号

lumi.sensor_motion.aq2

Component version / 插件版本

0.7.12

HA core version / HA版本

2023.9.1

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

My aqara motion sensors ( lumi.sensor_motion.aq2 ) shows only Clear status. In the Xiaomi app I can see the motion, but in HA just Clear state.

Entity attributes / 实体属性

model: lumi.sensor_motion.aq2
lan_ip: ''
mac_address: lumi.158d00046241b7
entity_class: LumiBinarySensorEntity
miot_type: urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-aq2:1
motion_sensor.motion_state: false
motion_sensor.illumination: 48
state_updater: cloud
trigger_type: prop.illumination
trigger_time: 1694438249
trigger_at: '2023-09-11 15:17:29'
state_property: motion_sensor.motion_state
sub_entities:
  - motion_sensor-2.illumination-2
  - motion_sensor-2.no_motion_duration-3
no_motion_duration-2-3: 2
device_class: motion
friendly_name: Hallway Motion Sensor Motion Sensor
supported_features: 0

Home Assistant Logs / 系统日志

aqara_sensor home-assistant_2023-09-11T14-25-15.834Z.log

litecross91 commented 1 year ago

Logger: homeassistant.helpers.entity Source: components/sensor/init.py:593 First occurred: 17:49:54 (24 occurrences) Last logged: 17:52:54

Update for binary_sensor.lumi_aq2_8183_motion_sensor fails Update for binary_sensor.lumi_aq2_41b7_motion_sensor fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 591, in state numerical_value = float(value) # type:ignore[arg-type] ^^^^^^^^^^^^ ValueError: could not convert string to float: '5 minutes'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 936, in async_device_update await self.async_update() File "/config/custom_components/xiaomi_miot/binary_sensor.py", line 334, in async_update await super().async_update() File "/config/custom_components/xiaomi_miot/init.py", line 1498, in async_update await self.async_update_for_main_entity() File "/config/custom_components/xiaomi_miot/binary_sensor.py", line 129, in async_update_for_main_entity self._update_sub_entities(['illumination', 'no_motion_duration'], domain='sensor') File "/config/custom_components/xiaomi_miot/init.py", line 2071, in _update_sub_entities self._subs[fnm].update_from_parent() File "/config/custom_components/xiaomi_miot/init.py", line 2428, in update_from_parent self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state state, attr = self._async_generate_attributes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 771, in _async_generate_attributes state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 593, in state raise ValueError( ValueError: Sensor sensor.lumi_aq2_8183_no_motion_duration has device class 'None', state class 'None' unit 'minutes' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '5 minutes' (<class 'str'>)

al-one commented 1 year ago

Try master branch.

litecross91 commented 1 year ago

Try master branch.

I'm sorry, but could you clarify that? What do you mean? I am using now a Xiaomi Gateway 3, lumi.gateway.v3, Firmware: 1.4.1_175.