test_kogan_kawfpac09ya_airconditioner.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. from homeassistant.components.climate.const import (
  2. HVAC_MODE_COOL,
  3. HVAC_MODE_DRY,
  4. HVAC_MODE_FAN_ONLY,
  5. HVAC_MODE_OFF,
  6. SUPPORT_FAN_MODE,
  7. SUPPORT_TARGET_TEMPERATURE,
  8. )
  9. from homeassistant.const import STATE_UNAVAILABLE, TEMP_CELSIUS, TEMP_FAHRENHEIT
  10. from ..const import KOGAN_KAWFPAC09YA_AIRCON_PAYLOAD
  11. from ..helpers import assert_device_properties_set
  12. from ..mixins.climate import TargetTemperatureTests
  13. from .base_device_tests import TuyaDeviceTestCase
  14. POWER_DPS = "1"
  15. TEMPERATURE_DPS = "2"
  16. CURRENTTEMP_DPS = "3"
  17. HVACMODE_DPS = "4"
  18. FAN_DPS = "5"
  19. UNIT_DPS = "19"
  20. COUNTDOWN_DPS = "105"
  21. UNKNOWN106_DPS = "106"
  22. UNKNOWN107_DPS = "107"
  23. class TestKoganKAWFPAC09YA(TargetTemperatureTests, TuyaDeviceTestCase):
  24. __test__ = True
  25. def setUp(self):
  26. self.setUpForConfig(
  27. "kogan_kawfpac09ya_airconditioner.yaml",
  28. KOGAN_KAWFPAC09YA_AIRCON_PAYLOAD,
  29. )
  30. self.subject = self.entities.get("climate")
  31. self.setUpTargetTemperature(
  32. TEMPERATURE_DPS,
  33. self.subject,
  34. min=16,
  35. max=30,
  36. )
  37. def test_supported_features(self):
  38. self.assertEqual(
  39. self.subject.supported_features,
  40. SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE,
  41. )
  42. def test_icon(self):
  43. self.dps[POWER_DPS] = True
  44. self.dps[HVACMODE_DPS] = "COOL"
  45. self.assertEqual(self.subject.icon, "mdi:snowflake")
  46. self.dps[HVACMODE_DPS] = "DRY"
  47. self.assertEqual(self.subject.icon, "mdi:water")
  48. self.dps[HVACMODE_DPS] = "FAN"
  49. self.assertEqual(self.subject.icon, "mdi:fan")
  50. self.dps[POWER_DPS] = False
  51. self.assertEqual(self.subject.icon, "mdi:hvac-off")
  52. def test_temperature_unit(self):
  53. self.dps[UNIT_DPS] = "C"
  54. self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
  55. self.dps[UNIT_DPS] = "F"
  56. self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
  57. def test_minimum_target_temperature_f(self):
  58. self.dps[UNIT_DPS] = "F"
  59. self.assertEqual(self.subject.min_temp, 60)
  60. def test_maximum_target_temperature_f(self):
  61. self.dps[UNIT_DPS] = "F"
  62. self.assertEqual(self.subject.max_temp, 86)
  63. def test_current_temperature(self):
  64. self.dps[CURRENTTEMP_DPS] = 25
  65. self.assertEqual(self.subject.current_temperature, 25)
  66. def test_hvac_mode(self):
  67. self.dps[POWER_DPS] = True
  68. self.dps[HVACMODE_DPS] = "COOL"
  69. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_COOL)
  70. self.dps[HVACMODE_DPS] = "DRY"
  71. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_DRY)
  72. self.dps[HVACMODE_DPS] = "FAN"
  73. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_FAN_ONLY)
  74. self.dps[HVACMODE_DPS] = None
  75. self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
  76. self.dps[HVACMODE_DPS] = "FAN"
  77. self.dps[POWER_DPS] = False
  78. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
  79. def test_hvac_modes(self):
  80. self.assertCountEqual(
  81. self.subject.hvac_modes,
  82. [
  83. HVAC_MODE_OFF,
  84. HVAC_MODE_COOL,
  85. HVAC_MODE_DRY,
  86. HVAC_MODE_FAN_ONLY,
  87. ],
  88. )
  89. async def test_turn_on(self):
  90. async with assert_device_properties_set(
  91. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "COOL"}
  92. ):
  93. await self.subject.async_set_hvac_mode(HVAC_MODE_COOL)
  94. async def test_turn_off(self):
  95. async with assert_device_properties_set(
  96. self.subject._device, {POWER_DPS: False}
  97. ):
  98. await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
  99. def test_fan_mode(self):
  100. self.dps[FAN_DPS] = "1"
  101. self.assertEqual(self.subject.fan_mode, "low")
  102. self.dps[FAN_DPS] = "2"
  103. self.assertEqual(self.subject.fan_mode, "high")
  104. def test_fan_modes(self):
  105. self.assertCountEqual(
  106. self.subject.fan_modes,
  107. [
  108. "low",
  109. "high",
  110. ],
  111. )
  112. async def test_set_fan_mode_to_low(self):
  113. async with assert_device_properties_set(
  114. self.subject._device,
  115. {FAN_DPS: "1"},
  116. ):
  117. await self.subject.async_set_fan_mode("low")
  118. async def test_set_fan_mode_to_high(self):
  119. async with assert_device_properties_set(
  120. self.subject._device,
  121. {FAN_DPS: "2"},
  122. ):
  123. await self.subject.async_set_fan_mode("high")
  124. def test_extra_state_attributes(self):
  125. self.dps[COUNTDOWN_DPS] = 105
  126. self.dps[UNKNOWN106_DPS] = 106
  127. self.dps[UNKNOWN107_DPS] = True
  128. self.assertDictEqual(
  129. self.subject.extra_state_attributes,
  130. {
  131. "countdown": 105,
  132. "unknown_106": 106,
  133. "unknown_107": True,
  134. },
  135. )