diff --git a/homeassistant/components/matter/discovery.py b/homeassistant/components/matter/discovery.py index 3b9fb0b8a94..de03d250836 100644 --- a/homeassistant/components/matter/discovery.py +++ b/homeassistant/components/matter/discovery.py @@ -130,6 +130,15 @@ def async_discover_entities( ): continue + # check for value that may not be present + if schema.value_is_not is not None and ( + schema.value_is_not == primary_value + or ( + isinstance(primary_value, list) and schema.value_is_not in primary_value + ) + ): + continue + # check for required value in cluster featuremap if schema.featuremap_contains is not None and ( not bool( diff --git a/homeassistant/components/matter/models.py b/homeassistant/components/matter/models.py index a00963c825a..f1fd7ca9fa3 100644 --- a/homeassistant/components/matter/models.py +++ b/homeassistant/components/matter/models.py @@ -116,6 +116,11 @@ class MatterDiscoverySchema: # NOTE: only works for list values value_contains: Any | None = None + # [optional] the primary attribute value must NOT have this value + # for example to filter out invalid values (such as empty string instead of null) + # in case of a list value, the list may not contain this value + value_is_not: Any | None = None + # [optional] the primary attribute's cluster featuremap must contain this value # for example for the DoorSensor on a DoorLock Cluster featuremap_contains: int | None = None