Fix Matter entity names (#95477)

This commit is contained in:
Marcel van der Veldt 2023-06-28 23:40:12 +02:00 committed by GitHub
parent ec7beee4c1
commit 0b81550092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 24 deletions

View file

@ -65,7 +65,6 @@ DISCOVERY_SCHEMAS = [
entity_description=MatterBinarySensorEntityDescription(
key="HueMotionSensor",
device_class=BinarySensorDeviceClass.MOTION,
name="Motion",
measurement_to_ha=lambda x: (x & 1 == 1) if x is not None else None,
),
entity_class=MatterBinarySensor,
@ -78,7 +77,6 @@ DISCOVERY_SCHEMAS = [
entity_description=MatterBinarySensorEntityDescription(
key="ContactSensor",
device_class=BinarySensorDeviceClass.DOOR,
name="Contact",
# value is inverted on matter to what we expect
measurement_to_ha=lambda x: not x,
),
@ -90,7 +88,6 @@ DISCOVERY_SCHEMAS = [
entity_description=MatterBinarySensorEntityDescription(
key="OccupancySensor",
device_class=BinarySensorDeviceClass.OCCUPANCY,
name="Occupancy",
# The first bit = if occupied
measurement_to_ha=lambda x: (x & 1 == 1) if x is not None else None,
),
@ -102,7 +99,6 @@ DISCOVERY_SCHEMAS = [
entity_description=MatterBinarySensorEntityDescription(
key="BatteryChargeLevel",
device_class=BinarySensorDeviceClass.BATTERY,
name="Battery Status",
measurement_to_ha=lambda x: x
!= clusters.PowerSource.Enums.BatChargeLevelEnum.kOk,
),

View file

@ -199,7 +199,7 @@ class MatterCover(MatterEntity, CoverEntity):
DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.COVER,
entity_description=CoverEntityDescription(key="MatterCover"),
entity_description=CoverEntityDescription(key="MatterCover", name=None),
entity_class=MatterCover,
required_attributes=(
clusters.WindowCovering.Attributes.OperationalStatus,
@ -212,7 +212,9 @@ DISCOVERY_SCHEMAS = [
),
MatterDiscoverySchema(
platform=Platform.COVER,
entity_description=CoverEntityDescription(key="MatterCoverPositionAwareLift"),
entity_description=CoverEntityDescription(
key="MatterCoverPositionAwareLift", name=None
),
entity_class=MatterCover,
required_attributes=(
clusters.WindowCovering.Attributes.OperationalStatus,
@ -225,7 +227,9 @@ DISCOVERY_SCHEMAS = [
),
MatterDiscoverySchema(
platform=Platform.COVER,
entity_description=CoverEntityDescription(key="MatterCoverPositionAwareTilt"),
entity_description=CoverEntityDescription(
key="MatterCoverPositionAwareTilt", name=None
),
entity_class=MatterCover,
required_attributes=(
clusters.WindowCovering.Attributes.OperationalStatus,
@ -239,7 +243,7 @@ DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.COVER,
entity_description=CoverEntityDescription(
key="MatterCoverPositionAwareLiftAndTilt"
key="MatterCoverPositionAwareLiftAndTilt", name=None
),
entity_class=MatterCover,
required_attributes=(

View file

@ -358,7 +358,7 @@ class MatterLight(MatterEntity, LightEntity):
DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.LIGHT,
entity_description=LightEntityDescription(key="MatterLight"),
entity_description=LightEntityDescription(key="MatterLight", name=None),
entity_class=MatterLight,
required_attributes=(clusters.OnOff.Attributes.OnOff,),
optional_attributes=(
@ -380,7 +380,9 @@ DISCOVERY_SCHEMAS = [
# Additional schema to match (HS Color) lights with incorrect/missing device type
MatterDiscoverySchema(
platform=Platform.LIGHT,
entity_description=LightEntityDescription(key="MatterHSColorLightFallback"),
entity_description=LightEntityDescription(
key="MatterHSColorLightFallback", name=None
),
entity_class=MatterLight,
required_attributes=(
clusters.OnOff.Attributes.OnOff,
@ -398,7 +400,9 @@ DISCOVERY_SCHEMAS = [
# Additional schema to match (XY Color) lights with incorrect/missing device type
MatterDiscoverySchema(
platform=Platform.LIGHT,
entity_description=LightEntityDescription(key="MatterXYColorLightFallback"),
entity_description=LightEntityDescription(
key="MatterXYColorLightFallback", name=None
),
entity_class=MatterLight,
required_attributes=(
clusters.OnOff.Attributes.OnOff,
@ -417,7 +421,7 @@ DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.LIGHT,
entity_description=LightEntityDescription(
key="MatterColorTemperatureLightFallback"
key="MatterColorTemperatureLightFallback", name=None
),
entity_class=MatterLight,
required_attributes=(
@ -430,7 +434,9 @@ DISCOVERY_SCHEMAS = [
# Additional schema to match generic dimmable lights with incorrect/missing device type
MatterDiscoverySchema(
platform=Platform.LIGHT,
entity_description=LightEntityDescription(key="MatterDimmableLightFallback"),
entity_description=LightEntityDescription(
key="MatterDimmableLightFallback", name=None
),
entity_class=MatterLight,
required_attributes=(
clusters.OnOff.Attributes.OnOff,

View file

@ -147,7 +147,7 @@ class DoorLockFeature(IntFlag):
DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.LOCK,
entity_description=LockEntityDescription(key="MatterLock"),
entity_description=LockEntityDescription(key="MatterLock", name=None),
entity_class=MatterLock,
required_attributes=(clusters.DoorLock.Attributes.LockState,),
optional_attributes=(clusters.DoorLock.Attributes.DoorState,),

View file

@ -68,7 +68,6 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="TemperatureSensor",
name="Temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
measurement_to_ha=lambda x: x / 100,
@ -80,7 +79,6 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="PressureSensor",
name="Pressure",
native_unit_of_measurement=UnitOfPressure.KPA,
device_class=SensorDeviceClass.PRESSURE,
measurement_to_ha=lambda x: x / 10,
@ -92,9 +90,8 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="FlowSensor",
name="Flow",
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
device_class=SensorDeviceClass.WATER, # what is the device class here ?
translation_key="flow",
measurement_to_ha=lambda x: x / 10,
),
entity_class=MatterSensor,
@ -104,7 +101,6 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="HumiditySensor",
name="Humidity",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.HUMIDITY,
measurement_to_ha=lambda x: x / 100,
@ -118,7 +114,6 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="LightSensor",
name="Illuminance",
native_unit_of_measurement=LIGHT_LUX,
device_class=SensorDeviceClass.ILLUMINANCE,
measurement_to_ha=lambda x: round(pow(10, ((x - 1) / 10000)), 1),
@ -130,7 +125,6 @@ DISCOVERY_SCHEMAS = [
platform=Platform.SENSOR,
entity_description=MatterSensorEntityDescription(
key="PowerSource",
name="Battery",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
# value has double precision

View file

@ -43,5 +43,12 @@
"install_addon": "Please wait while the Matter Server add-on installation finishes. This can take several minutes.",
"start_addon": "Please wait while the Matter Server add-on starts. This add-on is what powers Matter in Home Assistant. This may take some seconds."
}
},
"entity": {
"sensor": {
"flow": {
"name": "Flow"
}
}
}
}

View file

@ -63,7 +63,7 @@ DISCOVERY_SCHEMAS = [
MatterDiscoverySchema(
platform=Platform.SWITCH,
entity_description=SwitchEntityDescription(
key="MatterPlug", device_class=SwitchDeviceClass.OUTLET
key="MatterPlug", device_class=SwitchDeviceClass.OUTLET, name=None
),
entity_class=MatterSwitch,
required_attributes=(clusters.OnOff.Attributes.OnOff,),

View file

@ -31,7 +31,7 @@ async def test_contact_sensor(
contact_sensor_node: MatterNode,
) -> None:
"""Test contact sensor."""
state = hass.states.get("binary_sensor.mock_contact_sensor_contact")
state = hass.states.get("binary_sensor.mock_contact_sensor_door")
assert state
assert state.state == "off"
@ -40,7 +40,7 @@ async def test_contact_sensor(
hass, matter_client, data=(contact_sensor_node.node_id, "1/69/0", False)
)
state = hass.states.get("binary_sensor.mock_contact_sensor_contact")
state = hass.states.get("binary_sensor.mock_contact_sensor_door")
assert state
assert state.state == "on"