test_wetair_wawh1210lw_humidifier.py 4.3 KB

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