From 0d4b1866a7b0353090c0f85a9065482f4686ffb7 Mon Sep 17 00:00:00 2001 From: Tom Schneider Date: Wed, 26 Oct 2022 15:49:10 +0200 Subject: [PATCH] Add has_entity_name support to hvv_departures (#80963) --- homeassistant/components/hvv_departures/binary_sensor.py | 5 +++-- homeassistant/components/hvv_departures/sensor.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/hvv_departures/binary_sensor.py b/homeassistant/components/hvv_departures/binary_sensor.py index 2e47698ecd7..a99dea57447 100644 --- a/homeassistant/components/hvv_departures/binary_sensor.py +++ b/homeassistant/components/hvv_departures/binary_sensor.py @@ -55,9 +55,9 @@ async def async_setup_entry( description = elevator.get("description") if label is not None: - name = f"Elevator {label} at {station_name}" + name = f"Elevator {label}" else: - name = f"Unknown elevator at {station_name}" + name = "Unknown elevator" if description is not None: name += f" ({description})" @@ -126,6 +126,7 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity): """HVVDepartureBinarySensor class.""" _attr_attribution = ATTRIBUTION + _attr_has_entity_name = True def __init__(self, coordinator, idx, config_entry): """Initialize.""" diff --git a/homeassistant/components/hvv_departures/sensor.py b/homeassistant/components/hvv_departures/sensor.py index 3a44bc59c72..dfc69e51710 100644 --- a/homeassistant/components/hvv_departures/sensor.py +++ b/homeassistant/components/hvv_departures/sensor.py @@ -65,7 +65,8 @@ class HVVDepartureSensor(SensorEntity): self.station_name = self.config_entry.data[CONF_STATION]["name"] self._attr_extra_state_attributes = {} self._attr_available = False - self._attr_name = f"Departures at {self.station_name}" + self._attr_has_entity_name = True + self._attr_name = "Departures" self._last_error = None self.gti = hub.gti @@ -178,5 +179,5 @@ class HVVDepartureSensor(SensorEntity): ) }, manufacturer=MANUFACTURER, - name=self.name, + name=self.config_entry.data[CONF_STATION]["name"], )