test_woox_r4028_powerstrip.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. """Tests for the Woox R4028 powerstrip."""
  2. from homeassistant.components.number import NumberDeviceClass
  3. from homeassistant.components.switch import SwitchDeviceClass
  4. from homeassistant.const import UnitOfTime
  5. from ..const import WOOX_R4028_SOCKET_PAYLOAD
  6. from ..mixins.number import MultiNumberTests
  7. from ..mixins.switch import MultiSwitchTests
  8. from .base_device_tests import TuyaDeviceTestCase
  9. SWITCH1_DPS = "1"
  10. SWITCH2_DPS = "2"
  11. SWITCH3_DPS = "3"
  12. SWITCHUSB_DPS = "7"
  13. TIMER1_DPS = "101"
  14. TIMER2_DPS = "102"
  15. TIMER3_DPS = "103"
  16. TIMERUSB_DPS = "105"
  17. class TestWooxR4028Powerstrip(
  18. MultiNumberTests,
  19. MultiSwitchTests,
  20. TuyaDeviceTestCase,
  21. ):
  22. __test__ = True
  23. def setUp(self):
  24. self.setUpForConfig("woox_r4028_powerstrip.yaml", WOOX_R4028_SOCKET_PAYLOAD)
  25. self.setUpMultiSwitch(
  26. [
  27. {
  28. "dps": SWITCH1_DPS,
  29. "name": "switch_outlet_1",
  30. "device_class": SwitchDeviceClass.OUTLET,
  31. },
  32. {
  33. "dps": SWITCH2_DPS,
  34. "name": "switch_outlet_2",
  35. "device_class": SwitchDeviceClass.OUTLET,
  36. },
  37. {
  38. "dps": SWITCH3_DPS,
  39. "name": "switch_outlet_3",
  40. "device_class": SwitchDeviceClass.OUTLET,
  41. },
  42. {
  43. "dps": SWITCHUSB_DPS,
  44. "name": "switch_usb_switch",
  45. "device_class": SwitchDeviceClass.SWITCH,
  46. },
  47. ]
  48. )
  49. self.setUpMultiNumber(
  50. [
  51. {
  52. "dps": TIMER1_DPS,
  53. "name": "number_timer_1",
  54. "max": 1440,
  55. "scale": 60,
  56. "unit": UnitOfTime.MINUTES,
  57. "device_class": NumberDeviceClass.DURATION,
  58. },
  59. {
  60. "dps": TIMER2_DPS,
  61. "name": "number_timer_2",
  62. "max": 1440,
  63. "scale": 60,
  64. "unit": UnitOfTime.MINUTES,
  65. "device_class": NumberDeviceClass.DURATION,
  66. },
  67. {
  68. "dps": TIMER3_DPS,
  69. "name": "number_timer_3",
  70. "max": 1440,
  71. "scale": 60,
  72. "unit": UnitOfTime.MINUTES,
  73. "device_class": NumberDeviceClass.DURATION,
  74. },
  75. {
  76. "dps": TIMERUSB_DPS,
  77. "name": "number_usb_timer",
  78. "max": 1440,
  79. "scale": 60,
  80. "unit": UnitOfTime.MINUTES,
  81. "device_class": NumberDeviceClass.DURATION,
  82. },
  83. ]
  84. )
  85. self.mark_secondary(
  86. [
  87. "number_timer_1",
  88. "number_timer_2",
  89. "number_timer_3",
  90. "number_usb_timer",
  91. "time_timer_1",
  92. "time_timer_2",
  93. "time_timer_3",
  94. "time_timer_usb",
  95. ]
  96. )