test_wetair_wawh1210lw_humidifier.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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": LEVEL_DPS,
  48. "name": "sensor_water_level",
  49. "unit": PERCENTAGE,
  50. },
  51. ]
  52. )
  53. self.setUpMultiSwitch(
  54. [
  55. {
  56. "dps": SOUND_DPS,
  57. "name": "switch_sound",
  58. },
  59. {
  60. "dps": IONIZER_DPS,
  61. "name": "switch_ionizer",
  62. },
  63. ]
  64. )
  65. self.mark_secondary(
  66. [
  67. "light_display",
  68. "lock_child_lock",
  69. "sensor_water_level",
  70. "switch_sound",
  71. ]
  72. )
  73. def test_supported_features(self):
  74. self.assertEqual(self.subject.supported_features, HumidifierEntityFeature.MODES)
  75. def test_min_target_humidity(self):
  76. self.assertEqual(self.subject.min_humidity, 30)
  77. def test_max_target_humidity(self):
  78. self.assertEqual(self.subject.max_humidity, 80)
  79. def test_target_humidity(self):
  80. self.dps[HUMIDITY_DPS] = 55
  81. self.assertEqual(self.subject.target_humidity, 55)
  82. def test_available_modes(self):
  83. self.assertCountEqual(
  84. self.subject.available_modes,
  85. [MODE_AUTO, MODE_BOOST, MODE_NORMAL, MODE_SLEEP],
  86. )
  87. def test_mode(self):
  88. self.dps[PRESET_DPS] = "AUTO"
  89. self.assertEqual(self.subject.mode, MODE_AUTO)
  90. self.dps[PRESET_DPS] = "MIDDLE"
  91. self.assertEqual(self.subject.mode, MODE_NORMAL)
  92. self.dps[PRESET_DPS] = "HIGH"
  93. self.assertEqual(self.subject.mode, MODE_BOOST)
  94. self.dps[PRESET_DPS] = "SLEEP"
  95. self.assertEqual(self.subject.mode, MODE_SLEEP)
  96. async def test_set_mode_to_auto(self):
  97. async with assert_device_properties_set(
  98. self.subject._device, {PRESET_DPS: "AUTO"}
  99. ):
  100. await self.subject.async_set_mode(MODE_AUTO)
  101. async def test_set_mode_to_normal(self):
  102. async with assert_device_properties_set(
  103. self.subject._device, {PRESET_DPS: "MIDDLE"}
  104. ):
  105. await self.subject.async_set_mode(MODE_NORMAL)
  106. async def test_set_mode_to_boost(self):
  107. async with assert_device_properties_set(
  108. self.subject._device, {PRESET_DPS: "HIGH"}
  109. ):
  110. await self.subject.async_set_mode(MODE_BOOST)
  111. async def test_set_mode_to_sleep(self):
  112. async with assert_device_properties_set(
  113. self.subject._device, {PRESET_DPS: "SLEEP"}
  114. ):
  115. await self.subject.async_set_mode(MODE_SLEEP)
  116. def test_extra_state_attributes(self):
  117. self.dps[UNKNOWN22_DPS] = 22
  118. self.assertDictEqual(
  119. self.subject.extra_state_attributes,
  120. {"unknown_22": 22},
  121. )