test_essentials_purifier.py 3.6 KB

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