Some small fixes for the Matter light platform (#95343)
parent
cb22fb16f8
commit
30fcfaf1ec
|
@ -220,7 +220,7 @@ class MatterLight(MatterEntity, LightEntity):
|
|||
return round(
|
||||
renormalize(
|
||||
level_control.currentLevel,
|
||||
(level_control.minLevel, level_control.maxLevel),
|
||||
(level_control.minLevel or 0, level_control.maxLevel or 254),
|
||||
(0, 255),
|
||||
)
|
||||
)
|
||||
|
@ -299,6 +299,8 @@ class MatterLight(MatterEntity, LightEntity):
|
|||
# colormode(s)
|
||||
if self._entity_info.endpoint.has_attribute(
|
||||
None, clusters.ColorControl.Attributes.ColorMode
|
||||
) and self._entity_info.endpoint.has_attribute(
|
||||
None, clusters.ColorControl.Attributes.ColorCapabilities
|
||||
):
|
||||
capabilities = self.get_matter_attribute_value(
|
||||
clusters.ColorControl.Attributes.ColorCapabilities
|
||||
|
@ -375,4 +377,84 @@ DISCOVERY_SCHEMAS = [
|
|||
device_types.OnOffLight,
|
||||
),
|
||||
),
|
||||
# Additional schema to match (HS Color) lights with incorrect/missing device type
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.LIGHT,
|
||||
entity_description=LightEntityDescription(key="MatterHSColorLightFallback"),
|
||||
entity_class=MatterLight,
|
||||
required_attributes=(
|
||||
clusters.OnOff.Attributes.OnOff,
|
||||
clusters.LevelControl.Attributes.CurrentLevel,
|
||||
clusters.ColorControl.Attributes.CurrentHue,
|
||||
clusters.ColorControl.Attributes.CurrentSaturation,
|
||||
),
|
||||
optional_attributes=(
|
||||
clusters.ColorControl.Attributes.ColorTemperatureMireds,
|
||||
clusters.ColorControl.Attributes.ColorMode,
|
||||
clusters.ColorControl.Attributes.CurrentX,
|
||||
clusters.ColorControl.Attributes.CurrentY,
|
||||
),
|
||||
),
|
||||
# Additional schema to match (XY Color) lights with incorrect/missing device type
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.LIGHT,
|
||||
entity_description=LightEntityDescription(key="MatterXYColorLightFallback"),
|
||||
entity_class=MatterLight,
|
||||
required_attributes=(
|
||||
clusters.OnOff.Attributes.OnOff,
|
||||
clusters.LevelControl.Attributes.CurrentLevel,
|
||||
clusters.ColorControl.Attributes.CurrentX,
|
||||
clusters.ColorControl.Attributes.CurrentY,
|
||||
),
|
||||
optional_attributes=(
|
||||
clusters.ColorControl.Attributes.ColorTemperatureMireds,
|
||||
clusters.ColorControl.Attributes.ColorMode,
|
||||
clusters.ColorControl.Attributes.CurrentHue,
|
||||
clusters.ColorControl.Attributes.CurrentSaturation,
|
||||
),
|
||||
),
|
||||
# Additional schema to match (color temperature) lights with incorrect/missing device type
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.LIGHT,
|
||||
entity_description=LightEntityDescription(
|
||||
key="MatterColorTemperatureLightFallback"
|
||||
),
|
||||
entity_class=MatterLight,
|
||||
required_attributes=(
|
||||
clusters.OnOff.Attributes.OnOff,
|
||||
clusters.LevelControl.Attributes.CurrentLevel,
|
||||
clusters.ColorControl.Attributes.ColorTemperatureMireds,
|
||||
),
|
||||
optional_attributes=(clusters.ColorControl.Attributes.ColorMode,),
|
||||
),
|
||||
# Additional schema to match generic dimmable lights with incorrect/missing device type
|
||||
MatterDiscoverySchema(
|
||||
platform=Platform.LIGHT,
|
||||
entity_description=LightEntityDescription(key="MatterDimmableLightFallback"),
|
||||
entity_class=MatterLight,
|
||||
required_attributes=(
|
||||
clusters.OnOff.Attributes.OnOff,
|
||||
clusters.LevelControl.Attributes.CurrentLevel,
|
||||
),
|
||||
optional_attributes=(
|
||||
clusters.ColorControl.Attributes.ColorMode,
|
||||
clusters.ColorControl.Attributes.CurrentHue,
|
||||
clusters.ColorControl.Attributes.CurrentSaturation,
|
||||
clusters.ColorControl.Attributes.CurrentX,
|
||||
clusters.ColorControl.Attributes.CurrentY,
|
||||
clusters.ColorControl.Attributes.ColorTemperatureMireds,
|
||||
),
|
||||
# important: make sure to rule out all device types that are also based on the
|
||||
# onoff and levelcontrol clusters !
|
||||
not_device_type=(
|
||||
device_types.Fan,
|
||||
device_types.GenericSwitch,
|
||||
device_types.OnOffPlugInUnit,
|
||||
device_types.HeatingCoolingUnit,
|
||||
device_types.Pump,
|
||||
device_types.CastingVideoClient,
|
||||
device_types.VideoRemoteControl,
|
||||
device_types.Speaker,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue