mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +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):
|
class TankerkoenigCoordinatorEntity(CoordinatorEntity):
|
||||||
"""Tankerkoenig base entity."""
|
"""Tankerkoenig base entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: TankerkoenigDataUpdateCoordinator, station: dict
|
self, coordinator: TankerkoenigDataUpdateCoordinator, station: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -43,6 +43,7 @@ class StationOpenBinarySensorEntity(TankerkoenigCoordinatorEntity, BinarySensorE
|
|||||||
"""Shows if a station is open or closed."""
|
"""Shows if a station is open or closed."""
|
||||||
|
|
||||||
_attr_device_class = BinarySensorDeviceClass.DOOR
|
_attr_device_class = BinarySensorDeviceClass.DOOR
|
||||||
|
_attr_translation_key = "status"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -53,9 +54,6 @@ class StationOpenBinarySensorEntity(TankerkoenigCoordinatorEntity, BinarySensorE
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(coordinator, station)
|
super().__init__(coordinator, station)
|
||||||
self._station_id = station["id"]
|
self._station_id = station["id"]
|
||||||
self._attr_name = (
|
|
||||||
f"{station['brand']} {station['street']} {station['houseNumber']} status"
|
|
||||||
)
|
|
||||||
self._attr_unique_id = f"{station['id']}_status"
|
self._attr_unique_id = f"{station['id']}_status"
|
||||||
if show_on_map:
|
if show_on_map:
|
||||||
self._attr_extra_state_attributes = {
|
self._attr_extra_state_attributes = {
|
||||||
|
@ -20,7 +20,6 @@ from .const import (
|
|||||||
ATTR_STREET,
|
ATTR_STREET,
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
FUEL_TYPES,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -59,6 +58,7 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
_attr_attribution = ATTRIBUTION
|
_attr_attribution = ATTRIBUTION
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
_attr_native_unit_of_measurement = CURRENCY_EURO
|
||||||
_attr_icon = "mdi:gas-station"
|
_attr_icon = "mdi:gas-station"
|
||||||
|
|
||||||
def __init__(self, fuel_type, station, coordinator, show_on_map):
|
def __init__(self, fuel_type, station, coordinator, show_on_map):
|
||||||
@ -66,8 +66,7 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
|
|||||||
super().__init__(coordinator, station)
|
super().__init__(coordinator, station)
|
||||||
self._station_id = station["id"]
|
self._station_id = station["id"]
|
||||||
self._fuel_type = fuel_type
|
self._fuel_type = fuel_type
|
||||||
self._attr_name = f"{station['brand']} {station['street']} {station['houseNumber']} {FUEL_TYPES[fuel_type]}"
|
self._attr_translation_key = fuel_type
|
||||||
self._attr_native_unit_of_measurement = CURRENCY_EURO
|
|
||||||
self._attr_unique_id = f"{station['id']}_{fuel_type}"
|
self._attr_unique_id = f"{station['id']}_{fuel_type}"
|
||||||
attrs = {
|
attrs = {
|
||||||
ATTR_BRAND: station["brand"],
|
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