Add entity translations to Tankerkoenig (#98961)

This commit is contained in:
Joost Lekkerkerker 2023-08-24 19:59:34 +02:00 committed by GitHub
parent 480db1f1e6
commit 7575ffa24e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 6 deletions

View File

@ -170,6 +170,8 @@ class TankerkoenigDataUpdateCoordinator(DataUpdateCoordinator):
class TankerkoenigCoordinatorEntity(CoordinatorEntity):
"""Tankerkoenig base entity."""
_attr_has_entity_name = True
def __init__(
self, coordinator: TankerkoenigDataUpdateCoordinator, station: dict
) -> None:

View File

@ -43,6 +43,7 @@ class StationOpenBinarySensorEntity(TankerkoenigCoordinatorEntity, BinarySensorE
"""Shows if a station is open or closed."""
_attr_device_class = BinarySensorDeviceClass.DOOR
_attr_translation_key = "status"
def __init__(
self,
@ -53,9 +54,6 @@ class StationOpenBinarySensorEntity(TankerkoenigCoordinatorEntity, BinarySensorE
"""Initialize the sensor."""
super().__init__(coordinator, station)
self._station_id = station["id"]
self._attr_name = (
f"{station['brand']} {station['street']} {station['houseNumber']} status"
)
self._attr_unique_id = f"{station['id']}_status"
if show_on_map:
self._attr_extra_state_attributes = {

View File

@ -20,7 +20,6 @@ from .const import (
ATTR_STREET,
ATTRIBUTION,
DOMAIN,
FUEL_TYPES,
)
_LOGGER = logging.getLogger(__name__)
@ -59,6 +58,7 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
_attr_attribution = ATTRIBUTION
_attr_state_class = SensorStateClass.MEASUREMENT
_attr_native_unit_of_measurement = CURRENCY_EURO
_attr_icon = "mdi:gas-station"
def __init__(self, fuel_type, station, coordinator, show_on_map):
@ -66,8 +66,7 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
super().__init__(coordinator, station)
self._station_id = station["id"]
self._fuel_type = fuel_type
self._attr_name = f"{station['brand']} {station['street']} {station['houseNumber']} {FUEL_TYPES[fuel_type]}"
self._attr_native_unit_of_measurement = CURRENCY_EURO
self._attr_translation_key = fuel_type
self._attr_unique_id = f"{station['id']}_{fuel_type}"
attrs = {
ATTR_BRAND: station["brand"],

View File

@ -43,5 +43,23 @@
}
}
}
},
"entity": {
"binary_sensor": {
"status": {
"name": "Status"
}
},
"sensor": {
"e5": {
"name": "Super"
},
"e10": {
"name": "Super E10"
},
"diesel": {
"name": "Diesel"
}
}
}
}