Browse Source

feat(frizzlife_lp365p_watermonitorandshutdoff): add entities and units

Salvagable changes from PR #4703 by @rwalker777:

- unit conversion based on device settings
- additional sensors for minimum flow rate
Jason Rumney 17 hours ago
parent
commit
0b335ffb42

+ 146 - 7
custom_components/tuya_local/devices/frizzlife_lp365p_watermonitorandshutdoff.yaml

@@ -19,10 +19,37 @@ entities:
       - id: 12
       - id: 12
         type: integer
         type: integer
         name: sensor
         name: sensor
-        unit: C
         class: measurement
         class: measurement
         mapping:
         mapping:
           - scale: 10
           - scale: 10
+      - id: 20
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: f
+            value: F
+          - value: C
+
+  - entity: sensor
+    class: pressure
+    category: diagnostic
+    dps:
+      - id: 15
+        type: integer
+        optional: true
+        name: sensor
+        class: measurement
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: psi
+            scale: 10
+          - value: bar
+            scale: 100
 
 
   # Protection Enabled Switch
   # Protection Enabled Switch
   - entity: switch
   - entity: switch
@@ -41,10 +68,16 @@ entities:
         optional: true
         optional: true
         name: sensor
         name: sensor
         class: total_increasing
         class: total_increasing
-        unit: L
         mapping:
         mapping:
           - scale: 10
           - scale: 10
-
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: gal
+          - value: L
   # Flow rate
   # Flow rate
   - entity: sensor
   - entity: sensor
     class: volume_flow_rate
     class: volume_flow_rate
@@ -55,8 +88,14 @@ entities:
         optional: true
         optional: true
         name: sensor
         name: sensor
         class: measurement
         class: measurement
-        unit: L/h
-
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: gal/h
+          - value: L/h
   # Current flow rate
   # Current flow rate
   - entity: sensor
   - entity: sensor
     class: volume_flow_rate
     class: volume_flow_rate
@@ -66,9 +105,16 @@ entities:
         type: integer
         type: integer
         name: sensor
         name: sensor
         class: measurement
         class: measurement
-        unit: L/h
         mapping:
         mapping:
           - scale: 1000
           - scale: 1000
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: gal/min
+          - value: L/h
   # Leak Warning
   # Leak Warning
   - entity: binary_sensor
   - entity: binary_sensor
     class: moisture
     class: moisture
@@ -224,10 +270,17 @@ entities:
           - dps_val: ADVANCED_SETTING
           - dps_val: ADVANCED_SETTING
             value: true
             value: true
           - value: false
           - value: false
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: gal
+          - value: L
       - id: 111
       - id: 111
         type: string
         type: string
         name: value
         name: value
-        unit: L
         range:
         range:
           min: 0
           min: 0
           max: 5000
           max: 5000
@@ -271,3 +324,89 @@ entities:
           - dps_val: 0
           - dps_val: 0
             value: 50
             value: 50
           - scale: 0.01
           - scale: 0.01
+  - entity: select
+    translation_key: temperature_unit
+    category: config
+    dps:
+      - id: 20
+        type: string
+        optional: true
+        name: option
+        mapping:
+          - dps_val: c
+            value: celsius
+          - dps_val: f
+            value: fahrenheit
+  - entity: select
+    name: Measurement units
+    icon: "mdi:ruler-square"
+    category: config
+    dps:
+      - id: 102
+        type: string
+        optional: true
+        name: option
+        mapping:
+          - dps_val: us_units
+            value: US
+          - dps_val: metric_unit
+            value: Metric
+
+  # Advanced: Allowed Flow Rate
+  - entity: switch
+    name: Require minimum flow
+    category: config
+    dps:
+      - id: 118
+        type: boolean
+        name: switch
+      - id: 109
+        type: string
+        name: available
+        mapping:
+          - dps_val: "ADVANCED_SETTING"
+            value: true
+          - value: false
+
+  - entity: number
+    name: Minimum flow rate
+    category: config
+    dps:
+      - id: 119
+        type: integer
+        name: value
+        range:
+          min: 0
+          max: 9
+        mapping:
+          - constraint: unit
+            conditions:
+              - dps_val: us_units
+                target_range:
+                  min: 0.01
+                  max: 0.1
+            target_range:
+              min: 2.5
+              max: 25
+      - id: 109
+        type: string
+        name: mode_system
+      - id: 118
+        type: boolean
+        name: available
+        mapping:
+          - dps_val: true
+            value: false
+            constraint: mode_system
+            conditions:
+              - dps_val: "ADVANCED_SETTING"
+                value: true
+          - value: false
+      - id: 102
+        type: string
+        optional: true
+        name: unit
+        mapping:
+          - dps_val: us_units
+            value: gal/min
+          - value: L/h