test_wetair_wawh1210lw_humidifier.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. from homeassistant.components.humidifier import HumidifierEntityFeature
  2. from homeassistant.components.humidifier.const import (
  3. MODE_AUTO,
  4. MODE_BOOST,
  5. MODE_NORMAL,
  6. MODE_SLEEP,
  7. )
  8. from homeassistant.components.sensor import SensorDeviceClass
  9. from homeassistant.const import PERCENTAGE
  10. from ..const import WETAIR_WAWH1210_HUMIDIFIER_PAYLOAD
  11. from ..helpers import assert_device_properties_set
  12. from ..mixins.light import BasicLightTests
  13. from ..mixins.lock import BasicLockTests
  14. from ..mixins.sensor import MultiSensorTests
  15. from ..mixins.switch import MultiSwitchTests, SwitchableTests
  16. from .base_device_tests import TuyaDeviceTestCase
  17. SWITCH_DPS = "1"
  18. LIGHT_DPS = "5"
  19. SOUND_DPS = "8"
  20. HUMIDITY_DPS = "13"
  21. CURRENTHUMID_DPS = "14"
  22. UNKNOWN22_DPS = "22"
  23. PRESET_DPS = "24"
  24. IONIZER_DPS = "25"
  25. LOCK_DPS = "29"
  26. LEVEL_DPS = "101"
  27. class TestWetairWAWH1210LWHumidifier(
  28. BasicLightTests,
  29. BasicLockTests,
  30. MultiSensorTests,
  31. MultiSwitchTests,
  32. SwitchableTests,
  33. TuyaDeviceTestCase,
  34. ):
  35. __test__ = True
  36. def setUp(self):
  37. self.setUpForConfig(
  38. "wetair_wawh1210lw_humidifier.yaml", WETAIR_WAWH1210_HUMIDIFIER_PAYLOAD
  39. )
  40. self.subject = self.entities.get("humidifier_humidifier")
  41. self.setUpSwitchable(SWITCH_DPS, self.subject)
  42. self.setUpBasicLight(LIGHT_DPS, self.entities.get("light_display"))
  43. self.setUpBasicLock(LOCK_DPS, self.entities.get("lock_child_lock"))
  44. self.setUpMultiSensors(
  45. [
  46. {
  47. "dps": CURRENTHUMID_DPS,
  48. "name": "sensor_current_humidity",
  49. "device_class": SensorDeviceClass.HUMIDITY,
  50. "state_class": "measurement",
  51. "unit": PERCENTAGE,
  52. },
  53. {
  54. "dps": LEVEL_DPS,
  55. "name": "sensor_water_level",
  56. "unit": PERCENTAGE,
  57. },
  58. ]
  59. )
  60. self.setUpMultiSwitch(
  61. [
  62. {
  63. "dps": SOUND_DPS,
  64. "name": "switch_sound",
  65. },
  66. {
  67. "dps": IONIZER_DPS,
  68. "name": "switch_ionizer",
  69. },
  70. ]
  71. )
  72. self.mark_secondary(
  73. [
  74. "light_display",
  75. "lock_child_lock",
  76. "sensor_current_humidity",
  77. "sensor_water_level",
  78. "switch_sound",
  79. ]
  80. )
  81. def test_supported_features(self):
  82. self.assertEqual(self.subject.supported_features, HumidifierEntityFeature.MODES)
  83. def test_icons(self):
  84. self.dps[SWITCH_DPS] = True
  85. self.assertEqual(self.subject.icon, "mdi:air-humidifier")
  86. self.dps[SWITCH_DPS] = False
  87. self.assertEqual(self.subject.icon, "mdi:air-humidifier-off")
  88. def test_min_target_humidity(self):
  89. self.assertEqual(self.subject.min_humidity, 30)
  90. def test_max_target_humidity(self):
  91. self.assertEqual(self.subject.max_humidity, 80)
  92. def test_target_humidity(self):
  93. self.dps[HUMIDITY_DPS] = 55
  94. self.assertEqual(self.subject.target_humidity, 55)
  95. def test_available_modes(self):
  96. self.assertCountEqual(
  97. self.subject.available_modes,
  98. [MODE_AUTO, MODE_BOOST, MODE_NORMAL, MODE_SLEEP],
  99. )
  100. def test_mode(self):
  101. self.dps[PRESET_DPS] = "AUTO"
  102. self.assertEqual(self.subject.mode, MODE_AUTO)
  103. self.dps[PRESET_DPS] = "MIDDLE"
  104. self.assertEqual(self.subject.mode, MODE_NORMAL)
  105. self.dps[PRESET_DPS] = "HIGH"
  106. self.assertEqual(self.subject.mode, MODE_BOOST)
  107. self.dps[PRESET_DPS] = "SLEEP"
  108. self.assertEqual(self.subject.mode, MODE_SLEEP)
  109. async def test_set_mode_to_auto(self):
  110. async with assert_device_properties_set(
  111. self.subject._device, {PRESET_DPS: "AUTO"}
  112. ):
  113. await self.subject.async_set_mode(MODE_AUTO)
  114. async def test_set_mode_to_normal(self):
  115. async with assert_device_properties_set(
  116. self.subject._device, {PRESET_DPS: "MIDDLE"}
  117. ):
  118. await self.subject.async_set_mode(MODE_NORMAL)
  119. async def test_set_mode_to_boost(self):
  120. async with assert_device_properties_set(
  121. self.subject._device, {PRESET_DPS: "HIGH"}
  122. ):
  123. await self.subject.async_set_mode(MODE_BOOST)
  124. async def test_set_mode_to_sleep(self):
  125. async with assert_device_properties_set(
  126. self.subject._device, {PRESET_DPS: "SLEEP"}
  127. ):
  128. await self.subject.async_set_mode(MODE_SLEEP)
  129. def test_extra_state_attributes(self):
  130. self.dps[UNKNOWN22_DPS] = 22
  131. self.assertDictEqual(
  132. self.subject.extra_state_attributes,
  133. {"unknown_22": 22},
  134. )