test_essentials_purifier.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. """Tests for the essentials air purifier."""
  2. from homeassistant.components.button import ButtonDeviceClass
  3. from homeassistant.components.sensor import SensorDeviceClass
  4. from homeassistant.const import (
  5. CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
  6. PERCENTAGE,
  7. UnitOfTime,
  8. )
  9. from ..const import ESSENTIALS_PURIFIER_PAYLOAD
  10. from ..mixins.button import BasicButtonTests
  11. from ..mixins.lock import BasicLockTests
  12. from ..mixins.select import MultiSelectTests
  13. from ..mixins.sensor import MultiSensorTests
  14. from ..mixins.switch import MultiSwitchTests
  15. from .base_device_tests import TuyaDeviceTestCase
  16. SWITCH_DP = "1"
  17. PM25_DP = "2"
  18. MODE_DP = "3"
  19. FILTER_DP = "5"
  20. LOCK_DP = "7"
  21. UV_DP = "9"
  22. RESET_DP = "11"
  23. TIMER_DP = "18"
  24. COUNTDOWN_DP = "19"
  25. QUALITY_DP = "21"
  26. LIGHT_DP = "101"
  27. class TestEssentialsPurifier(
  28. BasicButtonTests,
  29. BasicLockTests,
  30. MultiSelectTests,
  31. MultiSensorTests,
  32. MultiSwitchTests,
  33. TuyaDeviceTestCase,
  34. ):
  35. __test__ = True
  36. def setUp(self):
  37. self.setUpForConfig("essentials_purifier.yaml", ESSENTIALS_PURIFIER_PAYLOAD)
  38. self.setUpBasicButton(
  39. RESET_DP,
  40. self.entities.get("button_filter_reset"),
  41. ButtonDeviceClass.RESTART,
  42. )
  43. self.setUpBasicLock(LOCK_DP, self.entities.get("lock_child_lock"))
  44. self.setUpMultiSelect(
  45. [
  46. {
  47. "dps": LIGHT_DP,
  48. "name": "select_light",
  49. "options": {
  50. "Standard": "On",
  51. "Soft": "Soft",
  52. "Close": "Off",
  53. },
  54. },
  55. {
  56. "dps": TIMER_DP,
  57. "name": "select_timer",
  58. "options": {
  59. "cancel": "Off",
  60. "2h": "2 hours",
  61. "4h": "4 hours",
  62. "8h": "8 hours",
  63. },
  64. },
  65. {
  66. "dps": MODE_DP,
  67. "name": "select_mode",
  68. "options": {
  69. "auto": "Auto",
  70. "M": "Medium",
  71. "H": "High",
  72. "sleep": "Sleep",
  73. },
  74. },
  75. ]
  76. )
  77. self.setUpMultiSensors(
  78. [
  79. {
  80. "dps": FILTER_DP,
  81. "name": "sensor_active_filter_life",
  82. "unit": PERCENTAGE,
  83. },
  84. {
  85. "dps": COUNTDOWN_DP,
  86. "name": "sensor_timer",
  87. "unit": UnitOfTime.MINUTES,
  88. },
  89. {
  90. "dps": PM25_DP,
  91. "name": "sensor_pm2_5",
  92. "unit": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
  93. "device_class": SensorDeviceClass.PM25,
  94. "state_class": "measurement",
  95. },
  96. {
  97. "dps": QUALITY_DP,
  98. "name": "sensor_air_quality",
  99. },
  100. ]
  101. )
  102. self.setUpMultiSwitch(
  103. [
  104. {
  105. "dps": SWITCH_DP,
  106. "name": "switch",
  107. },
  108. {
  109. "dps": UV_DP,
  110. "name": "switch_uv_disinfection",
  111. },
  112. {
  113. "dps": RESET_DP,
  114. "name": "switch_filter_reset",
  115. },
  116. ]
  117. )
  118. self.mark_secondary(
  119. [
  120. "button_filter_reset",
  121. "sensor_active_filter_life",
  122. "lock_child_lock",
  123. "select_light",
  124. "switch_uv_disinfection",
  125. "switch_filter_reset",
  126. "select_timer",
  127. "sensor_timer",
  128. ]
  129. )