test_starlight_heatpump.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. from homeassistant.components.climate.const import ClimateEntityFeature
  2. from ..const import STARLIGHT_HEATPUMP_PAYLOAD
  3. from ..helpers import assert_device_properties_set
  4. from ..mixins.climate import TargetTemperatureTests
  5. from .base_device_tests import TuyaDeviceTestCase
  6. TEMPERATURE_DPS = "2"
  7. FLAGS_DPS = "123"
  8. class TestStarLightHeatpump(
  9. TargetTemperatureTests,
  10. TuyaDeviceTestCase,
  11. ):
  12. __test__ = True
  13. def setUp(self):
  14. self.setUpForConfig("starlight_heatpump.yaml", STARLIGHT_HEATPUMP_PAYLOAD)
  15. self.subject = self.entities["climate"]
  16. self.display_switch = self.entities.get("light_display")
  17. self.buzzer_switch = self.entities.get("switch_buzzer")
  18. self.soft_wind_switch = self.entities.get("switch_soft_wind")
  19. self.setUpTargetTemperature(
  20. TEMPERATURE_DPS,
  21. self.subject,
  22. min=16.0,
  23. max=31.0,
  24. scale=10,
  25. step=5,
  26. )
  27. self.mark_secondary(
  28. [
  29. "binary_sensor_problem",
  30. "binary_sensor_filter",
  31. "light_display",
  32. "sensor_humidity",
  33. "select_vertical_swing",
  34. "select_vertical_position",
  35. "select_horizontal_swing",
  36. "select_horizontal_position",
  37. "select_sleep_mode",
  38. "switch_buzzer",
  39. "switch_soft_wind",
  40. "switch_anti_mildew",
  41. "switch_health",
  42. "switch_anti_frost",
  43. "switch_eco_mode",
  44. ]
  45. )
  46. def test_supported_features(self):
  47. self.assertEqual(
  48. self.subject.supported_features,
  49. (
  50. ClimateEntityFeature.TARGET_TEMPERATURE
  51. | ClimateEntityFeature.FAN_MODE
  52. | ClimateEntityFeature.SWING_MODE
  53. | ClimateEntityFeature.SWING_HORIZONTAL_MODE
  54. | ClimateEntityFeature.TURN_OFF
  55. | ClimateEntityFeature.TURN_ON
  56. ),
  57. )
  58. def test_display_is_on(self):
  59. self.dps[FLAGS_DPS] = "0000"
  60. self.assertFalse(self.display_switch.is_on)
  61. self.dps[FLAGS_DPS] = "0008"
  62. self.assertTrue(self.display_switch.is_on)
  63. self.dps[FLAGS_DPS] = "8001"
  64. self.assertFalse(self.display_switch.is_on)
  65. self.dps[FLAGS_DPS] = "8009"
  66. self.assertTrue(self.display_switch.is_on)
  67. def test_buzzer_is_on(self):
  68. self.dps[FLAGS_DPS] = "0008"
  69. self.assertFalse(self.buzzer_switch.is_on)
  70. self.dps[FLAGS_DPS] = "0018"
  71. self.assertTrue(self.buzzer_switch.is_on)
  72. self.dps[FLAGS_DPS] = "8000"
  73. self.assertFalse(self.buzzer_switch.is_on)
  74. self.dps[FLAGS_DPS] = "8010"
  75. self.assertTrue(self.buzzer_switch.is_on)
  76. def test_soft_wind_is_on(self):
  77. self.dps[FLAGS_DPS] = "0000"
  78. self.assertFalse(self.soft_wind_switch.is_on)
  79. self.dps[FLAGS_DPS] = "0008"
  80. self.assertFalse(self.soft_wind_switch.is_on)
  81. self.dps[FLAGS_DPS] = "8002"
  82. self.assertTrue(self.soft_wind_switch.is_on)
  83. self.dps[FLAGS_DPS] = "8008"
  84. self.assertTrue(self.soft_wind_switch.is_on)
  85. async def test_turn_on_display(self):
  86. self.dps[FLAGS_DPS] = "0000"
  87. async with assert_device_properties_set(
  88. self.subject._device, {FLAGS_DPS: "0008"}
  89. ):
  90. await self.display_switch.async_turn_on()
  91. self.dps[FLAGS_DPS] = "8001"
  92. async with assert_device_properties_set(
  93. self.subject._device, {FLAGS_DPS: "8009"}
  94. ):
  95. await self.display_switch.async_turn_on()
  96. async def test_turn_off_display(self):
  97. self.dps[FLAGS_DPS] = "0018"
  98. async with assert_device_properties_set(
  99. self.subject._device, {FLAGS_DPS: "0010"}
  100. ):
  101. await self.display_switch.async_turn_off()
  102. self.dps[FLAGS_DPS] = "8009"
  103. async with assert_device_properties_set(
  104. self.subject._device, {FLAGS_DPS: "8001"}
  105. ):
  106. await self.display_switch.async_turn_off()
  107. async def test_turn_on_buzzer(self):
  108. self.dps[FLAGS_DPS] = "8008"
  109. async with assert_device_properties_set(
  110. self.subject._device, {FLAGS_DPS: "8018"}
  111. ):
  112. await self.buzzer_switch.async_turn_on()
  113. self.dps[FLAGS_DPS] = "0009"
  114. async with assert_device_properties_set(
  115. self.subject._device, {FLAGS_DPS: "0019"}
  116. ):
  117. await self.buzzer_switch.async_turn_on()
  118. async def test_turn_off_buzzer(self):
  119. self.dps[FLAGS_DPS] = "8018"
  120. async with assert_device_properties_set(
  121. self.subject._device, {FLAGS_DPS: "8008"}
  122. ):
  123. await self.buzzer_switch.async_turn_off()
  124. self.dps[FLAGS_DPS] = "0019"
  125. async with assert_device_properties_set(
  126. self.subject._device, {FLAGS_DPS: "0009"}
  127. ):
  128. await self.buzzer_switch.async_turn_off()
  129. async def test_turn_on_soft_wind(self):
  130. self.dps[FLAGS_DPS] = "0008"
  131. async with assert_device_properties_set(
  132. self.subject._device, {FLAGS_DPS: "8008"}
  133. ):
  134. await self.soft_wind_switch.async_turn_on()
  135. self.dps[FLAGS_DPS] = "0010"
  136. async with assert_device_properties_set(
  137. self.subject._device, {FLAGS_DPS: "8010"}
  138. ):
  139. await self.soft_wind_switch.async_turn_on()
  140. async def test_turn_off_soft_wind(self):
  141. self.dps[FLAGS_DPS] = "8008"
  142. async with assert_device_properties_set(
  143. self.subject._device, {FLAGS_DPS: "0008"}
  144. ):
  145. await self.soft_wind_switch.async_turn_off()
  146. self.dps[FLAGS_DPS] = "8011"
  147. async with assert_device_properties_set(
  148. self.subject._device, {FLAGS_DPS: "0011"}
  149. ):
  150. await self.soft_wind_switch.async_turn_off()