test_digoo_dgsp202.py 3.5 KB

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