test_goldair_portable_airconditioner.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. from homeassistant.components.climate.const import (
  2. SWING_OFF,
  3. SWING_ON,
  4. )
  5. from ..const import GOLDAIR_PORTABLE_AIR_CONDITIONER_PAYLOAD
  6. from ..helpers import assert_device_properties_set
  7. from ..mixins.climate import TargetTemperatureTests
  8. from .base_device_tests import TuyaDeviceTestCase
  9. POWER_DP = "1"
  10. TEMPERATURE_DP = "2"
  11. CURRENT_TEMPERATURE_DP = "3"
  12. MODE_DP = "4"
  13. FANMODE_DP = "5"
  14. IONIZER_DP = "11"
  15. SWINGV_DP = "15"
  16. FAULT_DP = "20"
  17. SLEEP_DP = "103"
  18. ONTIMER_DP = "104"
  19. OFFTIMER_DP = "105"
  20. TEMPF_DP = "107"
  21. CURTEMPF_DP = "108"
  22. FEATURE_DP = "109"
  23. SWINGH_DP = "110"
  24. class TestGoldairPortableAir(TargetTemperatureTests, TuyaDeviceTestCase):
  25. __test__ = True
  26. def setUp(self):
  27. self.setUpForConfig(
  28. "goldair_portable_airconditioner.yaml",
  29. GOLDAIR_PORTABLE_AIR_CONDITIONER_PAYLOAD,
  30. )
  31. self.subject = self.entities.get("climate")
  32. self.setUpTargetTemperature(
  33. TEMPERATURE_DP,
  34. self.subject,
  35. min=16.0,
  36. max=31.0,
  37. )
  38. self.mark_secondary(
  39. [
  40. "binary_sensor_problem",
  41. "binary_sensor_tank_full",
  42. "number_on_timer",
  43. "number_off_timer",
  44. "time_on_timer",
  45. "time_off_timer",
  46. ],
  47. )
  48. def test_swing_modes_with_vswing_unavailable(self):
  49. self.dps[FEATURE_DP] = 26
  50. # config should arrange for hswing to move to swing_mode in this case
  51. self.assertCountEqual(self.subject.swing_horizontal_modes, [])
  52. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  53. def test_swing_modes_with_vswing_available(self):
  54. self.dps[FEATURE_DP] = 27
  55. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  56. self.assertCountEqual(
  57. self.subject.swing_horizontal_modes, [SWING_OFF, SWING_ON]
  58. )
  59. def test_swing(self):
  60. self.dps[FEATURE_DP] = 27
  61. self.dps[SWINGV_DP] = "on"
  62. self.dps[SWINGH_DP] = True
  63. self.assertEqual(self.subject.swing_mode, SWING_ON)
  64. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  65. self.dps[SWINGV_DP] = "off"
  66. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  67. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  68. self.dps[SWINGH_DP] = False
  69. self.assertEqual(self.subject.swing_horizontal_mode, SWING_OFF)
  70. def test_swing_with_vswing_unavailable(self):
  71. self.dps[FEATURE_DP] = 26
  72. self.dps[SWINGV_DP] = "off"
  73. self.dps[SWINGH_DP] = True
  74. self.assertEqual(self.subject.swing_mode, SWING_ON)
  75. self.dps[SWINGV_DP] = "on"
  76. self.dps[SWINGH_DP] = False
  77. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  78. async def test_set_swing_modes(self):
  79. self.dps[FEATURE_DP] = 27
  80. async with assert_device_properties_set(
  81. self.subject._device,
  82. {
  83. SWINGV_DP: "on",
  84. },
  85. ):
  86. await self.subject.async_set_swing_mode(SWING_ON)
  87. async with assert_device_properties_set(
  88. self.subject._device,
  89. {
  90. SWINGV_DP: "off",
  91. },
  92. ):
  93. await self.subject.async_set_swing_mode(SWING_OFF)
  94. async with assert_device_properties_set(
  95. self.subject._device,
  96. {
  97. SWINGH_DP: True,
  98. },
  99. ):
  100. await self.subject.async_set_swing_horizontal_mode(SWING_ON)
  101. async with assert_device_properties_set(
  102. self.subject._device,
  103. {
  104. SWINGH_DP: False,
  105. },
  106. ):
  107. await self.subject.async_set_swing_horizontal_mode(SWING_OFF)
  108. async def test_set_swing_modes_only_hswing(self):
  109. self.dps[FEATURE_DP] = 26
  110. async with assert_device_properties_set(
  111. self.subject._device,
  112. {
  113. SWINGH_DP: True,
  114. },
  115. ):
  116. await self.subject.async_set_swing_mode(SWING_ON)
  117. async with assert_device_properties_set(
  118. self.subject._device,
  119. {
  120. SWINGH_DP: False,
  121. },
  122. ):
  123. await self.subject.async_set_swing_mode(SWING_OFF)
  124. def test_available(self):
  125. """Override the base class, as this has availability logic."""
  126. pass