mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Add entity translations to Tankerkoenig (#98961)
This commit is contained in:
parent
480db1f1e6
commit
7575ffa24e
@ -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:
|
||||
|
@ -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 = {
|
||||
|
@ -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"],
|
||||
|
@ -43,5 +43,23 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"status": {
|
||||
"name": "Status"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"e5": {
|
||||
"name": "Super"
|
||||
},
|
||||
"e10": {
|
||||
"name": "Super E10"
|
||||
},
|
||||
"diesel": {
|
||||
"name": "Diesel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user