Add common light helpers to test for feature support (#49199)

This commit is contained in:
Erik Montnemery 2021-04-15 20:32:27 +02:00 committed by GitHub
parent 236d274351
commit 3d90d6073e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 23 deletions

View file

@ -504,12 +504,12 @@ class LightCapabilities(AlexaEntity):
"""Yield the supported interfaces."""
yield AlexaPowerController(self.entity)
color_modes = self.entity.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES, [])
if any(mode in color_modes for mode in light.COLOR_MODES_BRIGHTNESS):
color_modes = self.entity.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES)
if light.brightness_supported(color_modes):
yield AlexaBrightnessController(self.entity)
if any(mode in color_modes for mode in light.COLOR_MODES_COLOR):
if light.color_supported(color_modes):
yield AlexaColorController(self.entity)
if light.COLOR_MODE_COLOR_TEMP in color_modes:
if light.color_temp_supported(color_modes):
yield AlexaColorTemperatureController(self.entity)
yield AlexaEndpointHealth(self.hass, self.entity)