test_starlight_heatpump.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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("switch_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. "sensor_current_humidity",
  30. "select_vertical_swing",
  31. "select_vertical_position",
  32. "select_horizontal_swing",
  33. "select_horizontal_position",
  34. "select_sleep_mode",
  35. "switch_display",
  36. "switch_buzzer",
  37. "switch_soft_wind",
  38. "switch_anti_mildew",
  39. "switch_health",
  40. "switch_anti_freeze",
  41. "switch_eco_mode",
  42. ]
  43. )
  44. def test_supported_features(self):
  45. self.assertEqual(
  46. self.subject.supported_features,
  47. (
  48. ClimateEntityFeature.TARGET_TEMPERATURE
  49. | ClimateEntityFeature.FAN_MODE
  50. | ClimateEntityFeature.SWING_MODE
  51. ),
  52. )
  53. def test_display_is_on(self):
  54. self.dps[FLAGS_DPS] = "0000"
  55. self.assertFalse(self.display_switch.is_on)
  56. self.dps[FLAGS_DPS] = "0008"
  57. self.assertTrue(self.display_switch.is_on)
  58. self.dps[FLAGS_DPS] = "8001"
  59. self.assertFalse(self.display_switch.is_on)
  60. self.dps[FLAGS_DPS] = "8009"
  61. self.assertTrue(self.display_switch.is_on)
  62. def test_buzzer_is_on(self):
  63. self.dps[FLAGS_DPS] = "0008"
  64. self.assertFalse(self.buzzer_switch.is_on)
  65. self.dps[FLAGS_DPS] = "0018"
  66. self.assertTrue(self.buzzer_switch.is_on)
  67. self.dps[FLAGS_DPS] = "8000"
  68. self.assertFalse(self.buzzer_switch.is_on)
  69. self.dps[FLAGS_DPS] = "8010"
  70. self.assertTrue(self.buzzer_switch.is_on)
  71. def test_soft_wind_is_on(self):
  72. self.dps[FLAGS_DPS] = "0000"
  73. self.assertFalse(self.soft_wind_switch.is_on)
  74. self.dps[FLAGS_DPS] = "0008"
  75. self.assertFalse(self.soft_wind_switch.is_on)
  76. self.dps[FLAGS_DPS] = "8002"
  77. self.assertTrue(self.soft_wind_switch.is_on)
  78. self.dps[FLAGS_DPS] = "8008"
  79. self.assertTrue(self.soft_wind_switch.is_on)
  80. async def test_turn_on_display(self):
  81. self.dps[FLAGS_DPS] = "0000"
  82. async with assert_device_properties_set(
  83. self.subject._device, {FLAGS_DPS: "0008"}
  84. ):
  85. await self.display_switch.async_turn_on()
  86. self.dps[FLAGS_DPS] = "8001"
  87. async with assert_device_properties_set(
  88. self.subject._device, {FLAGS_DPS: "8009"}
  89. ):
  90. await self.display_switch.async_turn_on()
  91. async def test_turn_off_display(self):
  92. self.dps[FLAGS_DPS] = "0018"
  93. async with assert_device_properties_set(
  94. self.subject._device, {FLAGS_DPS: "0010"}
  95. ):
  96. await self.display_switch.async_turn_off()
  97. self.dps[FLAGS_DPS] = "8009"
  98. async with assert_device_properties_set(
  99. self.subject._device, {FLAGS_DPS: "8001"}
  100. ):
  101. await self.display_switch.async_turn_off()
  102. async def test_turn_on_buzzer(self):
  103. self.dps[FLAGS_DPS] = "8008"
  104. async with assert_device_properties_set(
  105. self.subject._device, {FLAGS_DPS: "8018"}
  106. ):
  107. await self.buzzer_switch.async_turn_on()
  108. self.dps[FLAGS_DPS] = "0009"
  109. async with assert_device_properties_set(
  110. self.subject._device, {FLAGS_DPS: "0019"}
  111. ):
  112. await self.buzzer_switch.async_turn_on()
  113. async def test_turn_off_buzzer(self):
  114. self.dps[FLAGS_DPS] = "8018"
  115. async with assert_device_properties_set(
  116. self.subject._device, {FLAGS_DPS: "8008"}
  117. ):
  118. await self.buzzer_switch.async_turn_off()
  119. self.dps[FLAGS_DPS] = "0019"
  120. async with assert_device_properties_set(
  121. self.subject._device, {FLAGS_DPS: "0009"}
  122. ):
  123. await self.buzzer_switch.async_turn_off()
  124. async def test_turn_on_soft_wind(self):
  125. self.dps[FLAGS_DPS] = "0008"
  126. async with assert_device_properties_set(
  127. self.subject._device, {FLAGS_DPS: "8008"}
  128. ):
  129. await self.soft_wind_switch.async_turn_on()
  130. self.dps[FLAGS_DPS] = "0010"
  131. async with assert_device_properties_set(
  132. self.subject._device, {FLAGS_DPS: "8010"}
  133. ):
  134. await self.soft_wind_switch.async_turn_on()
  135. async def test_turn_off_soft_wind(self):
  136. self.dps[FLAGS_DPS] = "8008"
  137. async with assert_device_properties_set(
  138. self.subject._device, {FLAGS_DPS: "0008"}
  139. ):
  140. await self.soft_wind_switch.async_turn_off()
  141. self.dps[FLAGS_DPS] = "8011"
  142. async with assert_device_properties_set(
  143. self.subject._device, {FLAGS_DPS: "0011"}
  144. ):
  145. await self.soft_wind_switch.async_turn_off()