Add has_entity_name support to hvv_departures (#80963)

pull/81026/head
Tom Schneider 2022-10-26 15:49:10 +02:00 committed by GitHub
parent fbe7a0289c
commit 0d4b1866a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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."""

View File

@ -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"],
)