فهرست منبع

Add support for Petrust pet fountain

Issue #1173

- valve: add support for mapped integer values to define a variable valve.
Jason Rumney 1 سال پیش
والد
کامیت
536cb1c36b

+ 1 - 0
ACKNOWLEDGEMENTS.md

@@ -672,3 +672,4 @@ Further device support has been made with the assistance of users. Please consid
 - [guffy1234](https://github.com/guffy1234) for contributing support for Atorch AT4PW energy meter.
 - [larronni](https://github.com/larronni) for contributing support for Calex aroma diffuser.
 - [JennyIglesias](https://github.com/JennyIglesias) for assisting with support for Tongou TO-Q-SYS-WT circuit breaker
+- [pot-noble](https://github.com/pot-noble) for contributing support for Petrust TK-WF002 pet fountain

+ 2 - 1
DEVICES.md

@@ -719,7 +719,8 @@ port and password.
 - Nedis pet feeder
 - Petlibro PLAF103 pet feeder
 - Petlibro PLAF203 pet feeder with camera
-- Petoneer Fresco Hydrate Ultra pet fountain/
+- Petoneer Fresco Hydrate Ultra pet fountain
+- Petrust TK-WF002 pet fountain
 - PNI water feeder
 - Rojeco PTM-001 pet feeder (two versions)
 - Sobralik pet fountain

+ 177 - 0
custom_components/tuya_local/devices/petrust_tkwf002_petfountain.yaml

@@ -0,0 +1,177 @@
+name: Petrust Smart Fountain
+products:
+  - id: 5jdws4vgfzhkq7vs
+    name: Petrust TK-WF002
+primary_entity:
+  entity: switch
+  icon: "mdi:power"
+  dps:
+    - id: 1
+      type: boolean
+      name: switch
+secondary_entities:
+  - entity: select
+    name: Mode
+    class: enum
+    icon: "mdi:auto-mode"
+    dps:
+      - id: 2
+        type: string
+        name: option
+        mapping:
+          - dps_val: "normal"
+            value: "Normal"
+          - dps_val: "smart"
+            value: "Smart"
+  - entity: valve
+    class: water
+    dps:
+      - id: 11
+        type: string
+        name: valve
+        mapping:
+          - dps_val: "close"
+            value: 0
+          - dps_val: "low"
+            value: 25
+          - dps_val: "middle"
+            value: 50
+          - dps_val: "high"
+            value: 100
+  - entity: light
+    translation_key: indicator
+    category: config
+    dps:
+      - id: 12
+        type: integer
+        name: brightness
+        range:
+          min: 0
+          max: 4
+  - entity: number
+    name: Filter lifetime
+    icon: "mdi:air-filter"
+    category: config
+    dps:
+      - id: 7
+        type: integer
+        name: value
+        range:
+          min: 0
+          max: 30
+  - entity: sensor
+    name: Replace filter in
+    icon: "mdi:air-filter"
+    class: duration
+    category: diagnostic
+    dps:
+      - id: 3
+        type: integer
+        name: sensor
+        unit: d
+  - entity: button
+    name: Replace filter
+    icon: "mdi:air-filter"
+    category: config
+    dps:
+      - id: 5
+        type: boolean
+        name: button
+  - entity: number
+    name: Clean interval
+    icon: "mdi:pump"
+    category: config
+    dps:
+      - id: 8
+        type: integer
+        name: value
+        range:
+          min: 0
+          max: 20
+  - entity: sensor
+    name: Clean in
+    icon: "mdi:pump"
+    class: duration
+    category: diagnostic
+    dps:
+      - id: 4
+        type: integer
+        name: sensor
+        unit: d
+  - entity: button
+    name: Pump cleaned
+    icon: "mdi:pump"
+    category: config
+    dps:
+      - id: 6
+        type: boolean
+        name: button
+  - entity: sensor
+    name: Water level
+    class: enum
+    category: diagnostic
+    dps:
+      - id: 9
+        name: sensor
+        type: string
+        mapping:
+          - dps_val: "low"
+            icon: "mdi:cup-outline"
+            value: "Low"
+          - dps_val: "middle"
+            icon: "mdi:cup-water"
+            value: "Middle"
+          - dps_val: "high"
+            icon: "mdi:cup"
+            value: "High"
+  - entity: sensor
+    name: Water age
+    class: duration
+    icon: "mdi:water-opacity"
+    category: diagnostic
+    dps:
+      - id: 24
+        type: integer
+        name: sensor
+        unit: d
+  - entity: button
+    name: Change water
+    icon: "mdi:water-sync"
+    category: config
+    dps:
+      - id: 25
+        type: boolean
+        name: button
+  - entity: switch
+    translation_key: uv_sterilization
+    category: config
+    dps:
+      - id: 14
+        type: boolean
+        name: switch
+  - entity: number
+    name: UV runtime
+    icon: "mdi:timer-outline"
+    category: config
+    dps:
+      - id: 15
+        type: integer
+        name: value
+        unit: min
+        range:
+          min: 0
+          max: 90
+  - entity: binary_sensor
+    class: problem
+    category: diagnostic
+    dps:
+      - id: 23
+        type: bitfield
+        name: sensor
+        mapping:
+          - dps_val: 0
+            value: false
+          - value: true
+      - id: 23
+        type: bitfield
+        name: fault_code

+ 8 - 2
custom_components/tuya_local/valve.py

@@ -45,7 +45,10 @@ class TuyaLocalValve(TuyaLocalEntity, ValveEntity):
         if not self._valve_dp.readonly:
             self._attr_supported_features |= ValveEntityFeature.OPEN
             self._attr_supported_features |= ValveEntityFeature.CLOSE
-            if self._valve_dp.type is int:
+            if self._valve_dp.type is int or (
+                self._valve_dp.values(device)
+                and self._valve_dp.values(device)[0] is int
+            ):
                 self._attr_supported_features |= ValveEntityFeature.SET_POSITION
 
     @property
@@ -66,7 +69,10 @@ class TuyaLocalValve(TuyaLocalEntity, ValveEntity):
     @property
     def reports_position(self):
         """If the valve is an integer, it reports position."""
-        return self._valve_dp.type is int
+        return self._valve_dp.type is int or (
+            self._valve_dp.values(device)
+            and self._valve_dp.values(device)[0] is int
+        )
 
     @property
     def current_position(self):