test_digoo_dgsp202.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. __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.setUpMultiSensors(
  45. [
  46. {
  47. "name": "sensor_voltage",
  48. "dps": VOLTAGE_DPS,
  49. "unit": UnitOfElectricPotential.VOLT,
  50. "device_class": SensorDeviceClass.VOLTAGE,
  51. "state_class": "measurement",
  52. "testdata": (2300, 230.0),
  53. },
  54. {
  55. "name": "sensor_current",
  56. "dps": CURRENT_DPS,
  57. "unit": UnitOfElectricCurrent.MILLIAMPERE,
  58. "device_class": SensorDeviceClass.CURRENT,
  59. "state_class": "measurement",
  60. },
  61. {
  62. "name": "sensor_power",
  63. "dps": POWER_DPS,
  64. "unit": UnitOfPower.WATT,
  65. "device_class": SensorDeviceClass.POWER,
  66. "state_class": "measurement",
  67. "testdata": (1234, 123.4),
  68. },
  69. ]
  70. )
  71. self.mark_secondary(
  72. [
  73. "sensor_voltage",
  74. "sensor_current",
  75. "sensor_power",
  76. "time_timer_1",
  77. "time_timer_2",
  78. ]
  79. )