test_essentials_purifier.py 3.7 KB

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