test_kogan_kawfpac09ya_airconditioner.py 4.5 KB

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