mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Use ZCL mandatory attribute to determine ZHA light capabilities (#9232)
The manadatory ColorCapabilities attribute should indicate whether a light is capable of XY color changes and/or color temperature.
This commit is contained in:
parent
bb37294047
commit
e22ec28bce
@ -27,8 +27,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
|
|
||||||
endpoint = discovery_info['endpoint']
|
endpoint = discovery_info['endpoint']
|
||||||
try:
|
try:
|
||||||
primaries = yield from endpoint.light_color['num_primaries']
|
discovery_info['color_capabilities'] \
|
||||||
discovery_info['num_primaries'] = primaries
|
= yield from endpoint.light_color['color_capabilities']
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -54,11 +54,11 @@ class Light(zha.Entity, light.Light):
|
|||||||
self._supported_features |= light.SUPPORT_TRANSITION
|
self._supported_features |= light.SUPPORT_TRANSITION
|
||||||
self._brightness = 0
|
self._brightness = 0
|
||||||
if zcl_clusters.lighting.Color.cluster_id in self._in_clusters:
|
if zcl_clusters.lighting.Color.cluster_id in self._in_clusters:
|
||||||
# Not sure all color lights necessarily support this directly
|
color_capabilities = kwargs.get('color_capabilities', 0x10)
|
||||||
# Should we emulate it?
|
if color_capabilities & 0x10:
|
||||||
self._supported_features |= light.SUPPORT_COLOR_TEMP
|
self._supported_features |= light.SUPPORT_COLOR_TEMP
|
||||||
# Silly heuristic, not sure if it works widely
|
|
||||||
if kwargs.get('num_primaries', 1) >= 3:
|
if color_capabilities & 0x08:
|
||||||
self._supported_features |= light.SUPPORT_XY_COLOR
|
self._supported_features |= light.SUPPORT_XY_COLOR
|
||||||
self._supported_features |= light.SUPPORT_RGB_COLOR
|
self._supported_features |= light.SUPPORT_RGB_COLOR
|
||||||
self._xy_color = (1.0, 1.0)
|
self._xy_color = (1.0, 1.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user