make-all / tuya-local

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

Request support for Bonaire Electric Heater HPC5200020 #2078

Closed bjeanes closed 2 months ago

bjeanes commented 3 months ago

Amazon link for this product: https://www.amazon.com.au/gp/product/B0BY1V1XHR

Log Message

I'm probably overlooking something obvious, but even with "Enable debug logging" set for this integration (and restarting Home Assistant afterwards), I'm not seeing much detail in the logs. The closest is:

Logger: custom_components.tuya_local.config_flow
Source: custom_components/tuya_local/config_flow.py:483
integration: Tuya Local ([documentation](https://github.com/make-all/tuya-local), [issues](https://github.com/make-all/tuya-local/issues))
First occurred: 6:05:44 PM (1 occurrences)
Last logged: 6:05:44 PM

Device matches arlec_panel_heater_v2 with quality of 75%. DPS: {"updated_at": 1720253133.2385817, "1": true, "2": 20, "3": 21, "4": "high", "7": false, "10": true, "12": 0, "19": "cancel"}

However, I hope the abundance of information provided in the rest of this issue will be sufficient.

Information about DPS mappings

Full output ```json { "result": { "model": "{\"modelId\":\"000004dh7k\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"Power\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_power2\",\"attribute\":\"1\"},\"name\":\"开关\",\"typeSpec\":{\"type\":\"bool\"}},{\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"TempSet\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_temp\",\"attribute\":\"4\"},\"name\":\"目标温度\",\"typeSpec\":{\"type\":\"value\",\"max\":50,\"min\":5,\"scale\":0,\"step\":1,\"unit\":\"℃\"}},{\"abilityId\":3,\"accessMode\":\"ro\",\"code\":\"TempCurrent\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_sun\"},\"name\":\"当前温度\",\"typeSpec\":{\"type\":\"value\",\"max\":50,\"min\":0,\"scale\":0,\"step\":1,\"unit\":\"℃\"}},{\"abilityId\":4,\"accessMode\":\"rw\",\"code\":\"Mode\",\"description\":\"高档、低档、防霜冻\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"4\"},\"name\":\"模式\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"low\",\"high\",\"af\"]}},{\"abilityId\":7,\"accessMode\":\"rw\",\"code\":\"child_lock\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_shake\",\"attribute\":\"128\"},\"name\":\"童锁\",\"typeSpec\":{\"type\":\"bool\"}},{\"abilityId\":10,\"accessMode\":\"rw\",\"code\":\"light\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_time2\",\"attribute\":\"128\"},\"name\":\"灯光\",\"typeSpec\":{\"type\":\"bool\"}},{\"abilityId\":12,\"accessMode\":\"ro\",\"code\":\"Fault\",\"description\":\"例如,温度传感器故障,高温故障,电机故障等\",\"extensions\":{\"iconName\":\"icon-dp_warming\",\"scope\":\"fault\"},\"name\":\"故障告警\",\"typeSpec\":{\"type\":\"bitmap\",\"label\":[\"1\",\"2\",\"3\"],\"maxlen\":3}},{\"abilityId\":19,\"accessMode\":\"rw\",\"code\":\"countdown_set\",\"description\":\"需和 倒计时剩余时间 配合使用\",\"extensions\":{\"attribute\":\"128\"},\"name\":\"倒计时\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"cancel\",\"1h\",\"2h\",\"3h\",\"4h\",\"5h\",\"6h\",\"7h\",\"8h\",\"9h\",\"10h\",\"11h\",\"12h\",\"13h\",\"14h\",\"15h\",\"16h\",\"17h\",\"18h\",\"19h\",\"20h\",\"21h\",\"22h\",\"23h\",\"24h\"]}}]}]}" }, "success": true, "t": 1720252132761, "tid": "3074a65a3b6c11ef9e3b1acebe103cd3" } ```
{
  "modelId": "000004dh7k",
  "services": [
    {
      "actions": [],
      "code": "",
      "description": "",
      "events": [],
      "name": "默认服务",
      "properties": [
        {
          "abilityId": 1,
          "accessMode": "rw",
          "code": "Power",
          "description": "",
          "extensions": {
            "iconName": "icon-dp_power2",
            "attribute": "1"
          },
          "name": "开关",
          "typeSpec": {
            "type": "bool"
          }
        },
        {
          "abilityId": 2,
          "accessMode": "rw",
          "code": "TempSet",
          "description": "",
          "extensions": {
            "iconName": "icon-dp_temp",
            "attribute": "4"
          },
          "name": "目标温度",
          "typeSpec": {
            "type": "value",
            "max": 50,
            "min": 5,
            "scale": 0,
            "step": 1,
            "unit": "℃"
          }
        },
        {
          "abilityId": 3,
          "accessMode": "ro",
          "code": "TempCurrent",
          "description": "",
          "extensions": {
            "iconName": "icon-dp_sun"
          },
          "name": "当前温度",
          "typeSpec": {
            "type": "value",
            "max": 50,
            "min": 0,
            "scale": 0,
            "step": 1,
            "unit": "℃"
          }
        },
        {
          "abilityId": 4,
          "accessMode": "rw",
          "code": "Mode",
          "description": "高档、低档、防霜冻",
          "extensions": {
            "iconName": "icon-dp_mode",
            "attribute": "4"
          },
          "name": "模式",
          "typeSpec": {
            "type": "enum",
            "range": [
              "low",
              "high",
              "af"
            ]
          }
        },
        {
          "abilityId": 7,
          "accessMode": "rw",
          "code": "child_lock",
          "description": "",
          "extensions": {
            "iconName": "icon-dp_shake",
            "attribute": "128"
          },
          "name": "童锁",
          "typeSpec": {
            "type": "bool"
          }
        },
        {
          "abilityId": 10,
          "accessMode": "rw",
          "code": "light",
          "description": "",
          "extensions": {
            "iconName": "icon-dp_time2",
            "attribute": "128"
          },
          "name": "灯光",
          "typeSpec": {
            "type": "bool"
          }
        },
        {
          "abilityId": 12,
          "accessMode": "ro",
          "code": "Fault",
          "description": "例如,温度传感器故障,高温故障,电机故障等",
          "extensions": {
            "iconName": "icon-dp_warming",
            "scope": "fault"
          },
          "name": "故障告警",
          "typeSpec": {
            "type": "bitmap",
            "label": [
              "1",
              "2",
              "3"
            ],
            "maxlen": 3
          }
        },
        {
          "abilityId": 19,
          "accessMode": "rw",
          "code": "countdown_set",
          "description": "需和 倒计时剩余时间 配合使用",
          "extensions": {
            "attribute": "128"
          },
          "name": "倒计时",
          "typeSpec": {
            "type": "enum",
            "range": [
              "cancel",
              "1h",
              "2h",
              "3h",
              "4h",
              "5h",
              "6h",
              "7h",
              "8h",
              "9h",
              "10h",
              "11h",
              "12h",
              "13h",
              "14h",
              "15h",
              "16h",
              "17h",
              "18h",
              "19h",
              "20h",
              "21h",
              "22h",
              "23h",
              "24h"
            ]
          }
        }
      ]
    }
  ]
}

Product ID

xto0qf9xem5bi7sj

Tuya IoT Platform gives this device name GPH-CPH-XA-NEW in the UI

Information about how the device functions

When adding device it proposes a few options to map, but defaults to arlec_panel_heater_v2 (with log Device matches arlec_panel_heater_v2 with quality of 75%. DPS: {"updated_at": 1720251219.5391908, "1": true, "2": 21, "3": 21, "4": "high", "7": false, "10": true, "12": 0, "19": "cancel"}):

Screenshot 2024-07-06 at 5 33 54 PM

Interestingly arlec_panel_heater (non v2) actually looks closer, though it is not listed as an option to select:

Screenshot 2024-07-06 at 5 56 32 PM

I looked through the device definitions and found andersson_gsh_heater (which is given as an option) is actually an ideal fit for basic controls. I re-added the device using andersson_gsh_heater and all the core functionality works 100%, though is missing the child lock and timer definitions.

bjeanes commented 3 months ago

I created my own mapping, put it in custom_components/tuya_local/devices/bonaire_heater.yaml and got everything except the light working:

name: Bonaire Electric Heater
products:
  - id: xto0qf9xem5bi7sj
    name: Bonaire Electric Heater HPC5200020
primary_entity:
  entity: climate
  translation_only_key: heater
  dps:
    - id: 1
      name: hvac_mode
      type: boolean
      mapping:
        - dps_val: true
          value: "heat"
        - dps_val: false
          value: "off"
    - id: 2
      name: temperature
      type: integer
      unit: C
      range:
        min: 5
        max: 35
    - id: 3
      name: current_temperature
      type: integer
    - id: 4
      name: preset_mode
      type: string
      mapping:
        - dps_val: low
          value: eco
        - dps_val: high
          value: boost
        - dps_val: af
          value: away
    - id: 12
      name: error
      type: bitfield
      mapping:
        - dps_val: 0
          value: "OK"
secondary_entities:
  - entity: lock
    translation_key: child_lock
    category: config
    dps:
      - id: 7
        type: boolean
        name: lock
  - entity: light
    translation_key: backlight
    dps:
      - id: 10
        type: boolean
        name: switch
  - entity: number
    translation_key: timer
    category: config
    dps:
      - id: 19
        type: string
        name: value
        unit: hour
        optional: true
        range:
          min: 0
          max: 24
        mapping:
          - dps_val: "cancel"
            value: 0
          - dps_val: "1h"
            value: 1
          - dps_val: "2h"
            value: 2
          - dps_val: "3h"
            value: 3
          - dps_val: "4h"
            value: 4
          - dps_val: "5h"
            value: 5
          - dps_val: "6h"
            value: 6
          - dps_val: "7h"
            value: 7
          - dps_val: "8h"
            value: 8
          - dps_val: "9h"
            value: 9
          - dps_val: "10h"
            value: 10
          - dps_val: "11h"
            value: 11
          - dps_val: "12h"
            value: 12
          - dps_val: "13h"
            value: 13
          - dps_val: "14h"
            value: 14
          - dps_val: "15h"
            value: 15
          - dps_val: "16h"
            value: 16
          - dps_val: "17h"
            value: 17
          - dps_val: "18h"
            value: 18
          - dps_val: "19h"
            value: 19
          - dps_val: "20h"
            value: 20
          - dps_val: "21h"
            value: 21
          - dps_val: "22h"
            value: 22
          - dps_val: "23h"
            value: 23
          - dps_val: "24h"
            value: 24
Edit: I figured out the light, so this is no longer relevant **Edit**: I needed to change `name: light` to `name: switch` (I initially thought this mapped to the DP name but looked at some other examples). I also had to set the `translation_key: backlight` as `translation_key: light` generically is missing. Any advice on how to get the light working? It shows up as an entity but get `Failed to call service light/turn_off. unknown error` when toggling it. The following log line shows up as a result: ``` Logger: homeassistant.components.light Source: components/light/__init__.py:1164 integration: Light ([documentation](https://www.home-assistant.io/integrations/light), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+light%22)) First occurred: 6:19:10 PM (1 occurrences) Last logged: 6:19:10 PM None () sets invalid supported color modes set(), this will stop working in Home Assistant Core 2025.3, please create a bug report at https://github.com/make-all/tuya-local/issues ````