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.36k stars 613 forks source link

浦安达单相智能保护开关电量数据为0 #1530

Open mickey50 opened 6 months ago

mickey50 commented 6 months ago

Device model / 设备型号

iot.switch.padw2p

Component version / 插件版本

0.7.15

HA core version / HA版本

2024.2.1

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

在miio auto中显示的电量为0,米家app中有数据 Screenshot_2024-02-12-18-30-23-143_com xiaomi smarthome Screenshot_2024-02-12-18-29-57-506_com android chrome

Entity attributes / 实体属性

state_class: total_increasing entity_class: MiotSensorSubEntity parent_entity_id: switch.iot_padw2p_3856_switch service_description: Power Consumption property_description: Power Consumption updated_time: "2024-02-12T17:13:55.630297+08:00" power_consumption: 0 unit_of_measurement: Wh friendly_name: 过欠压电表 Power Consumption supported_features: 0

Home Assistant Logs / 系统日志

No response

mickey50 commented 6 months ago

查了下miot-spec的本身就没有数据,需要使用/v2/user/statistics 这个接口获得数据

al-one commented 6 months ago

请提供/v2/user/statistics接口的具体请求参数

mickey50 commented 6 months ago

请提供/v2/user/statistics接口的具体请求参数 参数参考这里面描述:https://miecosystem.github.io/miot-plugin-sdk/module-miot_service_smarthome.html 接口对应这个 api的调用 getUserStatistics 示例: micli.py /v2/user/statistics '{"did": "745638077", "time_start": 1706716800, "time_end": 1709222400, "limit": 0, "accessKey": "IOS00026747c5acafc2", "key": "3.1", "data_type": "stat_day_v3"}'

roycho93 commented 5 months ago

请问这个问题有没有得到解决,我也用的这款断路器

roycho93 commented 5 months ago

另外这边https://github.com/al-one/hass-xiaomi-miot/issues/1451 好像可以获取到温度信息,现在却没有了,有没有办法解决呢

al-one commented 5 months ago

尝试master分支

mickey50 commented 5 months ago

尝试master分支

在传感器中没有出现相关的传感器

mickey50 commented 5 months ago

尝试master分支

在传感器中没有出现相关的传感器

看了代码,明白了,数据是放在switch的属性里面,已经有数据了,Power cost today Power cost month

mickey50 commented 5 months ago

尝试master分支

在传感器中没有出现相关的传感器

看了代码,明白了,数据是放在switch的属性里面,已经有数据了,Power cost today Power cost month

建议还是一个sensor好一些,能源的页面就可以直接加入了

mickey50 commented 5 months ago

电压、功率、电流的数据无法更新了 2024-03-14 02:55:49.347 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.iot_padw2p_3856_switch fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1262, in async_device_update
await self.async_update()
File "/config/custom_components/xiaomi_miot/switch.py", line 100, in async_update
await super().async_update()
File "/config/custom_components/xiaomi_miot/init.py", line 1415, in async_update
results = await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/init.py", line 702, in get_properties_for_mapping
return self.get_properties(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 240, in get_properties
values.extend(self.send(property_getter, _props[:max_properties]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/miio/device.py", line 107, in send
return self._protocol.send(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/miio/miioprotocol.py", line 202, in send
self.__id = payload["id"]