make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.38k stars 533 forks source link

Request support for "Metering WIFI smart circuit breaker / 计量WIFI智能断路器" #1537

Closed RoelDU closed 9 months ago

RoelDU commented 10 months ago

Log Message

Logger: custom_components.tuya_local.config_flow
Source: custom_components/tuya_local/config_flow.py:97
Integration: tuya_local ([documentation](https://github.com/make-all/tuya-local), [issues](https://github.com/make-all/tuya-local/issues))
First occurred: 8:02:04 PM (2 occurrences)
Last logged: 8:28:46 PM

Device matches compteur_energy_meter with quality of 62%. DPS: {"updated_at": 1705482122.6748202, "1": true, "9": 0, "17": 101, "18": 15423, "19": 21, "20": 2427, "21": 2, "22": 0, "23": 0, "24": 0, "25": 0, "26": 0, "38": "memory", "40": "relay", "42": "", "47": 37}
Device matches compteur_energy_meter with quality of 62%. DPS: {"updated_at": 1705483724.1985, "1": true, "9": 0, "17": 617, "18": 15423, "19": 21, "20": 2427, "21": 2, "22": 0, "23": 0, "24": 0, "25": 0, "26": 0, "38": "memory", "40": "relay", "42": "", "47": 39}

Information about DPS mappings

{
  "result": {
    "model": "{\"modelId\":\"e0f0us\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[
{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"switch_1\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_power2\",\"attribute\":\"645\"},\"name\":\"开关\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
{\"abilityId\":9,\"accessMode\":\"rw\",\"code\":\"countdown_1\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_time2\",\"attribute\":\"736\"},\"name\":\"开关倒计时\",\"typeSpec\":{\"max\":86400,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"s\"}},
{\"abilityId\":17,\"accessMode\":\"ro\",\"code\":\"add_ele\",\"description\":\"如有大电流规格调整硬件适配,可手工修改上限值,其他配置勿动。\",\"extensions\":{\"attribute\":\"1728\"},\"name\":\"增加电量\",\"typeSpec\":{\"max\":50000,\"min\":0,\"scale\":3,\"step\":100,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":18,\"accessMode\":\"ro\",\"code\":\"cur_current\",\"description\":\"默认参考开源方案建议使用额定电流规格不大于63A,如有大电流规格应用需求,需调试修改匹配的采样电阻及合适的互感器组合,并编辑调整本DP的数值上限配置,其他配置勿动。\",\"extensions\":{\"attribute\":\"1728\"},\"name\":\"当前电流\",\"typeSpec\":{\"max\":100000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"mA\"}},
{\"abilityId\":19,\"accessMode\":\"ro\",\"code\":\"cur_power\",\"description\":\"如有大电流规格调整硬件适配,可手工修改上限值,其他配置勿动。\",\"extensions\":{\"attribute\":\"1728\"},\"name\":\"当前功率\",\"typeSpec\":{\"max\":34500,\"min\":0,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"W\"}},
{\"abilityId\":20,\"accessMode\":\"ro\",\"code\":\"cur_voltage\",\"description\":\"\",\"extensions\":{\"attribute\":\"704\"},\"name\":\"当前电压\",\"typeSpec\":{\"max\":5000,\"min\":0,\"scale\":1,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"V\"}},
{\"abilityId\":21,\"accessMode\":\"ro\",\"code\":\"test_bit\",\"description\":\"\",\"extensions\":{\"attribute\":\"736\"},\"name\":\"产测结果位\",\"typeSpec\":{\"max\":5,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":22,\"accessMode\":\"ro\",\"code\":\"voltage_coe\",\"description\":\"\",\"extensions\":{\"attribute\":\"736\"},\"name\":\"电压校准系数\",\"typeSpec\":{\"max\":1000000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":23,\"accessMode\":\"ro\",\"code\":\"electric_coe\",\"description\":\"\",\"extensions\":{\"attribute\":\"736\"},\"name\":\"电流校准系数\",\"typeSpec\":{\"max\":1000000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":24,\"accessMode\":\"ro\",\"code\":\"power_coe\",\"description\":\"\",\"extensions\":{\"attribute\":\"736\"},\"name\":\"功率校准系数\",\"typeSpec\":{\"max\":1000000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":25,\"accessMode\":\"ro\",\"code\":\"electricity_coe\",\"description\":\"\",\"extensions\":{\"attribute\":\"736\"},\"name\":\"电量校准系数\",\"typeSpec\":{\"max\":1000000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0}},
{\"abilityId\":26,\"accessMode\":\"ro\",\"code\":\"fault\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-baojing\"},\"name\":\"故障告警\",\"typeSpec\":{\"label\":[\"ov_cr\",\"ov_vol\",\"ov_pwr\",\"ls_cr\",\"ls_vol\",\"ls_pow\",\"short_circuit_alarm\",\"overload_alarm\",\"leakagecurr_alarm\",\"self_test_alarm\",\"high_temp\",\"unbalance_alarm\",\"miss_phase_alarm\"],\"maxlen\":13,\"type\":\"bitmap\",\"typeDefaultValue\":0}},
{\"abilityId\":38,\"accessMode\":\"rw\",\"code\":\"relay_status\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-zhuangtai\",\"attribute\":\"736\"},\"name\":\"上电状态设置\",\"typeSpec\":{\"range\":[\"off\",\"on\",\"memory\"],\"type\":\"enum\",\"typeDefaultValue\":\"off\"}},
{\"abilityId\":40,\"accessMode\":\"rw\",\"code\":\"light_mode\",\"description\":\"\",\"extensions\":{\"iconName\":\"tcl_function_light\",\"attribute\":\"224\"},\"name\":\"指示灯状态设置\",\"typeSpec\":{\"range\":[\"relay\",\"pos\",\"none\",\"on\"],\"type\":\"enum\",\"typeDefaultValue\":\"relay\"}},
{\"abilityId\":42,\"accessMode\":\"rw\",\"code\":\"cycle_time\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_time3\",\"attribute\":\"128\"},\"name\":\"循环定时\",\"typeSpec\":{\"maxlen\":255,\"type\":\"string\",\"typeDefaultValue\":\"\"}},
{\"abilityId\":47,\"accessMode\":\"ro\",\"code\":\"temp_value\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-lengnuan\"},\"name\":\"温度\",\"typeSpec\":{\"max\":999,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"℃\"}},
{\"abilityId\":48,\"accessMode\":\"rw\",\"code\":\"alarm_set_1\",\"description\":\"固件106版本支持,低版本固件不支持。\\n1,告警阈值使能控制及设置1\\n2,HEX格式,大端模式, 总告警的数量*4字节= 设置告警总长度。\\n3,报文格式\\n每个告警由4个字节组成,第1个字节(表示该告警存在);第2个字节(发生此告警时,断路器控制模式(0X01拉闸,0X00不动作只告警);第3、4字节:设置告警阈值。\\n举例:0X01 01 00 00 03 01 00 14,表示该断路器支持短路告警,发生该告警时,自动跳闸,阀值补0。支持过载告警,发生该告警时,拉闸动作,动作阀值20KW。无其它告警功能。注:没有的告警,就不要上报字节。\\n4,通信逻辑\\nA,配网成功后,按照上面的格式,主动上报给云平台,面板知道哪些告警是断路器当前支持的。设置不成功,重新配网再上报。\\nB,断路器上电时,也上报一次。\\nC,面板根据协议下发告警设置。\\n5 APP面板支持第一字节能力清单:01短路告警,02浪涌告警,03过载告警,04漏电告警,05高温告警,06打火告警,07功率过高告警,08漏电自检异常告警\",\"extensions\":{\"iconName\":\"icon-dp_warming\",\"attribute\":\"128\"},\"name\":\"告警设置1\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},
{\"abilityId\":49,\"accessMode\":\"rw\",\"code\":\"alarm_set_2\",\"description\":\"固件106版本支持,低版本固件不支持。\\n1,告警阈值使能控制及设置2\\n2,HEX格式,大端模式\\n3,报文格式 每个告警由4个字节组成,第1个字节(表示该告警存在);第2个字节(发生此告警时,断路器控制模式(0X01拉闸,0X00不动作只告警);第3、4字节:设置告警阈值 举例:0X01 01 00 3C 03 01 00 F5,表示该断路器支持过流告警,发生该告警时,拉闸动作,动作阀值60A。支持过压告警,发生该告警时,拉闸动作,动作阀值245V 4,通信逻辑 A,配网成功后,按照上面的格式,主动上报给云平台,面板知道哪些告警是断路器当前支持的。设置不成功,重新配网再上报。 B,断路器上电时,也上报一次。 C,面板根据协议下发告警设置。\\n5 APP面板支持第一字节能力清单:01过流告警,02三相不平衡告警,03过压告警,04欠压告警,05缺相告警,06停电事件告警,07强磁告警,08余额不足告警,09欠费告警\",\"extensions\":{\"iconName\":\"icon-dp_warming\"},\"name\":\"告警设置2\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}}]}]}"
  },
  "success": true,
  "t": 1705483142414,
  "tid": "742ea37db51911ee965f7eb6fd123fbf"
}.

Product ID

"product_id": "cipuwutzfuqk3iru"

Information about how the device functions

This is the device: https://www.aliexpress.com/item/1005005945418460.html?spm=a2g0o.order_list.order_list_main.15.2ce51802PTwd46

RoelDU commented 9 months ago

If I select Smartplug2 Energyv2 I'm not able to add it in my Energy Dashboard as it is missing device_class energy and state_class increasing. Without these I'm not able to add it to my energy dashboard. I know I can create a helper but it would be great if this would work directly from tuyalocal.

make-all commented 9 months ago

With Tuya energy meter devices, the dp labelled "total_forward_energy" is usable directly in the energy dashboard. But this device only has the "add_ele" dp that many smartplugs use to increment cloud based energy statistics, which is not usable as a total_increasing state_class because it resets too frequently. Such devices need to use an integration helper on the power sensor, sorry.