Răsfoiți Sursa

Smartplugs: standardise how calibration dps are represented.

Add calibration as attributes onto the sensors they apply to.  Make
them optional, as many plugs do not report these factory config
values, and their absence should not affect matching of configs to plugs.
Where a config does not have an energy sensor, do not bother including
the energy calibration (though many plugs report it consistently, only
rarely reporting energy).
Jason Rumney 3 ani în urmă
părinte
comite
f77ee034ed

+ 17 - 60
custom_components/tuya_local/devices/grid_connect_usb_double_power_point.yaml

@@ -1,9 +1,3 @@
-# With limitation on reiterating same type of entity there is not much left to do to achieve full functionality.
-# However, it might complement existing Tuya v2 cloud integration or even localtuya by providing:
-# -  power reading
-# - child lock
-# - master switch (not very usable)
-
 name: Grid Connnect power metered double outlet with USB
 primary_entity:
   entity: switch
@@ -11,47 +5,12 @@ primary_entity:
   name: Master
   class: outlet
   dps:
-    - id: 18
-      type: integer
-      name: current_a
-      readonly: true
-      mapping:
-        - scale: 1000
-    - id: 19
-      type: integer
-      name: current_power_w
-      readonly: true
-      mapping:
-        - scale: 10
-    - id: 20
-      type: integer
-      name: voltage_v
-      readonly: true
-      mapping:
-        - scale: 10
-    - id: 21
-      name: test_bit
-      type: integer
-      readonly: true
-    - id: 22
-      name: voltage_calibration
-      type: integer
-      readonly: true
-    - id: 23
-      name: current_calibration
-      type: integer
-      readonly: true
-    - id: 24
-      name: power_calibration
-      type: integer
-      readonly: true
-    - id: 25
-      name: energy_calibration
-      type: integer
-      readonly: true
     - id: 101
       name: switch
       type: boolean
+    - id: 21
+      name: test_bit
+      type: integer
 secondary_entities:
   - entity: lock
     name: Child lock
@@ -72,13 +31,6 @@ secondary_entities:
       - id: 1
         name: switch
         type: boolean
-      - id: 9
-        name: countdown
-        type: integer
-      - id: 101
-        name: master
-        type: boolean
-        hidden: true
   - entity: switch
     class: outlet
     name: Outlet 2
@@ -86,13 +38,6 @@ secondary_entities:
       - id: 2
         name: switch
         type: boolean
-      - id: 10
-        name: countdown
-        type: integer
-      - id: 101
-        name: master
-        type: boolean
-        hidden: true
   - entity: sensor
     category: diagnostic
     name: Energy
@@ -101,6 +46,9 @@ secondary_entities:
         name: sensor
         type: integer
         unit: Wh
+      - id: 25
+        name: calibration
+        type: integer
   - entity: sensor
     class: current
     category: diagnostic
@@ -111,6 +59,9 @@ secondary_entities:
         type: integer
         class: measurement
         unit: mA
+      - id: 23
+        name: calibration
+        type: integer
   - entity: sensor
     class: power
     category: diagnostic
@@ -123,6 +74,9 @@ secondary_entities:
         unit: W
         mapping:
           - scale: 10
+      - id: 24
+        name: calibration
+        type: integer
   - entity: sensor
     class: voltage
     category: diagnostic
@@ -135,6 +89,9 @@ secondary_entities:
         unit: V
         mapping:
           - scale: 10
+      - id: 22
+        name: calibration
+        type: integer
   - entity: select
     category: config
     name: Initial state
@@ -148,8 +105,8 @@ secondary_entities:
             value: "On"
           - dps_val: "off"
             value: "Off"
-          - dps_val: "memory"
-            value: "Last State"
+          - dps_val: memory
+            value: Last State
   - entity: number
     name: Timer 1
     icon: "mdi:timer"

+ 12 - 16
custom_components/tuya_local/devices/smartplugv2.yaml

@@ -32,22 +32,6 @@ primary_entity:
       type: bitfield
       name: factory_test
       optional: true
-    - id: 22
-      type: integer
-      name: voltage_calibration
-      optional: true
-    - id: 23
-      type: integer
-      name: current_calibration
-      optional: true
-    - id: 24
-      type: integer
-      name: power_calibration
-      optional: true
-    - id: 25
-      type: integer
-      name: energy_calibration
-      optional: true
     - id: 26
       type: integer
       name: fault_code
@@ -65,6 +49,10 @@ secondary_entities:
         unit: V
         mapping:
           - scale: 10
+      - id: 22
+        type: integer
+        name: calibration
+        optional: true
   - entity: sensor
     category: diagnostic
     class: current
@@ -75,6 +63,10 @@ secondary_entities:
         type: integer
         class: measurement
         unit: mA
+      - id: 23
+        type: integer
+        name: calibration
+        optional: true
   - entity: sensor
     category: diagnostic
     class: power
@@ -87,6 +79,10 @@ secondary_entities:
         unit: W
         mapping:
           - scale: 10
+      - id: 24
+        type: integer
+        name: calibration
+        optional: true
   - entity: number
     category: config
     name: Timer

+ 12 - 12
custom_components/tuya_local/devices/smartplugv2_energyv2.yaml

@@ -9,18 +9,6 @@ primary_entity:
     - id: 21
       type: integer
       name: test_bit
-    - id: 22
-      type: integer
-      name: voltage_calibration
-    - id: 23
-      type: integer
-      name: current_calibration
-    - id: 24
-      type: integer
-      name: power_calibration
-    - id: 25
-      type: integer
-      name: energy_calibration
     - id: 26
       type: bitfield
       name: fault_code
@@ -54,6 +42,9 @@ secondary_entities:
         name: sensor
         type: integer
         unit: Wh
+      - id: 25
+        type: integer
+        name: calibration
   - entity: sensor
     category: diagnostic
     class: current
@@ -64,6 +55,9 @@ secondary_entities:
         type: integer
         class: measurement
         unit: mA
+      - id: 23
+        type: integer
+        name: calibration
   - entity: sensor
     category: diagnostic
     class: power
@@ -76,6 +70,9 @@ secondary_entities:
         unit: W
         mapping:
           - scale: 10
+      - id: 24
+        type: integer
+        name: calibration
   - entity: sensor
     category: diagnostic
     class: voltage
@@ -88,6 +85,9 @@ secondary_entities:
         unit: V
         mapping:
           - scale: 10
+      - id: 22
+        type: integer
+        name: calibration
   - entity: binary_sensor
     class: problem
     category: diagnostic

+ 12 - 12
custom_components/tuya_local/devices/smartplugv3.yaml

@@ -9,18 +9,6 @@ primary_entity:
     - id: 21
       type: integer
       name: test_bit
-    - id: 22
-      type: integer
-      name: voltage_calibration
-    - id: 23
-      type: integer
-      name: current_calibration
-    - id: 24
-      type: integer
-      name: power_calibration
-    - id: 25
-      type: integer
-      name: energy_calibration
     - id: 26
       type: bitfield
       name: fault_code
@@ -56,6 +44,10 @@ secondary_entities:
         type: integer
         class: measurement
         unit: mA
+      - id: 23
+        type: integer
+        name: calibration
+        optional: true
   - entity: sensor
     category: diagnostic
     class: power
@@ -68,6 +60,10 @@ secondary_entities:
         unit: W
         mapping:
           - scale: 10
+      - id: 24
+        type: integer
+        name: calibration
+        optional: true
   - entity: sensor
     category: diagnostic
     class: voltage
@@ -80,6 +76,10 @@ secondary_entities:
         unit: V
         mapping:
           - scale: 10
+      - id: 22
+        type: integer
+        name: calibration
+        optional: true
   - entity: binary_sensor
     class: problem
     category: diagnostic