Przeglądaj źródła

Refactor: hardcode default temperature unit in climate and water_heater entities.

Instead of deferring to device, just hardcode the fallback as CELSIUS.

I guess the original thinking was that temperature units would depend on the device (US marketed devices vs rest of world).  But if not specified explicitly in the config, we can only really have one default, which is CELSIUS.

This simplifies device by removing an unnecessary property, and removes that link with the history of this integration originally targeting climate devices.
Jason Rumney 3 lat temu
rodzic
commit
cbb9a1ee9b
37 zmienionych plików z 91 dodań i 143 usunięć
  1. 1 6
      custom_components/tuya_local/device.py
  2. 2 2
      custom_components/tuya_local/generic/climate.py
  3. 1 1
      custom_components/tuya_local/generic/water_heater.py
  4. 3 4
      tests/devices/test_andersson_gsh_heater.py
  5. 2 4
      tests/devices/test_awow_th213_thermostat.py
  6. 2 4
      tests/devices/test_awow_th213v2_thermostat.py
  7. 1 1
      tests/devices/test_beca_bht002_thermostat.py
  8. 1 1
      tests/devices/test_beca_bht6000_thermostat.py
  9. 3 5
      tests/devices/test_betterlife_bl1500_heater.py
  10. 3 4
      tests/devices/test_bwt_heatpump.py
  11. 1 1
      tests/devices/test_ecostrad_iqceramic_radiator.py
  12. 3 4
      tests/devices/test_electriq_12wminv_heatpump.py
  13. 3 5
      tests/devices/test_electriq_desd9lw_dehumidifier.py
  14. 3 4
      tests/devices/test_eurom_600_heater.py
  15. 3 4
      tests/devices/test_eurom_600v2_heater.py
  16. 3 4
      tests/devices/test_eurom_601_heater.py
  17. 3 4
      tests/devices/test_eurom_saniwallheat2000_heater.py
  18. 3 4
      tests/devices/test_eurom_walldesignheat2000_heater.py
  19. 3 5
      tests/devices/test_goldair_geco_heater.py
  20. 3 5
      tests/devices/test_goldair_gpcv_heater.py
  21. 3 5
      tests/devices/test_goldair_gpph_heater.py
  22. 3 4
      tests/devices/test_hellnar_heatpump.py
  23. 3 5
      tests/devices/test_hydrotherm_dynamicx8.py
  24. 3 5
      tests/devices/test_kogan_kahtp_heater.py
  25. 3 4
      tests/devices/test_kogan_kashmfp20ba_heater.py
  26. 3 5
      tests/devices/test_kogan_kawfhtp_heater.py
  27. 2 4
      tests/devices/test_moes_bht002_thermostat.py
  28. 3 5
      tests/devices/test_nedis_htpl20f_heater.py
  29. 3 4
      tests/devices/test_poolex_qline_heatpump.py
  30. 3 4
      tests/devices/test_poolex_silverline_heatpump.py
  31. 3 4
      tests/devices/test_poolex_vertigo_heatpump.py
  32. 3 4
      tests/devices/test_purline_m100_heater.py
  33. 3 4
      tests/devices/test_remora_heatpump.py
  34. 1 1
      tests/devices/test_saswell_c16_thermostat.py
  35. 3 4
      tests/devices/test_tadiran_wind_heatpump.py
  36. 2 4
      tests/devices/test_wetair_wch750_heater.py
  37. 0 5
      tests/test_device.py

+ 1 - 6
custom_components/tuya_local/device.py

@@ -9,7 +9,7 @@ from threading import Lock, Timer
 from time import time
 
 
-from homeassistant.const import CONF_HOST, CONF_NAME, UnitOfTemperature
+from homeassistant.const import CONF_HOST, CONF_NAME
 from homeassistant.core import HomeAssistant
 
 from .const import (
@@ -53,7 +53,6 @@ class TuyaLocalDevice(object):
 
         self._reset_cached_state()
 
-        self._TEMPERATURE_UNIT = UnitOfTemperature.CELSIUS
         self._hass = hass
 
         # API calls to update Tuya devices are asynchronous and non-blocking.
@@ -94,10 +93,6 @@ class TuyaLocalDevice(object):
         """Return True if the device has returned some state."""
         return len(self._get_cached_state()) > 1
 
-    @property
-    def temperature_unit(self):
-        return self._TEMPERATURE_UNIT
-
     async def async_possible_types(self):
         cached_state = self._get_cached_state()
         if len(cached_state) <= 1:

+ 2 - 2
custom_components/tuya_local/generic/climate.py

@@ -112,8 +112,8 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
             unit = validate_temp_unit(self._temperature_dps.unit)
             if unit is not None:
                 return unit
-        # Return the default unit from the device
-        return self._device.temperature_unit
+        # Return the default unit
+        return UnitOfTemperature.CELSIUS
 
     @property
     def target_temperature(self):

+ 1 - 1
custom_components/tuya_local/generic/water_heater.py

@@ -72,7 +72,7 @@ class TuyaLocalWaterHeater(TuyaLocalEntity, WaterHeaterEntity):
             if unit is not None:
                 return unit
         # Return the default unit from the device
-        return self._device.temperature_unit
+        return UnitOfTemperature.CELSIUS
 
     @property
     def current_operation(self):

+ 3 - 4
tests/devices/test_andersson_gsh_heater.py

@@ -2,6 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import GSH_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -44,10 +45,8 @@ class TestAnderssonGSHHeater(TargetTemperatureTests, TuyaDeviceTestCase):
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 2 - 4
tests/devices/test_awow_th213_thermostat.py

@@ -117,10 +117,8 @@ class TestAwowTH213Thermostat(
         self.dps[LOCK_DPS] = False
         self.assertEqual(self.basicLock.icon, "mdi:hand-back-right")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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: 2}):

+ 2 - 4
tests/devices/test_awow_th213v2_thermostat.py

@@ -124,10 +124,8 @@ class TestAwowTH213v2Thermostat(
         self.dps[LOCK_DPS] = False
         self.assertEqual(self.basicLock.icon, "mdi:hand-back-right")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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: 2}):

+ 1 - 1
tests/devices/test_beca_bht002_thermostat.py

@@ -68,7 +68,7 @@ class TestBecaBHT002Thermostat(
     def test_temperature_unit(self):
         self.assertEqual(
             self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
+            UnitOfTemperature.CELSIUS,
         )
 
     async def test_legacy_set_temperature_with_preset_mode(self):

+ 1 - 1
tests/devices/test_beca_bht6000_thermostat.py

@@ -65,7 +65,7 @@ class TestBecaBHT6000Thermostat(
     def test_temperature_unit(self):
         self.assertEqual(
             self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
+            UnitOfTemperature.CELSIUS,
         )
 
     async def test_legacy_set_temperature_with_preset_mode(self):

+ 3 - 5
tests/devices/test_betterlife_bl1500_heater.py

@@ -2,7 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
-from homeassistant.const import TIME_MINUTES
+from homeassistant.const import TIME_MINUTES, UnitOfTemperature
 
 from ..const import BETTERLIFE_BL1500_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -84,10 +84,8 @@ class TestBetterlifeBL1500Heater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 4
tests/devices/test_bwt_heatpump.py

@@ -3,6 +3,7 @@ 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
@@ -56,10 +57,8 @@ class TestBWTHeatpump(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 1 - 1
tests/devices/test_ecostrad_iqceramic_radiator.py

@@ -103,7 +103,7 @@ class TestEcostradAccentIqHeater(
     def test_temperature_unit(self):
         self.assertEqual(
             self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
+            UnitOfTemperature.CELSIUS,
         )
 
     def test_current_temperature(self):

+ 3 - 4
tests/devices/test_electriq_12wminv_heatpump.py

@@ -2,6 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import ELECTRIQ_12WMINV_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -76,10 +77,8 @@ class TestElectriq12WMINVHeatpump(
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 5
tests/devices/test_electriq_desd9lw_dehumidifier.py

@@ -3,7 +3,7 @@ from homeassistant.components.climate.const import (
     HVACMode,
 )
 from homeassistant.components.sensor import SensorDeviceClass
-from homeassistant.const import PERCENTAGE
+from homeassistant.const import PERCENTAGE, UnitOfTemperature
 
 from ..const import ELECTRIQ_DESD9LW_DEHUMIDIFIER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -80,10 +80,8 @@ class TestElectriqDESD9LWDehumidifier(
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:air-humidifier-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 21

+ 3 - 4
tests/devices/test_eurom_600_heater.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import EUROM_600_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -51,10 +52,8 @@ class TestEurom600Heater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_eurom_600v2_heater.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import EUROM_600v2_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -51,10 +52,8 @@ class TestEurom600Heater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_eurom_601_heater.py

@@ -5,6 +5,7 @@ from homeassistant.components.climate.const import (
     PRESET_COMFORT,
     PRESET_ECO,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import EUROM_601_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -57,10 +58,8 @@ class TestEurom601Heater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_eurom_saniwallheat2000_heater.py

@@ -7,6 +7,7 @@ from homeassistant.components.climate.const import (
     SWING_OFF,
     SWING_VERTICAL,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import EUROM_SANIWALLHEAT2000_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -58,10 +59,8 @@ class TestEuromSaniWallHeat2000Heater(
         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_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_eurom_walldesignheat2000_heater.py

@@ -7,6 +7,7 @@ from homeassistant.components.climate.const import (
     SWING_OFF,
     SWING_VERTICAL,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import EUROM_WALLDESIGNHEAT2000_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -58,10 +59,8 @@ class TestEuromWallDesignheat2000Heater(
         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_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 5
tests/devices/test_goldair_geco_heater.py

@@ -3,7 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
-from homeassistant.const import TIME_HOURS
+from homeassistant.const import TIME_HOURS, UnitOfTemperature
 
 from ..const import GECO_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -73,10 +73,8 @@ class TestGoldairGECOHeater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 5
tests/devices/test_goldair_gpcv_heater.py

@@ -3,7 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
-from homeassistant.const import TIME_HOURS
+from homeassistant.const import TIME_HOURS, UnitOfTemperature
 
 from ..const import GPCV_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -73,10 +73,8 @@ class TestGoldairGPCVHeater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 5
tests/devices/test_goldair_gpph_heater.py

@@ -4,7 +4,7 @@ from homeassistant.components.climate.const import (
     HVACMode,
 )
 from homeassistant.components.sensor import SensorDeviceClass
-from homeassistant.const import PERCENTAGE, TIME_MINUTES
+from homeassistant.const import PERCENTAGE, TIME_MINUTES, UnitOfTemperature
 
 from ..const import GPPH_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -103,10 +103,8 @@ class TestGoldairHeater(
         self.dps[POWERLEVEL_DPS] = "stop"
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_target_temperature_in_eco_and_af_modes(self):
         self.dps[TEMPERATURE_DPS] = 25

+ 3 - 4
tests/devices/test_hellnar_heatpump.py

@@ -2,6 +2,7 @@ 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
@@ -49,10 +50,8 @@ class TestHellnarHeatpump(TargetTemperatureTests, TuyaDeviceTestCase):
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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"

+ 3 - 5
tests/devices/test_hydrotherm_dynamicx8.py

@@ -8,6 +8,7 @@ from homeassistant.components.water_heater import (
     STATE_PERFORMANCE,
     WaterHeaterEntityFeature,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import HYDROTHERM_DYNAMICX8_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -46,11 +47,8 @@ class TestHydrothermDynamicX8(
             WaterHeaterEntityFeature.OPERATION_MODE,
         )
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DP] = 55

+ 3 - 5
tests/devices/test_kogan_kahtp_heater.py

@@ -2,7 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
-from homeassistant.const import TIME_MINUTES
+from homeassistant.const import TIME_MINUTES, UnitOfTemperature
 
 from ..const import KOGAN_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -58,10 +58,8 @@ class TestGoldairKoganKAHTPHeater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 4
tests/devices/test_kogan_kashmfp20ba_heater.py

@@ -6,6 +6,7 @@ from homeassistant.components.light import (
     ColorMode,
     LightEntityFeature,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import KOGAN_KASHMFP20BA_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -50,10 +51,8 @@ class TestKoganKASHMF20BAHeater(TargetTemperatureTests, TuyaDeviceTestCase):
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 5
tests/devices/test_kogan_kawfhtp_heater.py

@@ -2,7 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
-from homeassistant.const import TIME_MINUTES
+from homeassistant.const import TIME_MINUTES, UnitOfTemperature
 
 from ..const import KOGAN_KAWFHTP_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -61,10 +61,8 @@ class TestGoldairKoganKAHTPHeater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 2 - 4
tests/devices/test_moes_bht002_thermostat.py

@@ -4,6 +4,7 @@ from homeassistant.components.climate.const import (
     PRESET_ECO,
     PRESET_COMFORT,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import MOES_BHT002_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -51,10 +52,7 @@ class TestMoesBHT002Thermostat(
         )
 
     def test_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
-        )
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     async def test_legacy_set_temperature_with_preset_mode(self):
         async with assert_device_properties_set(

+ 3 - 5
tests/devices/test_nedis_htpl20f_heater.py

@@ -5,7 +5,7 @@ from homeassistant.components.climate.const import (
     PRESET_COMFORT,
     PRESET_ECO,
 )
-from homeassistant.const import TIME_MINUTES
+from homeassistant.const import TIME_MINUTES, UnitOfTemperature
 
 from ..const import NEDIS_HTPL20F_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -66,10 +66,8 @@ class TestNedisHtpl20fHeater(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_poolex_qline_heatpump.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import POOLEX_QLINE_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -60,10 +61,8 @@ class TestPoolexSilverlineHeatpump(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_poolex_silverline_heatpump.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import POOLEX_SILVERLINE_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -55,10 +56,8 @@ class TestPoolexSilverlineHeatpump(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 4
tests/devices/test_poolex_vertigo_heatpump.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import POOLEX_VERTIGO_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -58,10 +59,8 @@ class TestPoolexVertigoHeatpump(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 3 - 4
tests/devices/test_purline_m100_heater.py

@@ -5,6 +5,7 @@ from homeassistant.components.climate.const import (
     SWING_VERTICAL,
 )
 from homeassistant.components.light import ColorMode
+from homeassistant.const import UnitOfTemperature
 
 from ..const import PURLINE_M100_HEATER_PAYLOAD
 from ..helpers import (
@@ -71,10 +72,8 @@ class TestPulineM100Heater(
         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_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 25

+ 3 - 4
tests/devices/test_remora_heatpump.py

@@ -3,6 +3,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import REMORA_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -54,10 +55,8 @@ class TestRemoraHeatpump(
         self.dps[HVACMODE_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    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(

+ 1 - 1
tests/devices/test_saswell_c16_thermostat.py

@@ -180,7 +180,7 @@ class TestSaswellC16Thermostat(
     def test_temperature_unit(self):
         self.assertEqual(
             self.subject.temperature_unit,
-            self.subject._device.temperature_unit,
+            UnitOfTemperature.CELSIUS,
         )
 
     def test_current_temperature(self):

+ 3 - 4
tests/devices/test_tadiran_wind_heatpump.py

@@ -2,6 +2,7 @@ from homeassistant.components.climate.const import (
     ClimateEntityFeature,
     HVACMode,
 )
+from homeassistant.const import UnitOfTemperature
 
 from ..const import TADIRAN_HEATPUMP_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -49,10 +50,8 @@ class TestTadiranWindHeatpump(TargetTemperatureTests, TuyaDeviceTestCase):
         self.dps[POWER_DPS] = False
         self.assertEqual(self.subject.icon, "mdi:hvac-off")
 
-    def test_temperature_unit_returns_device_temperature_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+    def test_temperature_unit_returns_celsius(self):
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_current_temperature(self):
         self.dps[CURRENTTEMP_DPS] = 250

+ 2 - 4
tests/devices/test_wetair_wch750_heater.py

@@ -5,7 +5,7 @@ from homeassistant.components.climate.const import (
     PRESET_COMFORT,
     PRESET_BOOST,
 )
-from homeassistant.const import TIME_MINUTES
+from homeassistant.const import TIME_MINUTES, UnitOfTemperature
 
 from ..const import WETAIR_WCH750_HEATER_PAYLOAD
 from ..helpers import assert_device_properties_set
@@ -112,9 +112,7 @@ class TestWetairWCH750Heater(
         self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
 
     def test_temperatre_unit_retrns_device_temperatre_unit(self):
-        self.assertEqual(
-            self.subject.temperature_unit, self.subject._device.temperature_unit
-        )
+        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
 
     def test_target_temperature_in_af_mode(self):
         self.dps[TEMPERATURE_DPS] = 25

+ 0 - 5
tests/test_device.py

@@ -4,8 +4,6 @@ from time import sleep, time
 from unittest import IsolatedAsyncioTestCase
 from unittest.mock import AsyncMock, call, patch
 
-from homeassistant.const import UnitOfTemperature
-
 from custom_components.tuya_local.device import TuyaLocalDevice
 
 from .const import (
@@ -65,9 +63,6 @@ class TestDevice(IsolatedAsyncioTestCase):
         self.subject._cached_state = {"updated_at": 0}
         self.assertFalse(self.subject.has_returned_state)
 
-    def test_temperature_unit(self):
-        self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
-
     async def test_refreshes_state_if_no_cached_state_exists(self):
         self.subject._cached_state = {}
         self.subject.async_refresh = AsyncMock()