test_woox_r4028_powerstrip.py 2.8 KB

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