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.68k stars 664 forks source link

米家p1燃气灶套装,电池电量实体错误 #1630

Open xtjun opened 7 months ago

xtjun commented 7 months ago

Device model / 设备型号

cykj.hood.jyj22

Component version / 插件版本

0.7.17

HA core version / HA版本

2024.4.3

Integrated mode / 集成方式

Local (本地模式)

The problem / 问题详情

电量实体一直报错,因为此设备上报燃气灶的电量为normal,而不是数值类型

Entity attributes / 实体属性

实体不可用

Home Assistant Logs / 系统日志

2024-04-17 10:11:43.721 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 663, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'normal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 666, in state numerical_value = float(value) ^^^^^^^^^^^^ ValueError: could not convert string to float: 'normal'

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1035, in _update_entity_states await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 969, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 670, in state raise ValueError( ValueError: Sensor sensor.cykj_jyj22_e9f6_battery_level has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'normal' (<class 'str'>) 2024-04-17 10:11:45.626 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.cykj_jyj22_e9f6_light fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 663, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'normal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 666, in state numerical_value = float(value) ^^^^^^^^^^^^ ValueError: could not convert string to float: 'normal'

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 951, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update await self.async_update() File "/config/custom_components/xiaomi_miot/init.py", line 1524, in async_update await self.async_update_for_main_entity() File "/config/custom_components/xiaomi_miot/init.py", line 1565, in async_update_for_main_entity self._update_sub_entities( File "/config/custom_components/xiaomi_miot/init.py", line 2101, in _update_sub_entities self._subs[fnm].update_from_parent() File "/config/custom_components/xiaomi_miot/init.py", line 2461, in update_from_parent self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 670, in state raise ValueError( ValueError: Sensor sensor.cykj_jyj22_e9f6_battery_level has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'normal' (<class 'str'>)

al-one commented 7 months ago

尝试master分支。