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.5k stars 636 forks source link

小米门窗传感器光照度不再可用,日志有报错 #1137

Open chauyuen opened 1 year ago

chauyuen commented 1 year ago

Device model / 设备型号

isa.magnet.dw2hl

Component version / 插件版本

0.7.9

HA core version / HA版本

2023.5.4

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

从2023.05以来门窗传感器经常出现不再可用或者长期保持在Close状态,状态不刷新。尝试从插件中删除设备重新添加,可以用一段时间,又会开始之前的状态不刷新。查看系统日志如下。

Entity attributes / 实体属性

model: isa.magnet.dw2hl
lan_ip: 
mac_address: (已删除)
entity_class: BleBinarySensorEntity
home_room: XXXX的家
miot_type: urn:miot-spec-v2:device:magnet-sensor:0000A016:isa-dw2hl:1
magnet_sensor.illumination: 2
magnet_sensor.contact_state: true
battery_level: 100
state_updater: cloud
light_strong: true
illumination_level: strong
state_property: magnet_sensor.contact_state
sub_entities: battery-3.battery_level-1, magnet_sensor-2.illumination-1
device_class: door
friendly_name: 门窗传感器 门窗传感器
supported_features: 0

Home Assistant Logs / 系统日志

Logger: homeassistant.helpers.entity Source: components/sensor/init.py:583 First occurred: 22:12:23 (5 occurrences) Last logged: 22:13:23

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

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 554, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 779, in async_device_update await self.async_update() File "/config/custom_components/xiaomi_miot/init.py", line 1476, in async_update await self.async_update_for_main_entity() File "/config/custom_components/xiaomi_miot/binary_sensor.py", line 193, in async_update_for_main_entity await super().async_update_for_main_entity() File "/config/custom_components/xiaomi_miot/binary_sensor.py", line 127, 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 2048, in _update_sub_entities self._subs[fnm].update_from_parent() File "/config/custom_components/xiaomi_miot/init.py", line 2406, in update_from_parent self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 583, in state raise ValueError( ValueError: Sensor sensor.isa_dw2hl_9395_illumination has device class illuminance, state class None unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: weak (<class 'str'>)

wynnforthework commented 1 year ago

我的门窗传感器状态变更也不通知,不仅仅是延迟,打开几个小时时候,进入HA还显示关闭状态,手动更新后状态才正确。

wolnlow commented 1 year ago

同样问题+1

dails1987 commented 1 year ago

同样问题+1

al-one commented 1 year ago

尝试master分支。

SodaWithoutSparkles commented 1 year ago

确认问题了,估计是亮度那里有问题直接把整个流程挂起。如果只要门窗感应的,先去home assistant > device > 门窗传感器 > 亮度 > disable。用了一天多,除了偶尔变成unavailable 之外,一切正常。unavailable 也会在几秒内自动处理

chauyuen commented 1 year ago

尝试master分支。

不行,问题和报错依旧

SodaWithoutSparkles commented 1 year ago

因为这个门窗感应器只有"光亮"和"黑暗"两种状态,不如直接写一段逻辑专门给这个感应器,只有一个is_bright