Przeglądaj źródła

Fix more tests

Previous failures had a lot more failures hading behind them.
Remote unnecessary device specific tests, tweak some of the older
device tests that were created to test specific features.  Also tweak
the device_config test for the changing of default to a property.
Jason Rumney 2 lat temu
rodzic
commit
7283e8978b

+ 23 - 7
tests/devices/test_beca_bhp6000_thermostat.py

@@ -29,7 +29,10 @@ class TestBecaBHP6000Thermostat(
     __test__ = True
 
     def setUp(self):
-        self.setUpForConfig("beca_bhp6000_thermostat_f.yaml", BECA_BHP6000_PAYLOAD)
+        self.setUpForConfig(
+            "beca_bhp6000_thermostat_f.yaml",
+            BECA_BHP6000_PAYLOAD,
+        )
         self.subject = self.entities.get("climate")
         self.setUpTargetTemperature(
             TEMPERATURE_DPS,
@@ -52,11 +55,17 @@ class TestBecaBHP6000Thermostat(
         )
 
     def test_temperature_unit_returns_configured_temperature_unit(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.FAHRENHEIT)
+        self.assertEqual(
+            self.subject.temperature_unit,
+            UnitOfTemperature.FAHRENHEIT,
+        )
 
     async def test_legacy_set_temperature_with_preset_mode(self):
-        async with assert_device_properties_set(self.subject._device, {PRESET_DPS: 1}):
-            await self.subject.async_set_temperature(preset_mode="Schedule")
+        async with assert_device_properties_set(
+            self.subject._device,
+            {PRESET_DPS: 1},
+        ):
+            await self.subject.async_set_temperature(preset_mode="program")
 
     async def test_legacy_set_temperature_with_both_properties(self):
         async with assert_device_properties_set(
@@ -67,7 +76,8 @@ class TestBecaBHP6000Thermostat(
             },
         ):
             await self.subject.async_set_temperature(
-                temperature=78, preset_mode="Holiday Hold"
+                temperature=78,
+                preset_mode="away",
             )
 
     def test_current_temperature(self):
@@ -156,12 +166,18 @@ class TestBecaBHP6000ThermostatC(TuyaDeviceTestCase):
     __test__ = True
 
     def setUp(self):
-        self.setUpForConfig("beca_bhp6000_thermostat_c.yaml", BECA_BHP6000_PAYLOAD)
+        self.setUpForConfig(
+            "beca_bhp6000_thermostat_c.yaml",
+            BECA_BHP6000_PAYLOAD,
+        )
         self.subject = self.entities.get("climate")
         self.mark_secondary(["light_display", "lock_child_lock"])
 
     def test_temperature_unit_returns_configured_temperature_unit(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
+        self.assertEqual(
+            self.subject.temperature_unit,
+            UnitOfTemperature.CELSIUS,
+        )
 
     def test_minimum_target_temperature(self):
         self.assertEqual(self.subject.min_temp, 5)

+ 0 - 204
tests/devices/test_bwt_heatpump.py

@@ -1,204 +0,0 @@
-from homeassistant.components.binary_sensor import BinarySensorDeviceClass
-from homeassistant.components.climate.const import (
-    ClimateEntityFeature,
-    HVACMode,
-)
-from homeassistant.const import UnitOfTemperature
-
-from ..const import BWT_HEATPUMP_PAYLOAD
-from ..helpers import assert_device_properties_set
-from ..mixins.binary_sensor import BasicBinarySensorTests
-from ..mixins.climate import TargetTemperatureTests
-from .base_device_tests import TuyaDeviceTestCase
-
-HVACMODE_DPS = "1"
-TEMPERATURE_DPS = "2"
-CURRENTTEMP_DPS = "3"
-PRESET_DPS = "4"
-ERROR_DPS = "9"
-
-
-class TestBWTHeatpump(
-    BasicBinarySensorTests,
-    TargetTemperatureTests,
-    TuyaDeviceTestCase,
-):
-    __test__ = True
-
-    def setUp(self):
-        self.setUpForConfig("bwt_heatpump.yaml", BWT_HEATPUMP_PAYLOAD)
-        self.subject = self.entities["climate"]
-        self.setUpTargetTemperature(
-            TEMPERATURE_DPS,
-            self.subject,
-            min=5,
-            max=40,
-        )
-        self.setUpBasicBinarySensor(
-            ERROR_DPS,
-            self.entities.get("binary_sensor_water_flow"),
-            device_class=BinarySensorDeviceClass.PROBLEM,
-            testdata=(1, 0),
-        )
-        self.mark_secondary(["binary_sensor_water_flow"])
-
-    def test_supported_features(self):
-        self.assertEqual(
-            self.subject.supported_features,
-            (
-                ClimateEntityFeature.TARGET_TEMPERATURE
-                | ClimateEntityFeature.PRESET_MODE
-            ),
-        )
-
-    def test_icon(self):
-        self.dps[HVACMODE_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:hot-tub")
-        self.dps[HVACMODE_DPS] = False
-        self.assertEqual(self.subject.icon, "mdi:hvac-off")
-
-    def test_temperature_unit_returns_celsius(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
-
-    async def test_legacy_set_temperature_with_preset_mode(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PRESET_DPS: "cool"}
-        ):
-            await self.subject.async_set_temperature(preset_mode="Smart Cooling")
-
-    async def test_legacy_set_temperature_with_both_properties(self):
-        async with assert_device_properties_set(
-            self.subject._device, {TEMPERATURE_DPS: 26, PRESET_DPS: "heat"}
-        ):
-            await self.subject.async_set_temperature(
-                temperature=26, preset_mode="Smart Heating"
-            )
-
-    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.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
-
-        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])
-
-    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(HVACMode.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(HVACMode.OFF)
-
-    def test_preset_mode(self):
-        self.dps[PRESET_DPS] = "heat"
-        self.assertEqual(self.subject.preset_mode, "Smart Heating")
-
-        self.dps[PRESET_DPS] = "cool"
-        self.assertEqual(self.subject.preset_mode, "Smart Cooling")
-
-        self.dps[PRESET_DPS] = "quickheat"
-        self.assertEqual(self.subject.preset_mode, "Boost Heating")
-
-        self.dps[PRESET_DPS] = "quickcool"
-        self.assertEqual(self.subject.preset_mode, "Boost Cooling")
-
-        self.dps[PRESET_DPS] = "quietheat"
-        self.assertEqual(self.subject.preset_mode, "Eco Heating")
-
-        self.dps[PRESET_DPS] = "quietcool"
-        self.assertEqual(self.subject.preset_mode, "Eco Cooling")
-
-        self.dps[PRESET_DPS] = "auto"
-        self.assertEqual(self.subject.preset_mode, "Auto")
-
-        self.dps[PRESET_DPS] = None
-        self.assertIs(self.subject.preset_mode, None)
-
-    def test_preset_modes(self):
-        self.assertCountEqual(
-            self.subject.preset_modes,
-            [
-                "Smart Heating",
-                "Boost Heating",
-                "Eco Heating",
-                "Smart Cooling",
-                "Boost Cooling",
-                "Eco Cooling",
-                "Auto",
-            ],
-        )
-
-    async def test_set_preset_mode_to_heat(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "heat"},
-        ):
-            await self.subject.async_set_preset_mode("Smart Heating")
-
-    async def test_set_preset_mode_to_cool(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "cool"},
-        ):
-            await self.subject.async_set_preset_mode("Smart Cooling")
-
-    async def test_set_preset_mode_to_quickheat(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "quickheat"},
-        ):
-            await self.subject.async_set_preset_mode("Boost Heating")
-
-    async def test_set_preset_mode_to_quickcool(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "quickcool"},
-        ):
-            await self.subject.async_set_preset_mode("Boost Cooling")
-
-    async def test_set_preset_mode_to_quietheat(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "quietheat"},
-        ):
-            await self.subject.async_set_preset_mode("Eco Heating")
-
-    async def test_set_preset_mode_to_quietcool(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "quietcool"},
-        ):
-            await self.subject.async_set_preset_mode("Eco Cooling")
-
-    async def test_set_preset_mode_to_auto(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "auto"},
-        ):
-            await self.subject.async_set_preset_mode("Auto")
-
-    def test_error_state(self):
-        self.dps[ERROR_DPS] = 0
-        self.assertEqual(self.subject.extra_state_attributes, {"error": "OK"})
-
-        self.dps[ERROR_DPS] = 1
-        self.assertEqual(
-            self.subject.extra_state_attributes,
-            {"error": "Water Flow Protection"},
-        )
-        self.dps[ERROR_DPS] = 2
-        self.assertEqual(
-            self.subject.extra_state_attributes,
-            {"error": 2},
-        )

+ 24 - 10
tests/devices/test_goldair_gpph_heater.py

@@ -97,6 +97,9 @@ class TestGoldairHeater(
             ),
         )
 
+    def test_translation_key(self):
+        self.assertEqual(self.subject.translation_key, "swing_as_powerlevel")
+
     def test_icon(self):
         self.dps[HVACMODE_DPS] = True
         self.assertEqual(self.subject.icon, "mdi:radiator")
@@ -109,7 +112,10 @@ class TestGoldairHeater(
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
     def test_temperature_unit_returns_celsius(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
+        self.assertEqual(
+            self.subject.temperature_unit,
+            UnitOfTemperature.CELSIUS,
+        )
 
     def test_precision(self):
         self.assertEqual(self.subject.precision, PRECISION_WHOLE)
@@ -170,7 +176,9 @@ class TestGoldairHeater(
         ):
             await self.subject.async_set_target_temperature(15)
 
-    async def test_set_target_temperature_fails_outside_valid_range_in_eco(self):
+    async def test_set_target_temperature_fails_outside_valid_range_in_eco(
+        self,
+    ):
         self.dps[PRESET_DPS] = "ECO"
 
         with self.assertRaisesRegex(
@@ -214,7 +222,10 @@ class TestGoldairHeater(
         self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
 
     def test_hvac_modes(self):
-        self.assertCountEqual(self.subject.hvac_modes, [HVACMode.OFF, HVACMode.HEAT])
+        self.assertCountEqual(
+            self.subject.hvac_modes,
+            [HVACMode.OFF, HVACMode.HEAT],
+        )
 
     async def test_turn_on(self):
         async with assert_device_properties_set(
@@ -242,7 +253,10 @@ class TestGoldairHeater(
         self.assertIs(self.subject.preset_mode, None)
 
     def test_preset_modes(self):
-        self.assertCountEqual(self.subject.preset_modes, ["comfort", "eco", "away"])
+        self.assertCountEqual(
+            self.subject.preset_modes,
+            ["comfort", "eco", "away"],
+        )
 
     async def test_set_preset_mode_to_comfort(self):
         async with assert_device_properties_set(
@@ -269,17 +283,17 @@ class TestGoldairHeater(
         self.dps[SWING_DPS] = "user"
 
         self.dps[POWERLEVEL_DPS] = "stop"
-        self.assertEqual(self.subject.swing_mode, "Stop")
+        self.assertEqual(self.subject.swing_mode, "stop")
 
         self.dps[POWERLEVEL_DPS] = "3"
         self.assertEqual(self.subject.swing_mode, "3")
 
     def test_non_user_swing_mode(self):
         self.dps[SWING_DPS] = "stop"
-        self.assertEqual(self.subject.swing_mode, "Stop")
+        self.assertEqual(self.subject.swing_mode, "stop")
 
         self.dps[SWING_DPS] = "auto"
-        self.assertEqual(self.subject.swing_mode, "Auto")
+        self.assertEqual(self.subject.swing_mode, "auto")
 
         self.dps[SWING_DPS] = None
         self.assertIs(self.subject.swing_mode, None)
@@ -287,7 +301,7 @@ class TestGoldairHeater(
     def test_swing_modes(self):
         self.assertCountEqual(
             self.subject.swing_modes,
-            ["Stop", "1", "2", "3", "4", "5", "Auto"],
+            ["stop", "1", "2", "3", "4", "5", "auto"],
         )
 
     async def test_set_power_level_to_stop(self):
@@ -295,14 +309,14 @@ class TestGoldairHeater(
             self.subject._device,
             {POWERLEVEL_DPS: "stop", SWING_DPS: "stop"},
         ):
-            await self.subject.async_set_swing_mode("Stop")
+            await self.subject.async_set_swing_mode("stop")
 
     async def test_set_swing_mode_to_auto(self):
         async with assert_device_properties_set(
             self.subject._device,
             {SWING_DPS: "auto"},
         ):
-            await self.subject.async_set_swing_mode("Auto")
+            await self.subject.async_set_swing_mode("auto")
 
     async def test_set_power_level_to_numeric_value(self):
         async with assert_device_properties_set(

+ 0 - 163
tests/devices/test_hellnar_heatpump.py

@@ -1,163 +0,0 @@
-from homeassistant.components.climate.const import (
-    ClimateEntityFeature,
-    HVACMode,
-)
-from homeassistant.const import UnitOfTemperature
-
-from ..const import HELLNAR_HEATPUMP_PAYLOAD
-from ..helpers import assert_device_properties_set
-from ..mixins.climate import TargetTemperatureTests
-from .base_device_tests import TuyaDeviceTestCase
-
-POWER_DPS = "1"
-TEMPERATURE_DPS = "2"
-CURRENTTEMP_DPS = "3"
-HVACMODE_DPS = "4"
-
-
-class TestHellnarHeatpump(TargetTemperatureTests, TuyaDeviceTestCase):
-    __test__ = True
-
-    def setUp(self):
-        self.setUpForConfig("hellnar_heatpump.yaml", HELLNAR_HEATPUMP_PAYLOAD)
-        self.subject = self.entities.get("climate")
-        self.setUpTargetTemperature(
-            TEMPERATURE_DPS,
-            self.subject,
-            min=17.0,
-            max=30.0,
-            scale=10,
-        )
-
-    def test_supported_features(self):
-        self.assertEqual(
-            self.subject.supported_features,
-            (ClimateEntityFeature.SWING_MODE | ClimateEntityFeature.TARGET_TEMPERATURE),
-        )
-
-    def test_icon(self):
-        self.dps[POWER_DPS] = True
-        self.dps[HVACMODE_DPS] = "auto"
-        self.assertEqual(self.subject.icon, "mdi:hvac")
-        self.dps[HVACMODE_DPS] = "cold"
-        self.assertEqual(self.subject.icon, "mdi:snowflake")
-        self.dps[HVACMODE_DPS] = "hot"
-        self.assertEqual(self.subject.icon, "mdi:fire")
-        self.dps[HVACMODE_DPS] = "wet"
-        self.assertEqual(self.subject.icon, "mdi:water")
-        self.dps[HVACMODE_DPS] = "wind"
-        self.assertEqual(self.subject.icon, "mdi:fan")
-        self.dps[POWER_DPS] = False
-        self.assertEqual(self.subject.icon, "mdi:hvac-off")
-
-    def test_temperature_unit_celsius(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
-
-    def test_minimum_target_temperature_in_hot(self):
-        self.dps[HVACMODE_DPS] = "hot"
-        self.assertEqual(self.subject.min_temp, 0.0)
-
-    def test_maximum_target_temperature_in_hot(self):
-        self.dps[HVACMODE_DPS] = "hot"
-        self.assertEqual(self.subject.max_temp, 30.0)
-
-    async def test_set_target_temperature_fails_outside_valid_range_in_hot(self):
-        self.dps[HVACMODE_DPS] = "hot"
-        with self.assertRaisesRegex(
-            ValueError, "temperature \\(31\\) must be between 0.0 and 30.0"
-        ):
-            await self.subject.async_set_target_temperature(31)
-
-    def test_current_temperature(self):
-        self.dps[CURRENTTEMP_DPS] = 25
-        self.assertEqual(self.subject.current_temperature, 25)
-
-    def test_hvac_mode(self):
-        self.dps[POWER_DPS] = True
-        self.dps[HVACMODE_DPS] = "hot"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
-
-        self.dps[HVACMODE_DPS] = "cold"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
-
-        self.dps[HVACMODE_DPS] = "wet"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.DRY)
-
-        self.dps[HVACMODE_DPS] = "wind"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.FAN_ONLY)
-
-        self.dps[HVACMODE_DPS] = "auto"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
-
-        self.dps[HVACMODE_DPS] = "auto"
-        self.dps[POWER_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.HEAT_COOL,
-                HVACMode.COOL,
-                HVACMode.DRY,
-                HVACMode.FAN_ONLY,
-            ],
-        )
-
-    async def test_turn_on(self):
-        async with assert_device_properties_set(
-            self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "hot"}
-        ):
-            await self.subject.async_set_hvac_mode(HVACMode.HEAT)
-
-    async def test_turn_off(self):
-        async with assert_device_properties_set(
-            self.subject._device, {POWER_DPS: False}
-        ):
-            await self.subject.async_set_hvac_mode(HVACMode.OFF)
-
-    def test_extra_state_attributes(self):
-        self.dps["5"] = "fan?"
-        self.dps["18"] = 18
-        self.dps["20"] = 20
-        self.dps["105"] = "unknown105"
-        self.dps["110"] = 110
-        self.dps["113"] = "unknown113"
-        self.dps["114"] = "unknown114"
-        self.dps["119"] = "unknown119"
-        self.dps["120"] = "unknown120"
-        self.dps["126"] = "unknown126"
-        self.dps["127"] = "unknown127"
-        self.dps["128"] = "unknown128"
-        self.dps["129"] = "unknown129"
-        self.dps["130"] = 130
-        self.dps["131"] = True
-        self.dps["132"] = False
-        self.dps["133"] = "unknown133"
-        self.dps["134"] = "unknown134"
-
-        self.assertDictEqual(
-            self.subject.extra_state_attributes,
-            {
-                "maybe_fan_mode": "fan?",
-                "unknown_18": 18,
-                "unknown_20": 20,
-                "unknown_105": "unknown105",
-                "unknown_110": 110,
-                "unknown_113": "unknown113",
-                "unknown_114": "unknown114",
-                "unknown_119": "unknown119",
-                "unknown_120": "unknown120",
-                "unknown_126": "unknown126",
-                "unknown_127": "unknown127",
-                "unknown_128": "unknown128",
-                "unknown_129": "unknown129",
-                "maybe_eco_temp": 130,
-                "unknown_131": True,
-                "unknown_132": False,
-                "unknown_133": "unknown133",
-                "unknown_134": "unknown134",
-            },
-        )

+ 0 - 314
tests/devices/test_inkbird_itc306a_thermostat.py

@@ -1,314 +0,0 @@
-from homeassistant.components.binary_sensor import BinarySensorDeviceClass
-from homeassistant.components.climate.const import (
-    ClimateEntityFeature,
-    HVACAction,
-)
-from homeassistant.components.number.const import NumberDeviceClass
-from homeassistant.const import UnitOfTime, UnitOfTemperature
-
-
-from ..const import INKBIRD_ITC306A_THERMOSTAT_PAYLOAD
-from ..helpers import assert_device_properties_set
-from ..mixins.binary_sensor import MultiBinarySensorTests
-from ..mixins.number import MultiNumberTests
-from ..mixins.select import BasicSelectTests
-from .base_device_tests import TuyaDeviceTestCase
-
-ERROR_DPS = "12"
-UNIT_DPS = "101"
-CALIBRATE_DPS = "102"
-PRESET_DPS = "103"
-CURRENTTEMP_DPS = "104"
-TEMPLOW_DPS = "106"
-TIME_THRES_DPS = "108"
-HIGH_THRES_DPS = "109"
-LOW_THRES_DPS = "110"
-ALARM_HIGH_DPS = "111"
-ALARM_LOW_DPS = "112"
-ALARM_DIFF_DPS = "113"
-TEMPHIGH_DPS = "114"
-SWITCH_DPS = "115"
-TEMPF_DPS = "116"
-UNKNOWN117_DPS = "117"
-UNKNOWN118_DPS = "118"
-UNKNOWN119_DPS = "119"
-ALARM_TIME_DPS = "120"
-
-
-class TestInkbirdThermostat(
-    BasicSelectTests,
-    MultiBinarySensorTests,
-    MultiNumberTests,
-    TuyaDeviceTestCase,
-):
-    __test__ = True
-
-    def setUp(self):
-        self.setUpForConfig(
-            "inkbird_itc306a_thermostat.yaml", INKBIRD_ITC306A_THERMOSTAT_PAYLOAD
-        )
-        self.subject = self.entities.get("climate")
-        self.setUpBasicSelect(
-            UNIT_DPS,
-            self.entities.get("select_temperature_unit"),
-            {
-                "C": "Celsius",
-                "F": "Fahrenheit",
-            },
-        )
-        self.setUpMultiBinarySensors(
-            [
-                {
-                    "name": "binary_sensor_high_temperature",
-                    "dps": ALARM_HIGH_DPS,
-                    "device_class": BinarySensorDeviceClass.HEAT,
-                },
-                {
-                    "name": "binary_sensor_low_temperature",
-                    "dps": ALARM_LOW_DPS,
-                    "device_class": BinarySensorDeviceClass.COLD,
-                },
-                {
-                    "name": "binary_sensor_continuous_heat",
-                    "dps": ALARM_TIME_DPS,
-                    "device_class": BinarySensorDeviceClass.PROBLEM,
-                },
-                {
-                    "name": "binary_sensor_unbalanced",
-                    "dps": ALARM_DIFF_DPS,
-                    "device_class": BinarySensorDeviceClass.PROBLEM,
-                },
-                {
-                    "name": "binary_sensor_error",
-                    "dps": ERROR_DPS,
-                    "device_class": BinarySensorDeviceClass.PROBLEM,
-                    "testdata": (1, 0),
-                },
-            ]
-        )
-        self.setUpMultiNumber(
-            [
-                {
-                    "name": "number_calibration_offset",
-                    "dps": CALIBRATE_DPS,
-                    "scale": 10,
-                    "step": 0.1,
-                    "min": -9.9,
-                    "max": 9.9,
-                },
-                {
-                    "name": "number_continuous_heat_hours",
-                    "dps": TIME_THRES_DPS,
-                    "max": 96,
-                    "unit": UnitOfTime.HOURS,
-                },
-                {
-                    "name": "number_high_temperature_limit",
-                    "dps": HIGH_THRES_DPS,
-                    "device_class": NumberDeviceClass.TEMPERATURE,
-                    "scale": 10,
-                    "step": 0.1,
-                    "min": -40,
-                    "max": 100,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-                {
-                    "name": "number_low_temperature_limit",
-                    "dps": LOW_THRES_DPS,
-                    "device_class": NumberDeviceClass.TEMPERATURE,
-                    "scale": 10,
-                    "step": 0.1,
-                    "min": -40,
-                    "max": 100,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-            ]
-        )
-        self.mark_secondary(
-            [
-                "select_temperature_unit",
-                "binary_sensor_high_temperature",
-                "binary_sensor_low_temperature",
-                "binary_sensor_continuous_heat",
-                "binary_sensor_unbalanced",
-                "binary_sensor_error",
-                "number_calibration_offset",
-                "number_continuous_heat_hours",
-                "number_high_temperature_limit",
-                "number_low_temperature_limit",
-            ]
-        )
-
-    def test_supported_features(self):
-        self.assertEqual(
-            self.subject.supported_features,
-            (
-                ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
-                | ClimateEntityFeature.PRESET_MODE
-            ),
-        )
-
-    def test_icon(self):
-        """Test that the icon is as expected."""
-        self.dps[ALARM_HIGH_DPS] = False
-        self.dps[ALARM_LOW_DPS] = False
-        self.dps[ALARM_TIME_DPS] = False
-        self.dps[SWITCH_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:thermometer")
-
-        self.dps[SWITCH_DPS] = False
-        self.assertEqual(self.subject.icon, "mdi:thermometer-off")
-
-        self.dps[ALARM_HIGH_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:thermometer-alert")
-
-        self.dps[SWITCH_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:thermometer-alert")
-
-        self.dps[ALARM_HIGH_DPS] = False
-        self.dps[ALARM_LOW_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:snowflake-alert")
-
-        self.dps[ALARM_LOW_DPS] = False
-        self.dps[ALARM_TIME_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:clock-alert")
-
-        self.dps[ALARM_TIME_DPS] = False
-        self.dps[ALARM_DIFF_DPS] = True
-        self.assertEqual(self.subject.icon, "mdi:thermometer-alert")
-
-    def test_climate_hvac_modes(self):
-        self.assertEqual(self.subject.hvac_modes, [])
-
-    def test_preset_mode(self):
-        self.dps[PRESET_DPS] = "on"
-        self.assertEqual(self.subject.preset_mode, "On")
-
-        self.dps[PRESET_DPS] = "pause"
-        self.assertEqual(self.subject.preset_mode, "Pause")
-
-        self.dps[PRESET_DPS] = "off"
-        self.assertEqual(self.subject.preset_mode, "Off")
-
-        self.dps[PRESET_DPS] = None
-        self.assertEqual(self.subject.preset_mode, None)
-
-    def test_preset_modes(self):
-        self.assertCountEqual(
-            self.subject.preset_modes,
-            ["On", "Pause", "Off"],
-        )
-
-    async def test_set_preset_to_on(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {
-                PRESET_DPS: "on",
-            },
-        ):
-            await self.subject.async_set_preset_mode("On")
-            self.subject._device.anticipate_property_value.assert_not_called()
-
-    async def test_set_preset_to_pause(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {
-                PRESET_DPS: "pause",
-            },
-        ):
-            await self.subject.async_set_preset_mode("Pause")
-            self.subject._device.anticipate_property_value.assert_not_called()
-
-    async def test_set_preset_to_off(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {
-                PRESET_DPS: "off",
-            },
-        ):
-            await self.subject.async_set_preset_mode("Off")
-            self.subject._device.anticipate_property_value.assert_not_called()
-
-    def test_current_temperature(self):
-        self.dps[UNIT_DPS] = "C"
-        self.dps[CURRENTTEMP_DPS] = 289
-        self.assertEqual(self.subject.current_temperature, 28.9)
-        self.dps[UNIT_DPS] = "F"
-        self.dps[TEMPF_DPS] = 789
-        self.assertEqual(self.subject.current_temperature, 78.9)
-
-    def test_temperature_unit(self):
-        self.dps[UNIT_DPS] = "F"
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.FAHRENHEIT)
-
-        self.dps[UNIT_DPS] = "C"
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
-
-    def test_minimum_target_temperature(self):
-        self.dps[UNIT_DPS] = "C"
-        self.assertEqual(self.subject.min_temp, 0.0)
-        self.dps[UNIT_DPS] = "F"
-        self.assertEqual(self.subject.min_temp, 32.0)
-
-    def test_maximum_target_temperature(self):
-        self.dps[UNIT_DPS] = "C"
-        self.assertEqual(self.subject.max_temp, 45.0)
-        self.dps[UNIT_DPS] = "F"
-        self.assertEqual(self.subject.max_temp, 113.0)
-
-    def test_temperature_range(self):
-        self.dps[TEMPHIGH_DPS] = 301
-        self.dps[TEMPLOW_DPS] = 255
-        self.assertEqual(self.subject.target_temperature_high, 30.1)
-        self.assertEqual(self.subject.target_temperature_low, 25.5)
-
-    async def test_set_temperature_range(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {
-                TEMPHIGH_DPS: 322,
-                TEMPLOW_DPS: 266,
-            },
-        ):
-            await self.subject.async_set_temperature(
-                target_temp_high=32.2, target_temp_low=26.6
-            )
-
-    async def test_set_target_temperature_fails_outside_valid_range(self):
-        self.dps[UNIT_DPS] = "C"
-        with self.assertRaisesRegex(
-            ValueError, "target_temp_low \\(-0.1\\) must be between 0.0 and 45.0"
-        ):
-            await self.subject.async_set_temperature(
-                target_temp_high=32.2, target_temp_low=-0.1
-            )
-
-        self.dps[UNIT_DPS] = "F"
-        with self.assertRaisesRegex(
-            ValueError, "target_temp_high \\(113.1\\) must be between 32.0 and 113.0"
-        ):
-            await self.subject.async_set_temperature(
-                target_temp_low=70.0, target_temp_high=113.1
-            )
-
-    def test_hvac_action(self):
-        self.dps[SWITCH_DPS] = False
-        self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
-        self.dps[SWITCH_DPS] = True
-        self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
-
-    def test_extra_state_attributes(self):
-        self.dps[ERROR_DPS] = 1
-        self.dps[UNKNOWN117_DPS] = True
-        self.dps[UNKNOWN118_DPS] = False
-        self.dps[UNKNOWN119_DPS] = True
-
-        self.assertDictEqual(
-            self.subject.extra_state_attributes,
-            {
-                "error": 1,
-                "unknown_117": True,
-                "unknown_118": False,
-                "unknown_119": True,
-            },
-        )

+ 0 - 331
tests/devices/test_minco_mh1823d_thermostat.py

@@ -1,331 +0,0 @@
-from homeassistant.components.climate.const import (
-    ClimateEntityFeature,
-    HVACAction,
-    HVACMode,
-)
-from homeassistant.components.number.const import NumberDeviceClass
-from homeassistant.components.sensor import SensorDeviceClass
-from homeassistant.const import UnitOfTemperature
-
-from ..const import MINCO_MH1823D_THERMOSTAT_PAYLOAD
-from ..helpers import assert_device_properties_set
-from ..mixins.climate import TargetTemperatureTests
-from ..mixins.lock import BasicLockTests
-from ..mixins.number import MultiNumberTests
-from ..mixins.select import MultiSelectTests
-from ..mixins.sensor import BasicSensorTests
-from ..mixins.switch import BasicSwitchTests
-from .base_device_tests import TuyaDeviceTestCase
-
-HVACMODE_DPS = "1"
-PRESET_DPS = "2"
-HVACACTION_DPS = "3"
-LOCK_DPS = "5"
-ANTIFROST_DPS = "9"
-UNKNOWN12_DPS = "12"
-SELECT_DPS = "18"
-UNIT_DPS = "19"
-TEMPERATURE_DPS = "22"
-TEMPF_DPS = "23"
-UNKNOWN32_DPS = "32"
-CURRENTTEMP_DPS = "33"
-CALIBINT_DPS = "35"
-CURTEMPF_DPS = "37"
-SCHEDULE_DPS = "39"
-UNKNOWN45_DPS = "45"
-EXTERNTEMP_DPS = "101"
-EXTTEMPF_DPS = "102"
-CALIBEXT_DPS = "103"
-CALIBSWING_DPS = "104"
-UNKNOWN105_DPS = "105"
-TEMPLIMIT_DPS = "106"
-TEMPLIMITF_DPS = "107"
-
-
-class TestMincoMH1823DThermostat(
-    BasicLockTests,
-    BasicSensorTests,
-    BasicSwitchTests,
-    MultiNumberTests,
-    MultiSelectTests,
-    TargetTemperatureTests,
-    TuyaDeviceTestCase,
-):
-    __test__ = True
-
-    def setUp(self):
-        self.setUpForConfig(
-            "minco_mh1823d_thermostat.yaml",
-            MINCO_MH1823D_THERMOSTAT_PAYLOAD,
-        )
-        self.subject = self.entities.get("climate")
-        self.setUpTargetTemperature(
-            TEMPERATURE_DPS,
-            self.subject,
-            min=5,
-            max=50,
-        )
-        self.setUpBasicLock(LOCK_DPS, self.entities.get("lock_child_lock"))
-        self.setUpBasicSensor(
-            EXTERNTEMP_DPS,
-            self.entities.get("sensor_external_temperature"),
-            unit=UnitOfTemperature.CELSIUS,
-            device_class=SensorDeviceClass.TEMPERATURE,
-            state_class="measurement",
-            testdata=(300, 30.0),
-        )
-        self.setUpBasicSwitch(ANTIFROST_DPS, self.entities.get("switch_anti_frost"))
-        self.setUpMultiNumber(
-            [
-                {
-                    "name": "number_calibration_offset_internal",
-                    "dps": CALIBINT_DPS,
-                    "min": -9,
-                    "max": 9,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-                {
-                    "name": "number_calibration_offset_external",
-                    "dps": CALIBEXT_DPS,
-                    "min": -9,
-                    "max": 9,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-                {
-                    "name": "number_calibration_swing",
-                    "dps": CALIBSWING_DPS,
-                    "min": 1,
-                    "max": 9,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-                {
-                    "name": "number_high_temperature_limit",
-                    "dps": TEMPLIMIT_DPS,
-                    "device_class": NumberDeviceClass.TEMPERATURE,
-                    "min": 5,
-                    "max": 65,
-                    "unit": UnitOfTemperature.CELSIUS,
-                },
-            ]
-        )
-        self.setUpMultiSelect(
-            [
-                {
-                    "name": "select_temperature_sensor",
-                    "dps": SELECT_DPS,
-                    "options": {
-                        "in": "Internal",
-                        "out": "External",
-                    },
-                },
-                {
-                    "name": "select_temperature_unit",
-                    "dps": UNIT_DPS,
-                    "options": {
-                        "c": "Celsius",
-                        "f": "Fahrenheit",
-                    },
-                },
-                {
-                    "name": "select_schedule",
-                    "dps": SCHEDULE_DPS,
-                    "options": {
-                        "7": "7 day",
-                        "5_2": "5+2 day",
-                        "6_1": "6+1 day",
-                    },
-                },
-            ]
-        )
-        self.mark_secondary(
-            [
-                "lock_child_lock",
-                "number_calibration_offset_internal",
-                "number_calibration_offset_external",
-                "number_calibration_swing",
-                "number_high_temperature_limit",
-                "select_temperature_sensor",
-                "select_temperature_unit",
-                "select_schedule",
-                "switch_anti_frost",
-            ]
-        )
-
-    def test_supported_features(self):
-        self.assertEqual(
-            self.subject.supported_features,
-            (
-                ClimateEntityFeature.TARGET_TEMPERATURE
-                | ClimateEntityFeature.PRESET_MODE
-            ),
-        )
-
-    def test_icon(self):
-        self.dps[HVACMODE_DPS] = True
-        self.dps[HVACACTION_DPS] = "start"
-        self.assertEqual(self.subject.icon, "mdi:thermometer")
-
-        self.dps[HVACACTION_DPS] = "stop"
-        self.assertEqual(self.subject.icon, "mdi:thermometer-off")
-
-        self.assertEqual(self.basicSwitch.icon, "mdi:snowflake-melt")
-
-    def test_temperature_unit(self):
-        self.dps[UNIT_DPS] = "c"
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
-        self.dps[UNIT_DPS] = "f"
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.FAHRENHEIT)
-
-    def test_target_temperature_f(self):
-        self.dps[TEMPF_DPS] = 70
-
-        self.dps[UNIT_DPS] = "f"
-        self.assertEqual(self.subject.target_temperature, 70)
-
-    def test_minimum_target_temperature_f(self):
-        self.dps[UNIT_DPS] = "f"
-        self.assertEqual(self.subject.min_temp, 41)
-
-    def test_maximum_target_temperature_f(self):
-        self.dps[UNIT_DPS] = "f"
-        self.assertEqual(self.subject.max_temp, 99)
-
-    async def test_legacy_set_temperature_with_preset_mode(self):
-        async with assert_device_properties_set(
-            self.subject._device, {PRESET_DPS: "holiday"}
-        ):
-            await self.subject.async_set_temperature(preset_mode="holiday")
-
-    async def test_legacy_set_temperature_with_both_properties(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {
-                TEMPERATURE_DPS: 25,
-                PRESET_DPS: "program",
-            },
-        ):
-            await self.subject.async_set_temperature(
-                temperature=25, preset_mode="program"
-            )
-
-    async def test_set_target_temperature_fails_outside_valid_range_f(self):
-        self.dps[UNIT_DPS] = "f"
-        with self.assertRaisesRegex(
-            ValueError, "temp_f \\(40\\) must be between 41 and 99"
-        ):
-            await self.subject.async_set_target_temperature(40)
-
-        with self.assertRaisesRegex(
-            ValueError, "temp_f \\(100\\) must be between 41 and 99"
-        ):
-            await self.subject.async_set_target_temperature(100)
-
-    def test_current_temperature(self):
-        self.dps[CURRENTTEMP_DPS] = 251
-        self.dps[CURTEMPF_DPS] = 783
-        self.dps[UNIT_DPS] = "c"
-        self.assertEqual(self.subject.current_temperature, 25.1)
-        self.dps[UNIT_DPS] = "f"
-        self.assertEqual(self.subject.current_temperature, 78.3)
-
-    def test_hvac_mode(self):
-        self.dps[HVACMODE_DPS] = True
-        self.dps[PRESET_DPS] = "manual"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
-        self.dps[PRESET_DPS] = "program"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.AUTO)
-        self.dps[PRESET_DPS] = "holiday"
-        self.assertEqual(self.subject.hvac_mode, HVACMode.AUTO)
-
-        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.AUTO]
-        )
-
-    async def test_set_hvac_heat(self):
-        async with assert_device_properties_set(
-            self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "manual"}
-        ):
-            await self.subject.async_set_hvac_mode(HVACMode.HEAT)
-
-    async def test_set_hvac_auto(self):
-        async with assert_device_properties_set(
-            self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "program"}
-        ):
-            await self.subject.async_set_hvac_mode(HVACMode.AUTO)
-
-    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_mode(self):
-        self.dps[PRESET_DPS] = "manual"
-        self.assertEqual(self.subject.preset_mode, "manual")
-
-        self.dps[PRESET_DPS] = "program"
-        self.assertEqual(self.subject.preset_mode, "program")
-
-        self.dps[PRESET_DPS] = "holiday"
-        self.assertEqual(self.subject.preset_mode, "holiday")
-
-        self.dps[PRESET_DPS] = None
-        self.assertEqual(self.subject.preset_mode, None)
-
-    def test_preset_modes(self):
-        self.assertCountEqual(
-            self.subject.preset_modes,
-            ["manual", "program", "holiday"],
-        )
-
-    async def test_set_preset_mode_to_program(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "program"},
-        ):
-            await self.subject.async_set_preset_mode("program")
-
-    async def test_set_preset_mode_to_manual(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "manual"},
-        ):
-            await self.subject.async_set_preset_mode("manual")
-
-    async def test_set_preset_mode_to_holiday(self):
-        async with assert_device_properties_set(
-            self.subject._device,
-            {PRESET_DPS: "holiday"},
-        ):
-            await self.subject.async_set_preset_mode("holiday")
-
-    def test_hvac_action(self):
-        self.dps[HVACMODE_DPS] = True
-        self.dps[HVACACTION_DPS] = "start"
-        self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
-
-        self.dps[HVACACTION_DPS] = "stop"
-        self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
-
-        self.dps[HVACMODE_DPS] = False
-        self.assertEqual(self.subject.hvac_action, HVACAction.OFF)
-
-    def test_extra_state_attributes(self):
-        self.dps[UNKNOWN12_DPS] = False
-        self.dps[UNKNOWN32_DPS] = 32
-        self.dps[UNKNOWN45_DPS] = 45
-        self.dps[UNKNOWN105_DPS] = "unknown 105"
-
-        self.assertDictEqual(
-            self.subject.extra_state_attributes,
-            {
-                "unknown_12": False,
-                "unknown_32": 32,
-                "unknown_45": 45,
-                "unknown_105": "unknown 105",
-            },
-        )

+ 1 - 8
tests/test_device_config.py

@@ -476,16 +476,9 @@ class TestDeviceConfig(IsolatedAsyncioTestCase):
         self.assertEqual("sub-id", get_device_id({"device_cid": "sub-id"}))
         self.assertEqual("s", get_device_id({"device_id": "d", "device_cid": "s"}))
 
-    # values gets very complex, with things like mappings within conditions
-    # within mappings. I'd expect something like this was added with purpose,
-    # but it isn't exercised by any of the existing unit tests.
-    # value-mirror above is explained by the fact that the device it was
-
-    # added for never worked properly, so was removed.
-
     def test_default_without_mapping(self):
         """Test that default returns None when there is no mapping"""
         mock_entity = MagicMock()
         mock_config = {"id": "1", "name": "test", "type": "string"}
         cfg = TuyaDpsConfig(mock_entity, mock_config)
-        self.assertIsNone(cfg.default())
+        self.assertIsNone(cfg.default)