Gives a friendly name to emoncms entities if unit is not specified (#133358)

This commit is contained in:
Alexandre CUER 2024-12-16 19:26:47 +01:00 committed by GitHub
parent 34ab3e033f
commit 6a54edce19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -317,7 +317,7 @@ async def async_setup_entry(
EmonCmsSensor(
coordinator,
unique_id,
elem["unit"],
elem.get("unit"),
name,
idx,
)
@ -353,6 +353,7 @@ class EmonCmsSensor(CoordinatorEntity[EmoncmsCoordinator], SensorEntity):
self.entity_description = description
else:
self._attr_native_unit_of_measurement = unit_of_measurement
self._attr_name = f"{name} {elem[FEED_NAME]}"
self._update_attributes(elem)
def _update_attributes(self, elem: dict[str, Any]) -> None: