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

added Eurom Sani-Wall-Heat 2000 Wifi heater

Mark Ellis 3 лет назад
Родитель
Сommit
3e2c9ce50e

+ 55 - 0
custom_components/tuya_local/devices/eurom_saniwallheat2000_heater.yaml

@@ -0,0 +1,55 @@
+name: Eurom Sani-Wall-Heat 2000 Wifi heater
+primary_entity:
+  entity: climate
+  dps:
+    - id: 1
+      type: boolean
+      name: hvac_mode
+      mapping:
+        - dps_val: false
+          value: "off"
+          icon: "mdi:radiator-disabled"
+        - dps_val: true
+          constraint: preset_mode
+          conditions:
+            - dps_val: "off"
+              value: fan_only
+              icon: "mdi:fan"
+            - dps_val: auto
+              value: heat
+              icon: "mdi:radiator"
+            - dps_val: "50_per"
+              value: heat
+              icon: "mdi:radiator"
+            - dps_val: "100_per"
+              value: heat
+              icon: "mdi:radiator"
+    - id: 2
+      type: integer
+      name: temperature
+      range:
+        min: 10
+        max: 35
+    - id: 3
+      type: integer
+      name: current_temperature
+    - id: 4
+      type: string
+      name: preset_mode
+      mapping:
+        - dps_val: "off"
+          value: fan
+        - dps_val: "50_per"
+          value: eco
+        - dps_val: "100_per"
+          value: boost
+        - dps_val: auto
+          value: comfort
+    - id: 7
+      type: boolean
+      name: swing_mode
+      mapping:
+        - dps_val: true
+          value: vertical
+        - dps_val: false
+          value: "off"

+ 8 - 0
tests/const.py

@@ -36,6 +36,14 @@ EUROM_WALLDESIGNHEAT2000_HEATER_PAYLOAD = {
     "7": False,
 }
 
+EUROM_SANIWALLHEAT2000_HEATER_PAYLOAD = {
+    "1": True,
+    "2": 21,
+    "3": 19,
+    "4": "off",
+    "7": False,
+}
+
 GECO_HEATER_PAYLOAD = {"1": True, "2": True, "3": 30, "4": 25, "5": 0, "6": 0}
 
 JJPRO_JPD01_PAYLOAD = {

+ 173 - 0
tests/devices/test_eurom_saniwallheat2000_heater.py

@@ -0,0 +1,173 @@
+from homeassistant.components.climate.const import (
+    ClimateEntityFeature,
+    HVACMode,
+    PRESET_BOOST,
+    PRESET_COMFORT,
+    PRESET_ECO,
+    SWING_OFF,
+    SWING_VERTICAL,
+)
+
+from ..const import EUROM_SANIWALLHEAT2000_HEATER_PAYLOAD
+from ..helpers import assert_device_properties_set
+from ..mixins.climate import TargetTemperatureTests
+from .base_device_tests import TuyaDeviceTestCase
+
+HVACMODE_DPS = "1"
+TEMPERATURE_DPS = "2"
+CURRENTTEMP_DPS = "3"
+PRESET_DPS = "4"
+SWING_DPS = "7"
+
+
+class TestEuromSaniWallHeat2000Heater(
+    TargetTemperatureTests,
+    TuyaDeviceTestCase,
+):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig(
+            "eurom_saniwallheat2000_heater.yaml",
+            EUROM_SANIWALLHEAT2000_HEATER_PAYLOAD,
+        )
+        self.subject = self.entities.get("climate")
+        self.setUpTargetTemperature(
+            TEMPERATURE_DPS,
+            self.subject,
+            min=10,
+            max=35,
+        )
+
+    def test_supported_features(self):
+        self.assertEqual(
+            self.subject.supported_features,
+            (
+                ClimateEntityFeature.TARGET_TEMPERATURE
+                | ClimateEntityFeature.PRESET_MODE
+                | ClimateEntityFeature.SWING_MODE
+            ),
+        )
+
+    def test_icon(self):
+        self.dps[HVACMODE_DPS] = False
+        self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
+        self.dps[HVACMODE_DPS] = True
+        self.dps[PRESET_DPS] = "auto"
+        self.assertEqual(self.subject.icon, "mdi:radiator")
+        self.dps[PRESET_DPS] = "off"
+        self.assertEqual(self.subject.icon, "mdi:fan")
+
+    def test_temperature_unit_returns_device_temperature_unit(self):
+        self.assertEqual(
+            self.subject.temperature_unit, self.subject._device.temperature_unit
+        )
+
+    def test_current_temperature(self):
+        self.dps[CURRENTTEMP_DPS] = 25
+        self.assertEqual(self.subject.current_temperature, 25)
+
+    def test_hvac_mode(self):
+        self.dps[HVACMODE_DPS] = True
+        self.dps[PRESET_DPS] = "100_per"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
+
+        self.dps[PRESET_DPS] = "off"
+        self.assertEqual(self.subject.hvac_mode, HVACMode.FAN_ONLY)
+
+        self.dps[HVACMODE_DPS] = False
+        self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
+
+    def test_hvac_modes(self):
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [HVACMode.OFF, HVACMode.HEAT, HVACMode.FAN_ONLY],
+        )
+
+    async def test_set_hvac_mode_to_heat(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "auto"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.HEAT)
+
+    async def test_set_hvac_mode_to_fan(self):
+        async with assert_device_properties_set(
+            self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "off"}
+        ):
+            await self.subject.async_set_hvac_mode(HVACMode.FAN_ONLY)
+
+    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(HVACMode.OFF)
+
+    def test_preset_modes(self):
+        self.assertCountEqual(
+            self.subject.preset_modes,
+            [PRESET_BOOST, PRESET_COMFORT, PRESET_ECO, "fan"],
+        )
+
+    def test_preset_mode(self):
+        self.dps[PRESET_DPS] = "off"
+        self.assertEqual(self.subject.preset_mode, "fan")
+        self.dps[PRESET_DPS] = "50_per"
+        self.assertEqual(self.subject.preset_mode, PRESET_ECO)
+        self.dps[PRESET_DPS] = "100_per"
+        self.assertEqual(self.subject.preset_mode, PRESET_BOOST)
+        self.dps[PRESET_DPS] = "auto"
+        self.assertEqual(self.subject.preset_mode, PRESET_COMFORT)
+
+    async def test_set_preset_more_to_eco(self):
+        async with assert_device_properties_set(
+            self.subject._device, {PRESET_DPS: "50_per"}
+        ):
+            await self.subject.async_set_preset_mode(PRESET_ECO)
+
+    async def test_set_preset_more_to_boost(self):
+        async with assert_device_properties_set(
+            self.subject._device, {PRESET_DPS: "100_per"}
+        ):
+            await self.subject.async_set_preset_mode(PRESET_BOOST)
+
+    async def test_set_preset_mode_to_comfort(self):
+        async with assert_device_properties_set(
+            self.subject._device, {PRESET_DPS: "auto"}
+        ):
+            await self.subject.async_set_preset_mode(PRESET_COMFORT)
+
+    async def test_set_preset_mode_to_fan(self):
+        async with assert_device_properties_set(
+            self.subject._device, {PRESET_DPS: "off"}
+        ):
+            await self.subject.async_set_preset_mode("fan")
+
+    def test_swing_modes(self):
+        self.assertCountEqual(
+            self.subject.swing_modes,
+            [SWING_OFF, SWING_VERTICAL],
+        )
+
+    def test_swing_mode(self):
+        self.dps[SWING_DPS] = False
+        self.assertEqual(self.subject.swing_mode, SWING_OFF)
+
+        self.dps[SWING_DPS] = True
+        self.assertEqual(self.subject.swing_mode, SWING_VERTICAL)
+
+    async def test_set_swing_on(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {SWING_DPS: True},
+        ):
+            await self.subject.async_set_swing_mode(SWING_VERTICAL)
+
+    async def test_set_swing_off(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {SWING_DPS: False},
+        ):
+            await self.subject.async_set_swing_mode(SWING_OFF)
+
+    def test_extra_state_attributes(self):
+        self.assertEqual(self.subject.extra_state_attributes, {})