make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.28k stars 505 forks source link

Request support for Gosund P1 #389

Closed spitfire closed 1 year ago

spitfire commented 1 year ago

Log Message

Couldn't find it in the logs, but Here are the DPs I had configured in localtuya:

Information about DPS mappings

{
  "result": {
    "category": "pc",
    "functions": [
      {
        "code": "switch_1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_3",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_usb1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_2",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_3",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_usb1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "add_ele",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":50000,\"scale\":3,\"step\":100}"
      }
    ],
    "status": [
      {
        "code": "switch_1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_3",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_usb1",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_2",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_3",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "countdown_usb1",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "add_ele",
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":0,\"max\":50000,\"scale\":3,\"step\":100}"
      },
      {
        "code": "cur_current",
        "type": "Integer",
        "values": "{\"unit\":\"mA\",\"min\":0,\"max\":30000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "cur_power",
        "type": "Integer",
        "values": "{\"unit\":\"W\",\"min\":0,\"max\":50000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "cur_voltage",
        "type": "Integer",
        "values": "{\"unit\":\"V\",\"min\":0,\"max\":5000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "fault",
        "type": "Bitmap",
        "values": "{\"label\":[\"ov_cr\"],\"maxlen\":1}"
      },
      {
        "code": "over_load",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "usb_overload_alarm",
        "type": "Boolean",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1676135813830,
  "tid": "e13fdf3baa2f11ed9de742b33a3cd862"
}

Product ID

{
  "result": {
    "active_time": 1670599535,
    "category": "pc",
    "category_name": "Power Strip",
    "create_time": 1670599535,
    "gateway_id": "",
    "icon": "smart/icon/ay1517974017716dABhC/a6f48c46f790b927c24e0b07eadc7522.png",
    "id": "537472214855195b4125",
    "ip": "redacted",
    "lat": "redacted",
    "local_key": "redacted",
    "lon": "redacted",
    "model": "Po01-T-AR(P1)",
    "name": "Smart Power Strip",
    "online": true,
    "owner_id": "71836261",
    "product_id": "tsbguim4trl6fa7g",
    "product_name": "Smart Power Strip",
    "sub": false,
    "time_zone": "+01:00",
    "update_time": 1670599539,
    "uuid": "537472214855195b4125"
  },
  "success": true,
  "t": 1676135932235,
  "tid": "27d5d997aa3011eda120e66c285aff6b"
}

Information about how the device functions

A Smart power strip with 3 Sockets and 3 usb ports, controllable separately (Socket 1, 2, 3, USB) and power monitoring (for all sockets). https://gosund-polska.pl/inteligentna-listwa-zasilajaca-p1/ Basic functionality (3 plugs) is handled by Triple Switch device template.

make-all commented 1 year ago

The actual log message would be useful, as there appear to be many more dps available, such as individual timers and several types of fault detection.

spitfire commented 1 year ago

The actual log message would be useful, as there appear to be many more dps available, such as individual timers and several types of fault detection.

How do I get required information for you? What should I be looking for specifically?

make-all commented 1 year ago

I am going to make the release now, which will give you basic support to add the device.

After that, you will be able to download diagnostics from Settings / Devices & Services /Tuya Local /"1 device". This will provide a snapshot of the raw dps data that I need.

Since it won't be a perfect match yet, you will probably also get a Warning message in the HA log still, which will also contain the raw dps data snapshot at the time of adding the device.

spitfire commented 1 year ago

Zrzut ekranu 2023-02-13 o 14 19 49 Power and Voltage seem to need a decimal point moved (220W and 66W is what is should be).

In the logs I've found this, seems to be trying to match this powerstrip to something else:

Logger: custom_components.tuya_local.config_flow
Source: custom_components/tuya_local/config_flow.py:44
Integration: Tuya Local ([documentation](https://github.com/make-all/tuya-local), [issues](https://github.com/make-all/tuya-local/issues))
First occurred: 14:17:36 (2 occurrences)
Last logged: 14:17:36

Device matches qnect_usb_powerstrip with quality of 62%. DPS: {'updated_at': 1676294255.3417945, '1': False, '2': True, '3': False, '7': False, '9': 0, '10': 0, '11': 0, '15': 0, '18': 0, '19': 0, '20': 2131, '101': False, '102': False}
Report this to https://github.com/make-all/tuya-local/issues/
spitfire commented 1 year ago

For whatever reason it keeps changing how the switch looks between what you can see on screenshots below. Zrzut ekranu 2023-02-13 o 14 24 48 Zrzut ekranu 2023-02-13 o 14 24 40

make-all commented 1 year ago

I've never seen that last one, but UI issues are often solved by a Shift-Refresh (I forget how to do this on mobile though)

The log message is because the config is incomplete, and the 4 timers probably match the qnect config, vs 3 power/voltage/current sensors in this config, so the qnect is actually a closer match. Once this one has the timers and any other dps added, it will be the best match.

spitfire commented 1 year ago

Do you need any more information for this?

make-all commented 1 year ago

No, the changes to add timers and overload detection are done, now the config should match 100%, so no log message will be printed.

spitfire commented 1 year ago

copied latest gosund_usb_triple_powerstrip.yaml tpo where it belongs, and everything seems to be working, thanks!