test_essentials_purifier.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. def setUp(self):
  35. self.setUpForConfig("essentials_purifier.yaml", ESSENTIALS_PURIFIER_PAYLOAD)
  36. self.setUpBasicButton(
  37. RESET_DP,
  38. self.entities.get("button_filter_reset"),
  39. )
  40. self.setUpBasicLock(LOCK_DP, self.entities.get("lock_child_lock"))
  41. self.setUpMultiSelect(
  42. [
  43. {
  44. "dps": LIGHT_DP,
  45. "name": "select_light",
  46. "options": {
  47. "Standard": "On",
  48. "Soft": "Soft",
  49. "Close": "Off",
  50. },
  51. },
  52. {
  53. "dps": TIMER_DP,
  54. "name": "select_timer",
  55. "options": {
  56. "cancel": "cancel",
  57. "2h": "2h",
  58. "4h": "4h",
  59. "8h": "8h",
  60. },
  61. },
  62. ]
  63. )
  64. self.setUpMultiSensors(
  65. [
  66. {
  67. "dps": FILTER_DP,
  68. "name": "sensor_active_filter_life",
  69. "unit": PERCENTAGE,
  70. },
  71. {
  72. "dps": COUNTDOWN_DP,
  73. "name": "sensor_time_remaining",
  74. "unit": UnitOfTime.MINUTES,
  75. "device_class": SensorDeviceClass.DURATION,
  76. },
  77. {
  78. "dps": PM25_DP,
  79. "name": "sensor_pm25",
  80. "unit": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
  81. "device_class": SensorDeviceClass.PM25,
  82. "state_class": "measurement",
  83. },
  84. {
  85. "dps": QUALITY_DP,
  86. "name": "sensor_air_quality",
  87. },
  88. ]
  89. )
  90. self.setUpMultiSwitch(
  91. [
  92. {
  93. "dps": UV_DP,
  94. "name": "switch_uv_sterilization",
  95. },
  96. ]
  97. )
  98. self.mark_secondary(
  99. [
  100. "button_filter_reset",
  101. "sensor_active_filter_life",
  102. "lock_child_lock",
  103. "select_light",
  104. "switch_uv_sterilization",
  105. "select_timer",
  106. "sensor_time_remaining",
  107. ]
  108. )