mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Gives a friendly name to emoncms entities if unit is not specified (#133358)
This commit is contained in:
parent
34ab3e033f
commit
6a54edce19
@ -317,7 +317,7 @@ async def async_setup_entry(
|
|||||||
EmonCmsSensor(
|
EmonCmsSensor(
|
||||||
coordinator,
|
coordinator,
|
||||||
unique_id,
|
unique_id,
|
||||||
elem["unit"],
|
elem.get("unit"),
|
||||||
name,
|
name,
|
||||||
idx,
|
idx,
|
||||||
)
|
)
|
||||||
@ -353,6 +353,7 @@ class EmonCmsSensor(CoordinatorEntity[EmoncmsCoordinator], SensorEntity):
|
|||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
else:
|
else:
|
||||||
self._attr_native_unit_of_measurement = unit_of_measurement
|
self._attr_native_unit_of_measurement = unit_of_measurement
|
||||||
|
self._attr_name = f"{name} {elem[FEED_NAME]}"
|
||||||
self._update_attributes(elem)
|
self._update_attributes(elem)
|
||||||
|
|
||||||
def _update_attributes(self, elem: dict[str, Any]) -> None:
|
def _update_attributes(self, elem: dict[str, Any]) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user