Add device name to sensor name for mobile_app (#31756)
* Add device name to sensor name * Update test to include device name
This commit is contained in:
1 parent
3b3e062a35
commit
43256ebd83
2 files changed
+6
-4
No files matched your search
@@ -7,6 +7,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from .const import (
|
||||
ATTR_DEVICE_NAME,
|
||||
ATTR_SENSOR_ATTRIBUTES,
|
||||
ATTR_SENSOR_DEVICE_CLASS,
|
||||
ATTR_SENSOR_ICON,
|
||||
@@ -38,6 +39,7 @@ class MobileAppEntity(Entity):
|
||||
)
|
||||
self._entity_type = config[ATTR_SENSOR_TYPE]
|
||||
self.unsub_dispatcher = None
|
||||
self._name = f"{entry.data[ATTR_DEVICE_NAME]} {config[ATTR_SENSOR_NAME]}"
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
@@ -58,7 +60,7 @@ class MobileAppEntity(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the mobile app sensor."""
|
||||
return self._config[ATTR_SENSOR_NAME]
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
||||
Reference in new issue
Block a user