Migrate EAFM to has entity name (#98121)

This commit is contained in:
Joost Lekkerkerker 2023-08-09 17:44:08 +02:00 committed by GitHub
parent 4c03077dfe
commit 138854a9cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,8 @@ class Measurement(CoordinatorEntity, SensorEntity):
"from the real-time data API" "from the real-time data API"
) )
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
_attr_has_entity_name = True
_attr_name = None
def __init__(self, coordinator, key): def __init__(self, coordinator, key):
"""Initialise the gauge with a data instance and station.""" """Initialise the gauge with a data instance and station."""
@ -122,11 +124,6 @@ class Measurement(CoordinatorEntity, SensorEntity):
"""Return the parameter name for the station.""" """Return the parameter name for the station."""
return self.coordinator.data["measures"][self.key]["parameterName"] return self.coordinator.data["measures"][self.key]["parameterName"]
@property
def name(self):
"""Return the name of the gauge."""
return f"{self.station_name} {self.parameter_name} {self.qualifier}"
@property @property
def device_info(self): def device_info(self):
"""Return the device info.""" """Return the device info."""
@ -135,7 +132,7 @@ class Measurement(CoordinatorEntity, SensorEntity):
identifiers={(DOMAIN, "measure-id", self.station_id)}, identifiers={(DOMAIN, "measure-id", self.station_id)},
manufacturer="https://environment.data.gov.uk/", manufacturer="https://environment.data.gov.uk/",
model=self.parameter_name, model=self.parameter_name,
name=self.name, name=f"{self.station_name} {self.parameter_name} {self.qualifier}",
) )
@property @property