test_kogan_kawfpac09ya_airconditioner.py 4.4 KB

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