test_starlight_heatpump.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.TURN_OFF
  54. | ClimateEntityFeature.TURN_ON
  55. ),
  56. )
  57. def test_display_is_on(self):
  58. self.dps[FLAGS_DPS] = "0000"
  59. self.assertFalse(self.display_switch.is_on)
  60. self.dps[FLAGS_DPS] = "0008"
  61. self.assertTrue(self.display_switch.is_on)
  62. self.dps[FLAGS_DPS] = "8001"
  63. self.assertFalse(self.display_switch.is_on)
  64. self.dps[FLAGS_DPS] = "8009"
  65. self.assertTrue(self.display_switch.is_on)
  66. def test_buzzer_is_on(self):
  67. self.dps[FLAGS_DPS] = "0008"
  68. self.assertFalse(self.buzzer_switch.is_on)
  69. self.dps[FLAGS_DPS] = "0018"
  70. self.assertTrue(self.buzzer_switch.is_on)
  71. self.dps[FLAGS_DPS] = "8000"
  72. self.assertFalse(self.buzzer_switch.is_on)
  73. self.dps[FLAGS_DPS] = "8010"
  74. self.assertTrue(self.buzzer_switch.is_on)
  75. def test_soft_wind_is_on(self):
  76. self.dps[FLAGS_DPS] = "0000"
  77. self.assertFalse(self.soft_wind_switch.is_on)
  78. self.dps[FLAGS_DPS] = "0008"
  79. self.assertFalse(self.soft_wind_switch.is_on)
  80. self.dps[FLAGS_DPS] = "8002"
  81. self.assertTrue(self.soft_wind_switch.is_on)
  82. self.dps[FLAGS_DPS] = "8008"
  83. self.assertTrue(self.soft_wind_switch.is_on)
  84. async def test_turn_on_display(self):
  85. self.dps[FLAGS_DPS] = "0000"
  86. async with assert_device_properties_set(
  87. self.subject._device, {FLAGS_DPS: "0008"}
  88. ):
  89. await self.display_switch.async_turn_on()
  90. self.dps[FLAGS_DPS] = "8001"
  91. async with assert_device_properties_set(
  92. self.subject._device, {FLAGS_DPS: "8009"}
  93. ):
  94. await self.display_switch.async_turn_on()
  95. async def test_turn_off_display(self):
  96. self.dps[FLAGS_DPS] = "0018"
  97. async with assert_device_properties_set(
  98. self.subject._device, {FLAGS_DPS: "0010"}
  99. ):
  100. await self.display_switch.async_turn_off()
  101. self.dps[FLAGS_DPS] = "8009"
  102. async with assert_device_properties_set(
  103. self.subject._device, {FLAGS_DPS: "8001"}
  104. ):
  105. await self.display_switch.async_turn_off()
  106. async def test_turn_on_buzzer(self):
  107. self.dps[FLAGS_DPS] = "8008"
  108. async with assert_device_properties_set(
  109. self.subject._device, {FLAGS_DPS: "8018"}
  110. ):
  111. await self.buzzer_switch.async_turn_on()
  112. self.dps[FLAGS_DPS] = "0009"
  113. async with assert_device_properties_set(
  114. self.subject._device, {FLAGS_DPS: "0019"}
  115. ):
  116. await self.buzzer_switch.async_turn_on()
  117. async def test_turn_off_buzzer(self):
  118. self.dps[FLAGS_DPS] = "8018"
  119. async with assert_device_properties_set(
  120. self.subject._device, {FLAGS_DPS: "8008"}
  121. ):
  122. await self.buzzer_switch.async_turn_off()
  123. self.dps[FLAGS_DPS] = "0019"
  124. async with assert_device_properties_set(
  125. self.subject._device, {FLAGS_DPS: "0009"}
  126. ):
  127. await self.buzzer_switch.async_turn_off()
  128. async def test_turn_on_soft_wind(self):
  129. self.dps[FLAGS_DPS] = "0008"
  130. async with assert_device_properties_set(
  131. self.subject._device, {FLAGS_DPS: "8008"}
  132. ):
  133. await self.soft_wind_switch.async_turn_on()
  134. self.dps[FLAGS_DPS] = "0010"
  135. async with assert_device_properties_set(
  136. self.subject._device, {FLAGS_DPS: "8010"}
  137. ):
  138. await self.soft_wind_switch.async_turn_on()
  139. async def test_turn_off_soft_wind(self):
  140. self.dps[FLAGS_DPS] = "8008"
  141. async with assert_device_properties_set(
  142. self.subject._device, {FLAGS_DPS: "0008"}
  143. ):
  144. await self.soft_wind_switch.async_turn_off()
  145. self.dps[FLAGS_DPS] = "8011"
  146. async with assert_device_properties_set(
  147. self.subject._device, {FLAGS_DPS: "0011"}
  148. ):
  149. await self.soft_wind_switch.async_turn_off()