Răsfoiți Sursa

Smartplugs (multiple): do not mark as energy or total_increasing

Also applies to a couple of heatpumps and thermostats that had power
consumption readings.

Due to differences in the way different Tuya devices handle energy
dps (add_ele in particular), it is not possible to get consistent
behavior without warnings in the log.  Even in devices that seem to
work, the energy reported by HA is off by 5 - 10% compared to the Tuya
reports, so it is probably better to use an Integration helper on the
power sensor rather than using the energy sensor directly.

Left dedicated power meters alone, as those seem to report a running total
as expected.

Issue #392
Jason Rumney 3 ani în urmă
părinte
comite
fc276eed3c

+ 0 - 2
custom_components/tuya_local/devices/aubess_1gang_switch.yaml

@@ -50,12 +50,10 @@ secondary_entities:
   - entity: sensor
     name: Energy
     category: diagnostic
-    class: energy
     dps:
       - id: 20
         name: sensor
         type: integer
-        class: total_increasing
         unit: Wh
   - entity: sensor
     name: Current

+ 0 - 2
custom_components/tuya_local/devices/grid_connect_usb_double_power_point.yaml

@@ -94,14 +94,12 @@ secondary_entities:
         type: boolean
         hidden: true
   - entity: sensor
-    class: energy
     category: diagnostic
     name: Energy
     dps:
       - id: 17
         name: sensor
         type: integer
-        class: total_increasing
         unit: Wh
   - entity: sensor
     class: current

+ 0 - 3
custom_components/tuya_local/devices/jiahong_et72w_thermostat.yaml

@@ -161,14 +161,11 @@ secondary_entities:
             value: F
   - entity: sensor
     name: Energy
-    class: energy
-    readonly: true
     dps:
       - id: 117
         type: integer
         name: sensor
         unit: kWh
-        class: total_increasing
         mapping:
           - scale: 10
       - id: 116

+ 0 - 6
custom_components/tuya_local/devices/pc321ty_energy_meter.yaml

@@ -60,14 +60,12 @@ secondary_entities:
           - scale: 100
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy A
     dps:
       - id: 106
         name: sensor
         type: integer
         unit: kWh
-        class: total_increasing
         mapping:
           - scale: 100
   - entity: sensor
@@ -117,14 +115,12 @@ secondary_entities:
           - scale: 100
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy B
     dps:
       - id: 116
         name: sensor
         type: integer
         unit: kWh
-        class: total_increasing
         mapping:
           - scale: 100
   - entity: sensor
@@ -174,14 +170,12 @@ secondary_entities:
           - scale: 100
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy C
     dps:
       - id: 126
         name: sensor
         type: integer
         unit: kWh
-        class: total_increasing
         mapping:
           - scale: 100
   - entity: sensor

+ 0 - 2
custom_components/tuya_local/devices/sendo_airconditioner_c.yaml

@@ -80,13 +80,11 @@ secondary_entities:
   - entity: sensor
     name: Power consumption
     category: diagnostic
-    class: energy
     dps:
       - id: 28
         name: sensor
         type: integer
         unit: kWh
-        class: total_increasing
   - entity: switch
     name: Sleep
     category: config

+ 0 - 2
custom_components/tuya_local/devices/smartplugv2_energy.yaml

@@ -48,14 +48,12 @@ secondary_entities:
             step: 60
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy
     dps:
       - id: 17
         name: sensor
         type: integer
         unit: Wh
-        class: total_increasing
   - entity: sensor
     category: diagnostic
     class: current

+ 0 - 2
custom_components/tuya_local/devices/smartplugv2_energyv2.yaml

@@ -48,14 +48,12 @@ secondary_entities:
             step: 60
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy
     dps:
       - id: 17
         name: sensor
         type: integer
         unit: Wh
-        class: total_increasing
   - entity: sensor
     category: diagnostic
     class: current

+ 0 - 2
custom_components/tuya_local/devices/smartplugv2_energyv3.yaml

@@ -44,14 +44,12 @@ secondary_entities:
             step: 60
   - entity: sensor
     category: diagnostic
-    class: energy
     name: Energy
     dps:
       - id: 17
         name: sensor
         type: integer
         unit: Wh
-        class: total_increasing
         optional: true
       - id: 25
         type: integer

+ 0 - 2
custom_components/tuya_local/devices/tyte_d1_thermostat.yaml

@@ -112,14 +112,12 @@ secondary_entities:
             step: 60
   - entity: sensor
     name: Electricity consumption
-    class: energy
     category: diagnostic
     dps:
       - id: 10
         type: integer
         name: sensor
         unit: Wh
-        class: total_increasing
       - id: 17
         type: integer
         name: coefficient

+ 0 - 2
tests/devices/test_grid_connect_double_power_point.py

@@ -89,9 +89,7 @@ class TestGridConnectDoubleSwitch(
                 {
                     "name": "sensor_energy",
                     "dps": ENERGY_DPS,
-                    "device_class": SensorDeviceClass.ENERGY,
                     "unit": UnitOfEnergy.WATT_HOUR,
-                    "state_class": "total_increasing",
                 },
                 {
                     "name": "sensor_current",

+ 0 - 2
tests/devices/test_jiahong_et72w_thermostat.py

@@ -125,8 +125,6 @@ class TestJiahongEt72wThermostat(
                 {
                     "dps": ENERGY_DPS,
                     "name": "sensor_energy",
-                    "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": STATE_CLASS_TOTAL_INCREASING,
                     "unit": UnitOfEnergy.KILO_WATT_HOUR,
                     "testdata": (1234, 123.4),
                 },

+ 0 - 6
tests/devices/test_pc321ty_energy_meter.py

@@ -91,8 +91,6 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "dps": ENERGY1_DP,
                     "name": "sensor_energy_a",
                     "unit": UnitOfEnergy.KILO_WATT_HOUR,
-                    "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": STATE_CLASS_TOTAL_INCREASING,
                     "testdata": (12345, 123.45),
                 },
                 {
@@ -129,8 +127,6 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "dps": ENERGY2_DP,
                     "name": "sensor_energy_b",
                     "unit": UnitOfEnergy.KILO_WATT_HOUR,
-                    "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": STATE_CLASS_TOTAL_INCREASING,
                     "testdata": (12345, 123.45),
                 },
                 {
@@ -167,8 +163,6 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "dps": ENERGY3_DP,
                     "name": "sensor_energy_c",
                     "unit": UnitOfEnergy.KILO_WATT_HOUR,
-                    "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": STATE_CLASS_TOTAL_INCREASING,
                     "testdata": (12345, 123.45),
                 },
                 {

+ 0 - 2
tests/devices/test_smartplugv2_energy.py

@@ -89,8 +89,6 @@ class TestSwitchV2Energy(
                     "name": "sensor_energy",
                     "dps": ENERGY_DPS,
                     "unit": UnitOfEnergy.WATT_HOUR,
-                    "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": "total_increasing",
                 },
                 {
                     "name": "sensor_voltage",