test_blitzwolf_bsh2_humidifier.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. from homeassistant.components.fan import FanEntityFeature
  2. from ..const import BLITZWOLF_BWSH2_PAYLOAD
  3. from ..helpers import assert_device_properties_set
  4. from ..mixins.select import MultiSelectTests
  5. from .base_device_tests import TuyaDeviceTestCase
  6. SWITCH_DP = "1"
  7. SPEED_DP = "3"
  8. LIGHT_DP = "6"
  9. TIMER_DP = "19"
  10. class TestBlitzwolfSH2Humidifier(MultiSelectTests, TuyaDeviceTestCase):
  11. __test__ = True
  12. def setUp(self):
  13. self.setUpForConfig(
  14. "blitzwolf_bwsh2_humidifier.yaml",
  15. BLITZWOLF_BWSH2_PAYLOAD,
  16. )
  17. self.subject = self.entities.get("fan")
  18. self.light = self.entities.get("light")
  19. self.setUpMultiSelect(
  20. [
  21. {
  22. "name": "select_light",
  23. "dps": LIGHT_DP,
  24. "options": {
  25. "close": "Off",
  26. "purple": "Purple",
  27. "blue": "Blue",
  28. "cyan": "Cyan",
  29. "green": "Green",
  30. "yellow": "Yellow",
  31. "orange": "Orange",
  32. "red": "Red",
  33. "colour": "Colorful",
  34. },
  35. },
  36. {
  37. "name": "select_timer",
  38. "dps": TIMER_DP,
  39. "options": {
  40. "cancel": "cancel",
  41. "2h": "2h",
  42. "4h": "4h",
  43. "6h": "6h",
  44. "8h": "8h",
  45. "10h": "10h",
  46. "12h": "12h",
  47. },
  48. },
  49. ]
  50. )
  51. self.mark_secondary(["select_light", "select_timer"])
  52. def test_supported_features(self):
  53. self.assertEqual(
  54. self.subject.supported_features,
  55. FanEntityFeature.SET_SPEED
  56. | FanEntityFeature.TURN_OFF
  57. | FanEntityFeature.TURN_ON,
  58. )
  59. def test_speed(self):
  60. self.dps[SPEED_DP] = "sleep"
  61. self.assertEqual(self.subject.percentage, 10)
  62. self.dps[SPEED_DP] = "grade1"
  63. self.assertEqual(self.subject.percentage, 25)
  64. self.dps[SPEED_DP] = "grade2"
  65. self.assertEqual(self.subject.percentage, 40)
  66. self.dps[SPEED_DP] = "grade3"
  67. self.assertEqual(self.subject.percentage, 55)
  68. self.dps[SPEED_DP] = "grade4"
  69. self.assertEqual(self.subject.percentage, 70)
  70. self.dps[SPEED_DP] = "grade5"
  71. self.assertEqual(self.subject.percentage, 85)
  72. self.dps[SPEED_DP] = "grade6"
  73. self.assertEqual(self.subject.percentage, 100)
  74. async def test_set_speed_snaps(self):
  75. async with assert_device_properties_set(
  76. self.subject._device,
  77. {SPEED_DP: "grade3"},
  78. ):
  79. await self.subject.async_set_percentage(50)
  80. def test_light_named_color(self):
  81. self.dps[LIGHT_DP] = "colour"
  82. self.assertEqual(self.light.hs_color, (0, 0))
  83. self.dps[LIGHT_DP] = "red"
  84. self.assertEqual(self.light.hs_color, (0, 100))
  85. async def test_async_set_light_color(self):
  86. self.dps[LIGHT_DP] = "red"
  87. async with assert_device_properties_set(
  88. self.light._device,
  89. {LIGHT_DP: "green"},
  90. ):
  91. await self.light.async_turn_on(hs_color=(120, 100))
  92. async def test_async_light_turn_off(self):
  93. async with assert_device_properties_set(
  94. self.light._device,
  95. {LIGHT_DP: "close"},
  96. ):
  97. await self.light.async_turn_off()
  98. async def test_async_light_turn_on(self):
  99. async with assert_device_properties_set(
  100. self.light._device,
  101. {LIGHT_DP: "colour"},
  102. ):
  103. await self.light.async_turn_on()