test_digoo_dgsp202.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.sensor import MultiSensorTests
  12. from ..mixins.switch import MultiSwitchTests
  13. from .base_device_tests import TuyaDeviceTestCase
  14. SWITCH1_DPS = "1"
  15. SWITCH2_DPS = "2"
  16. TIMER1_DPS = "9"
  17. TIMER2_DPS = "10"
  18. CURRENT_DPS = "18"
  19. POWER_DPS = "19"
  20. VOLTAGE_DPS = "20"
  21. class TestDigooDGSP202Switch(
  22. MultiSensorTests,
  23. MultiSwitchTests,
  24. 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.setUpMultiSensors(
  46. [
  47. {
  48. "name": "sensor_voltage",
  49. "dps": VOLTAGE_DPS,
  50. "unit": UnitOfElectricPotential.VOLT,
  51. "device_class": SensorDeviceClass.VOLTAGE,
  52. "state_class": "measurement",
  53. "testdata": (2300, 230.0),
  54. },
  55. {
  56. "name": "sensor_current",
  57. "dps": CURRENT_DPS,
  58. "unit": UnitOfElectricCurrent.MILLIAMPERE,
  59. "device_class": SensorDeviceClass.CURRENT,
  60. "state_class": "measurement",
  61. },
  62. {
  63. "name": "sensor_power",
  64. "dps": POWER_DPS,
  65. "unit": UnitOfPower.WATT,
  66. "device_class": SensorDeviceClass.POWER,
  67. "state_class": "measurement",
  68. "testdata": (1234, 123.4),
  69. },
  70. ]
  71. )
  72. self.mark_secondary(
  73. [
  74. "sensor_voltage",
  75. "sensor_current",
  76. "sensor_power",
  77. "time_timer_1",
  78. "time_timer_2",
  79. ]
  80. )