test_digoo_dgsp202.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. """Tests for Digoo DSSP202 dual switch with timers and energy monitoring"""
  2. from homeassistant.components.switch import DEVICE_CLASS_OUTLET
  3. from homeassistant.const import (
  4. DEVICE_CLASS_CURRENT,
  5. DEVICE_CLASS_POWER,
  6. DEVICE_CLASS_VOLTAGE,
  7. ELECTRIC_CURRENT_MILLIAMPERE,
  8. ELECTRIC_POTENTIAL_VOLT,
  9. POWER_WATT,
  10. TIME_MINUTES,
  11. )
  12. from ..const import DIGOO_DGSP202_SOCKET_PAYLOAD
  13. from ..mixins.number import MultiNumberTests
  14. from ..mixins.sensor import MultiSensorTests
  15. from ..mixins.switch import MultiSwitchTests
  16. from .base_device_tests import TuyaDeviceTestCase
  17. SWITCH1_DPS = "1"
  18. SWITCH2_DPS = "2"
  19. TIMER1_DPS = "9"
  20. TIMER2_DPS = "10"
  21. CURRENT_DPS = "18"
  22. POWER_DPS = "19"
  23. VOLTAGE_DPS = "20"
  24. class TestDigooDGSP202Switch(
  25. MultiNumberTests, MultiSensorTests, MultiSwitchTests, TuyaDeviceTestCase
  26. ):
  27. __test__ = True
  28. def setUp(self):
  29. self.setUpForConfig("digoo_dgsp202.yaml", DIGOO_DGSP202_SOCKET_PAYLOAD)
  30. self.setUpMultiSwitch(
  31. [
  32. {
  33. "dps": SWITCH1_DPS,
  34. "name": "switch_outlet_1",
  35. "device_class": DEVICE_CLASS_OUTLET,
  36. "power_dps": POWER_DPS,
  37. "power_scale": 10,
  38. },
  39. {
  40. "dps": SWITCH2_DPS,
  41. "name": "switch_outlet_2",
  42. "device_class": DEVICE_CLASS_OUTLET,
  43. },
  44. ]
  45. )
  46. self.setUpMultiNumber(
  47. [
  48. {
  49. "dps": TIMER1_DPS,
  50. "name": "number_timer_1",
  51. "max": 1440,
  52. "scale": 60,
  53. "unit": TIME_MINUTES,
  54. },
  55. {
  56. "dps": TIMER2_DPS,
  57. "name": "number_timer_2",
  58. "max": 1440,
  59. "scale": 60,
  60. "unit": TIME_MINUTES,
  61. },
  62. ]
  63. )
  64. self.setUpMultiSensors(
  65. [
  66. {
  67. "name": "sensor_voltage",
  68. "dps": VOLTAGE_DPS,
  69. "unit": ELECTRIC_POTENTIAL_VOLT,
  70. "device_class": DEVICE_CLASS_VOLTAGE,
  71. "state_class": "measurement",
  72. "testdata": (2300, 230.0),
  73. },
  74. {
  75. "name": "sensor_current",
  76. "dps": CURRENT_DPS,
  77. "unit": ELECTRIC_CURRENT_MILLIAMPERE,
  78. "device_class": DEVICE_CLASS_CURRENT,
  79. "state_class": "measurement",
  80. },
  81. {
  82. "name": "sensor_power",
  83. "dps": POWER_DPS,
  84. "unit": POWER_WATT,
  85. "device_class": DEVICE_CLASS_POWER,
  86. "state_class": "measurement",
  87. "testdata": (1234, 123.4),
  88. },
  89. ]
  90. )
  91. self.mark_secondary(
  92. [
  93. "number_timer_1",
  94. "number_timer_2",
  95. "sensor_voltage",
  96. "sensor_current",
  97. "sensor_power",
  98. ]
  99. )