diff --git a/homeassistant/components/mobile_app/entity.py b/homeassistant/components/mobile_app/entity.py index 27cb9934b18..5200c6b0c12 100644 --- a/homeassistant/components/mobile_app/entity.py +++ b/homeassistant/components/mobile_app/entity.py @@ -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): diff --git a/tests/components/mobile_app/test_entity.py b/tests/components/mobile_app/test_entity.py index 0db9d42048f..65dc328186d 100644 --- a/tests/components/mobile_app/test_entity.py +++ b/tests/components/mobile_app/test_entity.py @@ -35,7 +35,7 @@ async def test_sensor(hass, create_registrations, webhook_client): assert json == {"success": True} await hass.async_block_till_done() - entity = hass.states.get("sensor.battery_state") + entity = hass.states.get("sensor.test_1_battery_state") assert entity is not None assert entity.attributes["device_class"] == "battery" @@ -43,7 +43,7 @@ async def test_sensor(hass, create_registrations, webhook_client): assert entity.attributes["unit_of_measurement"] == "%" assert entity.attributes["foo"] == "bar" assert entity.domain == "sensor" - assert entity.name == "Battery State" + assert entity.name == "Test 1 Battery State" assert entity.state == "100" update_resp = await webhook_client.post( @@ -63,7 +63,7 @@ async def test_sensor(hass, create_registrations, webhook_client): assert update_resp.status == 200 - updated_entity = hass.states.get("sensor.battery_state") + updated_entity = hass.states.get("sensor.test_1_battery_state") assert updated_entity.state == "123" dev_reg = await device_registry.async_get_registry(hass)