test_es01_powerstrip.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. """Tests for the ES01 powerstrip."""
  2. from homeassistant.components.switch import SwitchDeviceClass
  3. from homeassistant.const import TIME_MINUTES
  4. from ..const import ES01_POWERSTRIP_PAYLOAD
  5. from ..mixins.number import MultiNumberTests
  6. from ..mixins.switch import MultiSwitchTests
  7. from .base_device_tests import TuyaDeviceTestCase
  8. SWITCH1_DPS = "1"
  9. SWITCH2_DPS = "2"
  10. SWITCH3_DPS = "3"
  11. SWITCHUSB_DPS = "4"
  12. TIMER1_DPS = "5"
  13. TIMER2_DPS = "6"
  14. TIMER3_DPS = "7"
  15. TIMERUSB_DPS = "8"
  16. class TestES01Powerstrip(
  17. MultiNumberTests,
  18. MultiSwitchTests,
  19. TuyaDeviceTestCase,
  20. ):
  21. __test__ = True
  22. def setUp(self):
  23. self.setUpForConfig("es01_powerstrip.yaml", ES01_POWERSTRIP_PAYLOAD)
  24. self.setUpMultiSwitch(
  25. [
  26. {
  27. "dps": SWITCH1_DPS,
  28. "name": "switch_switch_1",
  29. "device_class": SwitchDeviceClass.OUTLET,
  30. },
  31. {
  32. "dps": SWITCH2_DPS,
  33. "name": "switch_switch_2",
  34. "device_class": SwitchDeviceClass.OUTLET,
  35. },
  36. {
  37. "dps": SWITCH3_DPS,
  38. "name": "switch_switch_3",
  39. "device_class": SwitchDeviceClass.OUTLET,
  40. },
  41. {"dps": SWITCHUSB_DPS, "name": "switch_usb_switch"},
  42. ]
  43. )
  44. self.setUpMultiNumber(
  45. [
  46. {
  47. "dps": TIMER1_DPS,
  48. "name": "number_timer_socket_1",
  49. "max": 1440,
  50. "scale": 60,
  51. "unit": TIME_MINUTES,
  52. },
  53. {
  54. "dps": TIMER2_DPS,
  55. "name": "number_timer_socket_2",
  56. "max": 1440,
  57. "scale": 60,
  58. "unit": TIME_MINUTES,
  59. },
  60. {
  61. "dps": TIMER3_DPS,
  62. "name": "number_timer_socket_3",
  63. "max": 1440,
  64. "scale": 60,
  65. "unit": TIME_MINUTES,
  66. },
  67. {
  68. "dps": TIMERUSB_DPS,
  69. "name": "number_usb_timer",
  70. "max": 1440,
  71. "scale": 60,
  72. "unit": TIME_MINUTES,
  73. },
  74. ]
  75. )
  76. self.mark_secondary(
  77. [
  78. "number_timer_socket_1",
  79. "number_timer_socket_2",
  80. "number_timer_socket_3",
  81. "number_usb_timer",
  82. ]
  83. )