فهرست منبع

smartplugv2_energy: update tests for attributes moving.

- rename energy_calibration to just calibration, as it is now on the
  energy sensor, so context is enough to replace the rest of the name.
Jason Rumney 3 سال پیش
والد
کامیت
b371d1a600
2فایلهای تغییر یافته به همراه24 افزوده شده و 9 حذف شده
  1. 1 1
      custom_components/tuya_local/devices/smartplugv2_energy.yaml
  2. 23 8
      tests/devices/test_smartplugv2_energy.py

+ 1 - 1
custom_components/tuya_local/devices/smartplugv2_energy.yaml

@@ -47,7 +47,7 @@ secondary_entities:
         unit: Wh
       - id: 25
         type: integer
-        name: energy_calibration
+        name: calibration
         optional: true
   - entity: sensor
     category: diagnostic

+ 23 - 8
tests/devices/test_smartplugv2_energy.py

@@ -130,10 +130,6 @@ class TestSwitchV2Energy(
 
     def test_multi_switch_state_attributes(self):
         self.dps[TEST_DPS] = 21
-        self.dps[CALIBV_DPS] = 22
-        self.dps[CALIBI_DPS] = 23
-        self.dps[CALIBP_DPS] = 24
-        self.dps[CALIBE_DPS] = 25
         self.dps[ERROR_DPS] = 26
         self.dps[CYCLE_DPS] = "1A2B"
         self.dps[RANDOM_DPS] = "3C4D"
@@ -142,12 +138,31 @@ class TestSwitchV2Energy(
             self.multiSwitch["switch"].extra_state_attributes,
             {
                 "test_bit": 21,
-                "voltage_calibration": 22,
-                "current_calibration": 23,
-                "power_calibration": 24,
-                "energy_calibration": 25,
                 "fault_code": 26,
                 "cycle_timer": "1A2B",
                 "random_timer": "3C4D",
             },
         )
+
+    def test_multi_sensor_extra_state_attributes(self):
+        self.dps[CALIBV_DPS] = 22
+        self.dps[CALIBI_DPS] = 23
+        self.dps[CALIBP_DPS] = 24
+        self.dps[CALIBE_DPS] = 25
+
+        self.assertDictEqual(
+            self.multiSensor["sensor_current"].extra_state_attributes,
+            {"calibration": 23},
+        )
+        self.assertDictEqual(
+            self.multiSensor["sensor_energy"].extra_state_attributes,
+            {"calibration": 25},
+        )
+        self.assertDictEqual(
+            self.multiSensor["sensor_power"].extra_state_attributes,
+            {"calibration": 24},
+        )
+        self.assertDictEqual(
+            self.multiSensor["sensor_voltage"].extra_state_attributes,
+            {"calibration": 22},
+        )