test_digoo_dgsp202.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. )
  9. from ..const import DIGOO_DGSP202_SOCKET_PAYLOAD
  10. from ..mixins.sensor import MultiSensorTests
  11. from ..mixins.switch import MultiSwitchTests
  12. from .base_device_tests import TuyaDeviceTestCase
  13. SWITCH1_DPS = "1"
  14. SWITCH2_DPS = "2"
  15. TIMER1_DPS = "9"
  16. TIMER2_DPS = "10"
  17. CURRENT_DPS = "18"
  18. POWER_DPS = "19"
  19. VOLTAGE_DPS = "20"
  20. class TestDigooDGSP202Switch(
  21. MultiSensorTests,
  22. MultiSwitchTests,
  23. TuyaDeviceTestCase,
  24. ):
  25. def setUp(self):
  26. self.setUpForConfig("digoo_dgsp202.yaml", DIGOO_DGSP202_SOCKET_PAYLOAD)
  27. self.setUpMultiSwitch(
  28. [
  29. {
  30. "dps": SWITCH1_DPS,
  31. "name": "switch_outlet_1",
  32. "device_class": SwitchDeviceClass.OUTLET,
  33. "power_dps": POWER_DPS,
  34. "power_scale": 10,
  35. },
  36. {
  37. "dps": SWITCH2_DPS,
  38. "name": "switch_outlet_2",
  39. "device_class": SwitchDeviceClass.OUTLET,
  40. },
  41. ]
  42. )
  43. self.setUpMultiSensors(
  44. [
  45. {
  46. "name": "sensor_voltage",
  47. "dps": VOLTAGE_DPS,
  48. "unit": UnitOfElectricPotential.VOLT,
  49. "device_class": SensorDeviceClass.VOLTAGE,
  50. "state_class": "measurement",
  51. "testdata": (2300, 230.0),
  52. },
  53. {
  54. "name": "sensor_current",
  55. "dps": CURRENT_DPS,
  56. "unit": UnitOfElectricCurrent.MILLIAMPERE,
  57. "device_class": SensorDeviceClass.CURRENT,
  58. "state_class": "measurement",
  59. },
  60. {
  61. "name": "sensor_power",
  62. "dps": POWER_DPS,
  63. "unit": UnitOfPower.WATT,
  64. "device_class": SensorDeviceClass.POWER,
  65. "state_class": "measurement",
  66. "testdata": (1234, 123.4),
  67. },
  68. ]
  69. )
  70. self.mark_secondary(
  71. [
  72. "sensor_voltage",
  73. "sensor_current",
  74. "sensor_power",
  75. "time_timer_1",
  76. "time_timer_2",
  77. ]
  78. )