test_digoo_dgsp202.py 3.3 KB

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