test_eurom_walldesignheat2000_heater.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. from homeassistant.components.climate.const import (
  2. HVAC_MODE_FAN_ONLY,
  3. HVAC_MODE_HEAT,
  4. HVAC_MODE_OFF,
  5. PRESET_BOOST,
  6. PRESET_COMFORT,
  7. PRESET_ECO,
  8. SUPPORT_TARGET_TEMPERATURE,
  9. SUPPORT_PRESET_MODE,
  10. SUPPORT_SWING_MODE,
  11. SWING_OFF,
  12. SWING_VERTICAL,
  13. )
  14. from homeassistant.const import STATE_UNAVAILABLE
  15. from ..const import EUROM_WALLDESIGNHEAT2000_HEATER_PAYLOAD
  16. from ..helpers import assert_device_properties_set
  17. from ..mixins.climate import TargetTemperatureTests
  18. from .base_device_tests import TuyaDeviceTestCase
  19. HVACMODE_DPS = "1"
  20. TEMPERATURE_DPS = "2"
  21. CURRENTTEMP_DPS = "3"
  22. PRESET_DPS = "4"
  23. SWING_DPS = "7"
  24. class TestEuromWallDesignheat2000Heater(
  25. TargetTemperatureTests,
  26. TuyaDeviceTestCase,
  27. ):
  28. __test__ = True
  29. def setUp(self):
  30. self.setUpForConfig(
  31. "eurom_walldesignheat2000_heater.yaml",
  32. EUROM_WALLDESIGNHEAT2000_HEATER_PAYLOAD,
  33. )
  34. self.subject = self.entities.get("climate")
  35. self.setUpTargetTemperature(
  36. TEMPERATURE_DPS,
  37. self.subject,
  38. min=10,
  39. max=35,
  40. )
  41. def test_supported_features(self):
  42. self.assertEqual(
  43. self.subject.supported_features,
  44. SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE | SUPPORT_SWING_MODE,
  45. )
  46. def test_icon(self):
  47. self.dps[HVACMODE_DPS] = False
  48. self.assertEqual(self.subject.icon, "mdi:radiator-disabled")
  49. self.dps[HVACMODE_DPS] = True
  50. self.dps[PRESET_DPS] = "auto"
  51. self.assertEqual(self.subject.icon, "mdi:radiator")
  52. self.dps[PRESET_DPS] = "off"
  53. self.assertEqual(self.subject.icon, "mdi:fan")
  54. def test_temperature_unit_returns_device_temperature_unit(self):
  55. self.assertEqual(
  56. self.subject.temperature_unit, self.subject._device.temperature_unit
  57. )
  58. def test_current_temperature(self):
  59. self.dps[CURRENTTEMP_DPS] = 25
  60. self.assertEqual(self.subject.current_temperature, 25)
  61. def test_hvac_mode(self):
  62. self.dps[HVACMODE_DPS] = True
  63. self.dps[PRESET_DPS] = "100_perc"
  64. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
  65. self.dps[PRESET_DPS] = "off"
  66. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_FAN_ONLY)
  67. self.dps[HVACMODE_DPS] = False
  68. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
  69. self.dps[HVACMODE_DPS] = None
  70. self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
  71. def test_hvac_modes(self):
  72. self.assertCountEqual(
  73. self.subject.hvac_modes,
  74. [HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_FAN_ONLY],
  75. )
  76. async def test_set_hvac_mode_to_heat(self):
  77. async with assert_device_properties_set(
  78. self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "auto"}
  79. ):
  80. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
  81. async def test_set_hvac_mode_to_fan(self):
  82. async with assert_device_properties_set(
  83. self.subject._device, {HVACMODE_DPS: True, PRESET_DPS: "off"}
  84. ):
  85. await self.subject.async_set_hvac_mode(HVAC_MODE_FAN_ONLY)
  86. async def test_turn_off(self):
  87. async with assert_device_properties_set(
  88. self.subject._device, {HVACMODE_DPS: False}
  89. ):
  90. await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
  91. def test_preset_modes(self):
  92. self.assertCountEqual(
  93. self.subject.preset_modes,
  94. [PRESET_BOOST, PRESET_COMFORT, PRESET_ECO, "fan"],
  95. )
  96. def test_preset_mode(self):
  97. self.dps[PRESET_DPS] = "off"
  98. self.assertEqual(self.subject.preset_mode, "fan")
  99. self.dps[PRESET_DPS] = "50_perc"
  100. self.assertEqual(self.subject.preset_mode, PRESET_ECO)
  101. self.dps[PRESET_DPS] = "100_perc"
  102. self.assertEqual(self.subject.preset_mode, PRESET_BOOST)
  103. self.dps[PRESET_DPS] = "auto"
  104. self.assertEqual(self.subject.preset_mode, PRESET_COMFORT)
  105. async def test_set_preset_more_to_eco(self):
  106. async with assert_device_properties_set(
  107. self.subject._device, {PRESET_DPS: "50_perc"}
  108. ):
  109. await self.subject.async_set_preset_mode(PRESET_ECO)
  110. async def test_set_preset_more_to_boost(self):
  111. async with assert_device_properties_set(
  112. self.subject._device, {PRESET_DPS: "100_perc"}
  113. ):
  114. await self.subject.async_set_preset_mode(PRESET_BOOST)
  115. async def test_set_preset_mode_to_comfort(self):
  116. async with assert_device_properties_set(
  117. self.subject._device, {PRESET_DPS: "auto"}
  118. ):
  119. await self.subject.async_set_preset_mode(PRESET_COMFORT)
  120. async def test_set_preset_mode_to_fan(self):
  121. async with assert_device_properties_set(
  122. self.subject._device, {PRESET_DPS: "off"}
  123. ):
  124. await self.subject.async_set_preset_mode("fan")
  125. def test_swing_modes(self):
  126. self.assertCountEqual(
  127. self.subject.swing_modes,
  128. [SWING_OFF, SWING_VERTICAL],
  129. )
  130. def test_swing_mode(self):
  131. self.dps[SWING_DPS] = False
  132. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  133. self.dps[SWING_DPS] = True
  134. self.assertEqual(self.subject.swing_mode, SWING_VERTICAL)
  135. async def test_set_swing_on(self):
  136. async with assert_device_properties_set(
  137. self.subject._device,
  138. {SWING_DPS: True},
  139. ):
  140. await self.subject.async_set_swing_mode(SWING_VERTICAL)
  141. async def test_set_swing_off(self):
  142. async with assert_device_properties_set(
  143. self.subject._device,
  144. {SWING_DPS: False},
  145. ):
  146. await self.subject.async_set_swing_mode(SWING_OFF)
  147. def test_extra_state_attributes(self):
  148. self.assertEqual(self.subject.extra_state_attributes, {})