test_goldair_portable_airconditioner.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. def setUp(self):
  26. self.setUpForConfig(
  27. "goldair_portable_airconditioner.yaml",
  28. GOLDAIR_PORTABLE_AIR_CONDITIONER_PAYLOAD,
  29. )
  30. self.subject = self.entities.get("climate")
  31. self.setUpTargetTemperature(
  32. TEMPERATURE_DP,
  33. self.subject,
  34. min=16.0,
  35. max=31.0,
  36. )
  37. self.mark_secondary(
  38. [
  39. "binary_sensor_problem",
  40. "binary_sensor_tank_full",
  41. "number_on_timer",
  42. "number_off_timer",
  43. "time_on_timer",
  44. "time_off_timer",
  45. ],
  46. )
  47. def test_swing_modes_with_vswing_unavailable(self):
  48. self.dps[FEATURE_DP] = 26
  49. # config should arrange for hswing to move to swing_mode in this case
  50. self.assertCountEqual(self.subject.swing_horizontal_modes, [])
  51. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  52. def test_swing_modes_with_vswing_available(self):
  53. self.dps[FEATURE_DP] = 27
  54. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  55. self.assertCountEqual(
  56. self.subject.swing_horizontal_modes, [SWING_OFF, SWING_ON]
  57. )
  58. def test_swing(self):
  59. self.dps[FEATURE_DP] = 27
  60. self.dps[SWINGV_DP] = "on"
  61. self.dps[SWINGH_DP] = True
  62. self.assertEqual(self.subject.swing_mode, SWING_ON)
  63. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  64. self.dps[SWINGV_DP] = "off"
  65. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  66. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  67. self.dps[SWINGH_DP] = False
  68. self.assertEqual(self.subject.swing_horizontal_mode, SWING_OFF)
  69. def test_swing_with_vswing_unavailable(self):
  70. self.dps[FEATURE_DP] = 26
  71. self.dps[SWINGV_DP] = "off"
  72. self.dps[SWINGH_DP] = True
  73. self.assertEqual(self.subject.swing_mode, SWING_ON)
  74. self.dps[SWINGV_DP] = "on"
  75. self.dps[SWINGH_DP] = False
  76. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  77. async def test_set_swing_modes(self):
  78. self.dps[FEATURE_DP] = 27
  79. async with assert_device_properties_set(
  80. self.subject._device,
  81. {
  82. SWINGV_DP: "on",
  83. },
  84. ):
  85. await self.subject.async_set_swing_mode(SWING_ON)
  86. async with assert_device_properties_set(
  87. self.subject._device,
  88. {
  89. SWINGV_DP: "off",
  90. },
  91. ):
  92. await self.subject.async_set_swing_mode(SWING_OFF)
  93. async with assert_device_properties_set(
  94. self.subject._device,
  95. {
  96. SWINGH_DP: True,
  97. },
  98. ):
  99. await self.subject.async_set_swing_horizontal_mode(SWING_ON)
  100. async with assert_device_properties_set(
  101. self.subject._device,
  102. {
  103. SWINGH_DP: False,
  104. },
  105. ):
  106. await self.subject.async_set_swing_horizontal_mode(SWING_OFF)
  107. async def test_set_swing_modes_only_hswing(self):
  108. self.dps[FEATURE_DP] = 26
  109. async with assert_device_properties_set(
  110. self.subject._device,
  111. {
  112. SWINGH_DP: True,
  113. },
  114. ):
  115. await self.subject.async_set_swing_mode(SWING_ON)
  116. async with assert_device_properties_set(
  117. self.subject._device,
  118. {
  119. SWINGH_DP: False,
  120. },
  121. ):
  122. await self.subject.async_set_swing_mode(SWING_OFF)
  123. def test_available(self):
  124. """Override the base class, as this has availability logic."""
  125. pass