test_essentials_purifier.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. )
  65. self.setUpMultiSensors(
  66. [
  67. {
  68. "dps": FILTER_DP,
  69. "name": "sensor_active_filter_life",
  70. "unit": PERCENTAGE,
  71. },
  72. {
  73. "dps": COUNTDOWN_DP,
  74. "name": "sensor_time_remaining",
  75. "unit": UnitOfTime.MINUTES,
  76. "device_class": SensorDeviceClass.DURATION,
  77. },
  78. {
  79. "dps": PM25_DP,
  80. "name": "sensor_pm25",
  81. "unit": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
  82. "device_class": SensorDeviceClass.PM25,
  83. "state_class": "measurement",
  84. },
  85. {
  86. "dps": QUALITY_DP,
  87. "name": "sensor_air_quality",
  88. },
  89. ]
  90. )
  91. self.setUpMultiSwitch(
  92. [
  93. {
  94. "dps": UV_DP,
  95. "name": "switch_uv_sterilization",
  96. },
  97. ]
  98. )
  99. self.mark_secondary(
  100. [
  101. "button_filter_reset",
  102. "sensor_active_filter_life",
  103. "lock_child_lock",
  104. "select_light",
  105. "switch_uv_sterilization",
  106. "select_timer",
  107. "sensor_time_remaining",
  108. ]
  109. )