test_starlight_heatpump.py 5.7 KB

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