test_ledvance_light.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """Tests for Ledvance Panel lighting, in particular the combined settings"""
  2. from homeassistant.components.light import (
  3. ColorMode,
  4. LightEntityFeature,
  5. )
  6. from ..const import LEDVANCE_PANEL_PAYLOAD
  7. from ..helpers import assert_device_properties_set
  8. from .base_device_tests import TuyaDeviceTestCase
  9. POWER_DP = "20"
  10. COMBO_DP = "51"
  11. class TestLedvanceLight(TuyaDeviceTestCase):
  12. """
  13. Tests for Ledvance Panel lighting.
  14. """
  15. __test__ = True
  16. def setUp(self):
  17. self.setUpForConfig(
  18. "ledvance_smart_plabl100x25b.yaml",
  19. LEDVANCE_PANEL_PAYLOAD,
  20. )
  21. self.white = self.entities.get("light")
  22. self.color = self.entities.get("light_backlight")
  23. self.mark_secondary(["number_timer"])
  24. async def test_color_combined_bright(self):
  25. self.dps[COMBO_DP] = "AAcAOQPoA+gCngDI"
  26. self.assertEqual(self.color.brightness, 255)
  27. self.assertEqual(self.white.brightness, 171)
  28. async with assert_device_properties_set(
  29. self.white._device,
  30. {COMBO_DP: "AAcAOQPoA+gD6ADI"},
  31. ):
  32. await self.white.async_turn_on(brightness=255)
  33. async def test_color_combined_rgb(self):
  34. self.dps[COMBO_DP] = "AAcAOQPoA+gCngDI"
  35. self.assertSequenceEqual(self.color.hs_color, (57, 100))
  36. async with assert_device_properties_set(
  37. self.color._device,
  38. {COMBO_DP: "AAcAtAPoA+gCngDI"},
  39. ):
  40. await self.color.async_turn_on(hs_color=(180, 100))