Explorar el Código

Add support for Eurom SaniWall 2000 heater.
Issue #75

Jason Rumney hace 4 años
padre
commit
67083a3c0a

+ 1 - 0
ACKNOWLEDGEMENTS.md

@@ -56,3 +56,4 @@ Further device support has been made with the assistance of users.  Please consi
  - [myevit](https://github.com/myevit) for assistance in supporting simple garage doors.
  - [maartendamen](https://github.com/maartendamen) for assistance in supporting Eurom Mon Soleil 601 heaters.
  - [TeddyLafrite](https://github.com/TeddyLafrite) for assistance in supporting Nedis HTPL20F heaters.
+ - [mvroosmalen1970](https://github.com/mvroosmalen1970) for assistance in supporting Eurom SaniWall 2000 heaters.

+ 1 - 0
README.md

@@ -37,6 +37,7 @@ the device will not work despite being listed below.
 - Kogan Wi-Fi Convection Panel heaters - KAHTP and KAWFHTP models
 - Andersson GSH heater
 - Eurom Mon Soleil 600 and 601 heaters
+- Eurom SaniWall 2000 heater
 - Purline Hoti M100 heater
 - Wetair WCH-750 heater
 - Kogan Flame effect heater - KAWHMFP20BA model

+ 50 - 0
custom_components/tuya_local/devices/eurom_saniwall2000_heater.yaml

@@ -0,0 +1,50 @@
+name: Eurom SaniWall 2000 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: low
+              value: heat
+              icon: "mdi:radiator"
+            - dps_val: high
+              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: low
+          value: eco
+        - dps_val: high
+          value: boost
+    - id: 7
+      type: boolean
+      name: swing_mode
+      mapping:
+        - dps_val: true
+          value: vertical
+        - dps_val: false
+          value: "off"

+ 8 - 0
tests/const.py

@@ -27,6 +27,14 @@ EUROM_600_HEATER_PAYLOAD = {"1": True, "2": 15, "5": 18, "6": 0}
 
 EUROM_601_HEATER_PAYLOAD = {"1": True, "2": 21, "3": 20, "6": False, "13": 0}
 
+EUROM_SANIWALL2000_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}
 
 KOGAN_HEATER_PAYLOAD = {"2": 30, "3": 25, "4": "Low", "6": True, "7": True, "8": 0}

+ 205 - 0
tests/devices/test_eurom_saniwall2000_heater.py

@@ -0,0 +1,205 @@
+from homeassistant.components.climate.const import (
+    HVAC_MODE_FAN_ONLY,
+    HVAC_MODE_HEAT,
+    HVAC_MODE_OFF,
+    PRESET_BOOST,
+    PRESET_ECO,
+    SUPPORT_TARGET_TEMPERATURE,
+    SUPPORT_PRESET_MODE,
+    SUPPORT_SWING_MODE,
+    SWING_OFF,
+    SWING_VERTICAL,
+)
+from homeassistant.const import STATE_UNAVAILABLE
+
+from ..const import EUROM_SANIWALL2000_HEATER_PAYLOAD
+from ..helpers import assert_device_properties_set
+from .base_device_tests import TuyaDeviceTestCase
+
+HVACMODE_DPS = "1"
+TEMPERATURE_DPS = "2"
+CURRENTTEMP_DPS = "3"
+PRESET_DPS = "4"
+SWING_DPS = "7"
+
+
+class TestEuromSaniWall2000Heater(TuyaDeviceTestCase):
+    __test__ = True
+
+    def setUp(self):
+        self.setUpForConfig(
+            "eurom_saniwall2000_heater.yaml", EUROM_SANIWALL2000_HEATER_PAYLOAD
+        )
+        self.subject = self.entities.get("climate")
+
+    def test_supported_features(self):
+        self.assertEqual(
+            self.subject.supported_features,
+            SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE | SUPPORT_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] = "low"
+        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_target_temperature(self):
+        self.dps[TEMPERATURE_DPS] = 25
+        self.assertEqual(self.subject.target_temperature, 25)
+
+    def test_target_temperature_step(self):
+        self.assertEqual(self.subject.target_temperature_step, 1)
+
+    def test_minimum_target_temperature(self):
+        self.assertEqual(self.subject.min_temp, 10)
+
+    def test_maximum_target_temperature(self):
+        self.assertEqual(self.subject.max_temp, 35)
+
+    async def test_legacy_set_temperature_with_temperature(self):
+        async with assert_device_properties_set(
+            self.subject._device, {TEMPERATURE_DPS: 24}
+        ):
+            await self.subject.async_set_temperature(temperature=24)
+
+    async def test_legacy_set_temperature_with_no_valid_properties(self):
+        await self.subject.async_set_temperature(something="else")
+        self.subject._device.async_set_property.assert_not_called()
+
+    async def test_set_target_temperature_succeeds_within_valid_range(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {TEMPERATURE_DPS: 25},
+        ):
+            await self.subject.async_set_target_temperature(25)
+
+    async def test_set_target_temperature_rounds_value_to_closest_integer(self):
+        async with assert_device_properties_set(
+            self.subject._device, {TEMPERATURE_DPS: 23}
+        ):
+            await self.subject.async_set_target_temperature(22.6)
+
+    async def test_set_target_temperature_fails_outside_valid_range(self):
+        with self.assertRaisesRegex(
+            ValueError, "temperature \\(9\\) must be between 10 and 35"
+        ):
+            await self.subject.async_set_target_temperature(9)
+
+        with self.assertRaisesRegex(
+            ValueError, "temperature \\(36\\) must be between 10 and 35"
+        ):
+            await self.subject.async_set_target_temperature(36)
+
+    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] = "high"
+        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
+
+        self.dps[PRESET_DPS] = "off"
+        self.assertEqual(self.subject.hvac_mode, HVAC_MODE_FAN_ONLY)
+
+        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, HVAC_MODE_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: "low"}
+        ):
+            await self.subject.async_set_hvac_mode(HVAC_MODE_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(HVAC_MODE_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(HVAC_MODE_OFF)
+
+    def test_preset_modes(self):
+        self.assertCountEqual(
+            self.subject.preset_modes,
+            [PRESET_BOOST, PRESET_ECO, "fan"],
+        )
+
+    def test_preset_mode(self):
+        self.dps[PRESET_DPS] = "off"
+        self.assertEqual(self.subject.preset_mode, "fan")
+        self.dps[PRESET_DPS] = "low"
+        self.assertEqual(self.subject.preset_mode, PRESET_ECO)
+
+        self.dps[PRESET_DPS] = "high"
+        self.assertEqual(self.subject.preset_mode, PRESET_BOOST)
+
+    async def test_set_preset_more_to_eco(self):
+        async with assert_device_properties_set(
+            self.subject._device, {PRESET_DPS: "low"}
+        ):
+            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: "high"}
+        ):
+            await self.subject.async_set_preset_mode(PRESET_BOOST)
+
+    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_device_state_attributes(self):
+        self.assertEqual(self.subject.device_state_attributes, {})