Procházet zdrojové kódy

Add support for Hiniso dehumidifier (#5025)

* Add support for Hiniso dehumidifier

Adds a new dehumidifier device definition for tuya-local with updated DPS mappings based on live Tuya cloud data.

Key changes:
- Updated mode mapping to match actual device states (dehumidify, drying, sleep)
- Added support for fan speed (low / mid / high)
- Added UV and ionizer switches based on verified DPS points
- Added child lock support
- Fixed tank_full (remind, DP 25) handling by supporting both raw and quoted enum values ("on"/"off")
- Improved fault handling with bitmap-based sensor description mapping

This configuration is based on real device telemetry from Tuya cloud API responses and tested state transitions.

Notes:
- DPS 25 (remind) changes between "off" and "on" when tank state changes
- Enum values may be received inconsistently as raw or quoted strings depending on Tuya firmware
- Mapping is made defensive to ensure correct binary_sensor state evaluation in tuya-local

Tested behavior:
- All states and commands

* Code changes after comments from owner

- Boolean options removed from tank full sensor (is string only)
- fault_code included to bitfield with attribute with the raw value.
- using fan entity with speed mapped to percentages
- uv sterilization used with translation_key

* Fix formatting in hiniso_dehumidifier.yaml

* fix(hiniso_dehumidifier): replace name with translation key

- reduce excessive vertical whitespace, it makes it more work to follow the config
- use "dehumidifier" translation key for fan
- remove icon override from child lock, as translation already defines a suitable icon

PR #5025

---------

Co-authored-by: Jason Rumney <make-all@users.noreply.github.com>
DomJoke před 3 dny
rodič
revize
c00800c706

+ 183 - 0
custom_components/tuya_local/devices/hiniso_dehumidifier.yaml

@@ -0,0 +1,183 @@
+name: Dehumidifier
+
+entities:
+  - entity: humidifier
+    class: dehumidifier
+    translation_only_key: extended
+    dps:
+      - id: 1
+        name: switch
+        type: boolean
+      - id: 2
+        name: humidity
+        type: integer
+        range:
+          min: 30
+          max: 90
+        mapping:
+          - step: 5
+      - id: 5
+        name: mode
+        type: string
+        mapping:
+          - dps_val: dehumidify
+            value: auto
+          - dps_val: drying
+            value: laundry
+          - dps_val: sleep
+            value: sleep
+      - id: 6
+        name: current_humidity
+        type: integer
+
+  # WATER TANK FULL
+  - entity: binary_sensor
+    translation_key: tank_full
+    category: diagnostic
+    dps:
+      - id: 25
+        type: string
+        name: sensor
+        mapping:
+          - dps_val: "on"
+            value: true
+          - dps_val: "off"
+            value: false
+
+  # DEVICE PROBLEM
+  - entity: binary_sensor
+    class: problem
+    category: diagnostic
+    dps:
+      - id: 19
+        type: bitfield
+        optional: true
+        name: sensor
+        mapping:
+          - dps_val: 0
+            value: false
+          - dps_val: null
+            value: false
+          - value: true
+      - id: 19
+        type: bitfield
+        optional: true
+        name: fault_code
+      - id: 19
+        type: bitfield
+        optional: true
+        name: description
+        mapping:
+          - dps_val: 0
+            value: OK
+          - dps_val: 1
+            value: Communication fault
+          - dps_val: 2
+            value: Indoor sensor fault
+          - dps_val: 4
+            value: Evaporator sensor fault
+
+  # ANION
+  - entity: switch
+    translation_key: ionizer
+    category: config
+    dps:
+      - id: 10
+        type: boolean
+        name: switch
+
+  # UV
+  - entity: switch
+    translation_key: uv_sterilization
+    category: config
+    dps:
+      - id: 13
+        type: boolean
+        name: switch
+
+  # CHILD LOCK
+  - entity: lock
+    translation_key: child_lock
+    category: config
+    dps:
+      - id: 16
+        type: boolean
+        name: lock
+
+  # FAN SPEED
+  - entity: fan
+    translation_key: dehumidifier
+    dps:
+      - id: 1
+        name: switch
+        type: boolean
+      - id: 4
+        name: speed
+        type: string
+        mapping:
+          - dps_val: low
+            value: 33
+          - dps_val: mid
+            value: 66
+          - dps_val: high
+            value: 100
+
+  # TIMER
+  - entity: select
+    translation_key: timer
+    category: config
+    dps:
+      - id: 17
+        type: string
+        name: option
+        mapping:
+          - dps_val: cancel
+            value: cancel
+          - dps_val: 1h
+            value: 1h
+          - dps_val: 2h
+            value: 2h
+          - dps_val: 3h
+            value: 3h
+          - dps_val: 4h
+            value: 4h
+          - dps_val: 5h
+            value: 5h
+          - dps_val: 6h
+            value: 6h
+          - dps_val: 7h
+            value: 7h
+          - dps_val: 8h
+            value: 8h
+          - dps_val: 9h
+            value: 9h
+          - dps_val: 10h
+            value: 10h
+          - dps_val: 11h
+            value: 11h
+          - dps_val: 12h
+            value: 12h
+          - dps_val: 13h
+            value: 13h
+          - dps_val: 14h
+            value: 14h
+          - dps_val: 15h
+            value: 15h
+          - dps_val: 16h
+            value: 16h
+          - dps_val: 17h
+            value: 17h
+          - dps_val: 18h
+            value: 18h
+          - dps_val: 19h
+            value: 19h
+          - dps_val: 20h
+            value: 20h
+          - dps_val: 21h
+            value: 21h
+          - dps_val: 22h
+            value: 22h
+          - dps_val: 23h
+            value: 23h
+          - dps_val: 24h
+            value: 24h