Просмотр исходного кода

Ecostrad heater: timer is in hours, not minutes.

Jason Rumney 4 лет назад
Родитель
Сommit
27f4cc6a75

+ 53 - 53
custom_components/tuya_local/devices/ecostrad_accentiq_heater.yaml

@@ -1,53 +1,53 @@
-name: Ecostrad Accent iQ heater
-primary_entity:
-  entity: climate
-  dps:
-    - id: 1
-      type: boolean
-      name: hvac_mode
-      mapping:
-        - dps_val: true
-          value: heat
-        - dps_val: false
-          value: "off"
-    - id: 2
-      type: integer
-      name: temperature
-      range:
-        min: 0
-        max: 450
-      mapping:
-        - scale: 10
-          step: 5
-          constraint: temperature_unit
-          conditions:
-            - dps_val: false
-              step: 10
-              range:
-                min: 32
-                max: 113
-    - id: 3
-      type: integer
-      name: current_temperature
-      mapping:
-        - scale: 10
-    - id: 101
-      type: boolean
-      name: temperature_unit
-      mapping:
-        - dps_val: true
-          value: C
-        - dps_val: false
-          value: F
-secondary_entities:
-  - entity: number
-    name: Timer
-    category: config
-    dps:
-      - id: 10
-        type: integer
-        name: value
-        unit: min
-        range:
-          min: 0
-          max: 720
+name: Ecostrad Accent iQ heater
+primary_entity:
+  entity: climate
+  dps:
+    - id: 1
+      type: boolean
+      name: hvac_mode
+      mapping:
+        - dps_val: true
+          value: heat
+        - dps_val: false
+          value: "off"
+    - id: 2
+      type: integer
+      name: temperature
+      range:
+        min: 0
+        max: 450
+      mapping:
+        - scale: 10
+          step: 5
+          constraint: temperature_unit
+          conditions:
+            - dps_val: false
+              step: 10
+              range:
+                min: 32
+                max: 113
+    - id: 3
+      type: integer
+      name: current_temperature
+      mapping:
+        - scale: 10
+    - id: 101
+      type: boolean
+      name: temperature_unit
+      mapping:
+        - dps_val: true
+          value: C
+        - dps_val: false
+          value: F
+secondary_entities:
+  - entity: number
+    name: Timer
+    category: config
+    dps:
+      - id: 10
+        type: integer
+        name: value
+        unit: h
+        range:
+          min: 0
+          max: 12

+ 90 - 90
tests/devices/test_ecostrad_accentiq_heater.py

@@ -1,90 +1,90 @@
-from homeassistant.components.climate.const import (
-    HVAC_MODE_HEAT,
-    HVAC_MODE_OFF,
-    SUPPORT_TARGET_TEMPERATURE,
-)
-from homeassistant.const import (
-    STATE_UNAVAILABLE,
-    TEMP_CELSIUS,
-    TEMP_FAHRENHEIT,
-    TIME_MINUTES,
-)
-
-from ..const import ECOSTRAD_ACCENTIQ_HEATER_PAYLOAD
-from ..helpers import assert_device_properties_set
-from ..mixins.climate import TargetTemperatureTests
-from ..mixins.number import BasicNumberTests
-from .base_device_tests import TuyaDeviceTestCase
-
-HVACMODE_DPS = "1"
-TEMPERATURE_DPS = "2"
-CURRENTTEMP_DPS = "3"
-TIMER_DPS = "10"
-UNIT_DPS = "101"
-
-
-class TestEcostradAccentIqHeater(
-    BasicNumberTests, TargetTemperatureTests, TuyaDeviceTestCase
-):
-    __test__ = True
-
-    def setUp(self):
-        self.setUpForConfig(
-            "ecostrad_accentiq_heater.yaml",
-            ECOSTRAD_ACCENTIQ_HEATER_PAYLOAD,
-        )
-        self.subject = self.entities.get("climate")
-        self.setUpTargetTemperature(
-            TEMPERATURE_DPS, self.subject, min=0.0, max=45.0, scale=10, step=5
-        )
-        self.setUpBasicNumber(
-            TIMER_DPS,
-            self.entities.get("number_timer"),
-            max=720,
-            unit=TIME_MINUTES,
-        )
-        self.mark_secondary(["number_timer"])
-
-    def test_supported_features(self):
-        self.assertEqual(
-            self.subject.supported_features,
-            SUPPORT_TARGET_TEMPERATURE,
-        )
-
-    def test_temperature_unit(self):
-        self.dps[UNIT_DPS] = True
-        self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
-        self.dps[UNIT_DPS] = False
-        self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
-
-    def test_current_temperature(self):
-        self.dps[CURRENTTEMP_DPS] = 250
-        self.assertEqual(self.subject.current_temperature, 25.0)
-
-    def test_hvac_mode(self):
-        self.dps[HVACMODE_DPS] = True
-        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
-
-        self.dps[HVACMODE_DPS] = False
-        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
-
-        self.dps[HVACMODE_DPS] = None
-        self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
-
-    def test_hvac_modes(self):
-        self.assertCountEqual(self.subject.hvac_modes, [HVAC_MODE_OFF, HVAC_MODE_HEAT])
-
-    async def test_turn_on(self):
-        async with assert_device_properties_set(
-            self.subject._device, {HVACMODE_DPS: True}
-        ):
-            await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
-
-    async def test_turn_off(self):
-        async with assert_device_properties_set(
-            self.subject._device, {HVACMODE_DPS: False}
-        ):
-            await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
-
-    def test_extra_state_attributes(self):
-        self.assertEqual(self.subject.extra_state_attributes, {})
+from homeassistant.components.climate.const import (
+    HVAC_MODE_HEAT,
+    HVAC_MODE_OFF,
+    SUPPORT_TARGET_TEMPERATURE,
+)
+from homeassistant.const import (
+    STATE_UNAVAILABLE,
+    TEMP_CELSIUS,
+    TEMP_FAHRENHEIT,
+    TIME_HOURS,
+)
+
+from ..const import ECOSTRAD_ACCENTIQ_HEATER_PAYLOAD
+from ..helpers import assert_device_properties_set
+from ..mixins.climate import TargetTemperatureTests
+from ..mixins.number import BasicNumberTests
+from .base_device_tests import TuyaDeviceTestCase
+
+HVACMODE_DPS = "1"
+TEMPERATURE_DPS = "2"
+CURRENTTEMP_DPS = "3"
+TIMER_DPS = "10"
+UNIT_DPS = "101"
+
+
+class TestEcostradAccentIqHeater(
+    BasicNumberTests, TargetTemperatureTests, TuyaDeviceTestCase
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig(
+            "ecostrad_accentiq_heater.yaml",
+            ECOSTRAD_ACCENTIQ_HEATER_PAYLOAD,
+        )
+        self.subject = self.entities.get("climate")
+        self.setUpTargetTemperature(
+            TEMPERATURE_DPS, self.subject, min=0.0, max=45.0, scale=10, step=5
+        )
+        self.setUpBasicNumber(
+            TIMER_DPS,
+            self.entities.get("number_timer"),
+            max=12,
+            unit=TIME_HOURS,
+        )
+        self.mark_secondary(["number_timer"])
+
+    def test_supported_features(self):
+        self.assertEqual(
+            self.subject.supported_features,
+            SUPPORT_TARGET_TEMPERATURE,
+        )
+
+    def test_temperature_unit(self):
+        self.dps[UNIT_DPS] = True
+        self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
+        self.dps[UNIT_DPS] = False
+        self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
+
+    def test_current_temperature(self):
+        self.dps[CURRENTTEMP_DPS] = 250
+        self.assertEqual(self.subject.current_temperature, 25.0)
+
+    def test_hvac_mode(self):
+        self.dps[HVACMODE_DPS] = True
+        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
+
+        self.dps[HVACMODE_DPS] = False
+        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
+
+        self.dps[HVACMODE_DPS] = None
+        self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
+
+    def test_hvac_modes(self):
+        self.assertCountEqual(self.subject.hvac_modes, [HVAC_MODE_OFF, HVAC_MODE_HEAT])
+
+    async def test_turn_on(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True}
+        ):
+            await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
+
+    async def test_turn_off(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: False}
+        ):
+            await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
+
+    def test_extra_state_attributes(self):
+        self.assertEqual(self.subject.extra_state_attributes, {})