tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
870 stars 206 forks source link

Energy usage `cur_current`, `cur_power`, `cur_voltage` report is missing from a status of mcb with category `cz` #527

Open Zen3515 opened 2 years ago

Zen3515 commented 2 years ago

Describe the bug I bought a MCB that can report power energy in the app, but when use tuyav1 or tuyav2 with homeassistant there is no such energy sensor.

Expected behavior I expected the device to create entity for energy or has cur_current, cur_power, cur_voltage keys in the logs.

Screenshots Screenshot_2021-10-06-21-27-40-027_com tuya smart

Home Assistant Version

Device info (please complete the following information, which can be found in log): like this:

{
    "active_time": 1632837806,
    "biz_type": 0,
    "category": "cz",
    "create_time": 1632837795,
    "icon": "smart/icon/ay1553135333939ynSju/24b1a8c40e7ee71f6ac0de02c16ab57e.png",
    "id": "deviceid1deviceid1devi",
    "ip": "***",
    "lat": "***",
    "local_key": "***",
    "lon": "***",
    "model": "WDYK-100",
    "name": "Home main switch RCBO",
    "online": false,
    "owner_id": "***",
    "product_id": "aynmagfq01aq70he",
    "product_name": "RC-RCBO",
    "status": [
        {
            "code": "switch_1",
            "value": false
        },
        {
            "code": "countdown_1",
            "value": 0
        },
        {
            "code": "relay_status",
            "value": "last"
        },
        {
            "code": "child_lock",
            "value": false
        }
    ],
    "sub": false,
    "time_zone": "+07:00",
    "uid": "***",
    "update_time": 1632838488,
    "uuid": "62fe06079f47998b"
}

Device specifications (please complete the following information, which can be found in log): Same device's id, like this:

2021-10-06 17:56:28 DEBUG (SyncWorker_7) [tuya iot] Request: method = GET, url = https://openapi.tuyaus.com/v1.0/devices/deviceid1deviceid1devi/specifications, params = None, body = None, t = 1633517788387

2021-10-06 17:56:28 DEBUG (SyncWorker_7) [tuya iot] Response: {
    "result": {
        "category": "cz",
        "functions": [
            {
                "code": "switch_1",
                "type": "Boolean",
                "values": "{}"
            },
            {
                "code": "countdown_1",
                "type": "Integer",
                "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
            },
            {
                "code": "child_lock",
                "type": "Boolean",
                "values": "{}"
            }
        ],
        "status": [
            {
                "code": "switch_1",
                "type": "Boolean",
                "values": "{}"
            },
            {
                "code": "countdown_1",
                "type": "Integer",
                "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
            },
            {
                "code": "relay_status",
                "type": "Enum",
                "values": "{\"range\":[\"power_off\",\"power_on\",\"last\"]}"
            },
            {
                "code": "child_lock",
                "type": "Boolean",
                "values": "{}"
            }
        ]
    },
    "success": true,
    "t": 1633517788541
}

Additional context I'm sure that my device can report such information, is it bug with wrong specification or what. It's also possible to set threshold for over voltage, under voltage, leakage current. I'm willing to implement this but can someone guide me to the right direction.

Which case is it?

CreatoX commented 2 years ago

Hi,

Same problem (I think) with my Wifi Smart Plug. Only the on/of function is discovered. But no powerusage details.

The information is available in the API: image

But not in the HA Integration: image

Hope this can be fixed easily

Zen3515 commented 2 years ago

Hi,

Same problem (I think) with my Wifi Smart Plug. Only the on/of function is discovered. But no powerusage details.

The information is available in the API: image

But not in the HA Integration: image

Hope this can be fixed easily

Would be nice to see your log too.

CreatoX commented 2 years ago

Hi, Same problem (I think) with my Wifi Smart Plug. Only the on/of function is discovered. But no powerusage details. The information is available in the API: image But not in the HA Integration: image Hope this can be fixed easily

Would be nice to see your log too.

Sorry for the late reply. I use the new Tuya integration and had to figure out how to debug this. I also think this debug is not worth anything. But here it is:

2021-10-20 19:47:10 DEBUG (MainThread) [homeassistant.components.tuya] init support type->['climate', 'fan', 'light', 'scene', 'switch'] 2021-10-20 19:47:10 DEBUG (MainThread) [homeassistant.components.tuya.light] light init 2021-10-20 19:47:10 DEBUG (MainThread) [homeassistant.components.tuya.light] light add-> [] 2021-10-20 19:47:10 DEBUG (MainThread) [homeassistant.components.tuya.switch] switch init 2021-10-20 19:47:10 DEBUG (MainThread) [homeassistant.components.tuya.switch] switch add-> ['device1', 'device2'] 2021-10-20 19:47:12 DEBUG (MainThread) [homeassistant.components.tuya.fan] fan init 2021-10-20 19:47:12 DEBUG (MainThread) [homeassistant.components.tuya.fan] fan add-> [] 2021-10-20 19:47:12 DEBUG (MainThread) [homeassistant.components.tuya.climate] climate init 2021-10-20 19:47:12 DEBUG (MainThread) [homeassistant.components.tuya.climate] climate add-> []

Both devices are Smart Plugs with power meter (I recently added another one so this one is not in the screenshot)