1 """Tankerkoenig binary sensor integration."""
3 from __future__
import annotations
7 from aiotankerkoenig
import PriceInfo, Station, Status
10 BinarySensorDeviceClass,
17 from .coordinator
import TankerkoenigConfigEntry, TankerkoenigDataUpdateCoordinator
18 from .entity
import TankerkoenigCoordinatorEntity
20 _LOGGER = logging.getLogger(__name__)
25 entry: TankerkoenigConfigEntry,
26 async_add_entities: AddEntitiesCallback,
28 """Set up the tankerkoenig binary sensors."""
29 coordinator = entry.runtime_data
36 for station
in coordinator.stations.values()
41 """Shows if a station is open or closed."""
43 _attr_device_class = BinarySensorDeviceClass.DOOR
44 _attr_translation_key =
"status"
49 coordinator: TankerkoenigDataUpdateCoordinator,
51 """Initialize the sensor."""
52 super().
__init__(coordinator, station)
55 if coordinator.show_on_map:
57 ATTR_LATITUDE: station.lat,
58 ATTR_LONGITUDE: station.lng,
63 """Return true if the station is open."""
64 data: PriceInfo = self.coordinator.data[self.
_station_id_station_id]
65 return data
is not None and data.status == Status.OPEN
None __init__(self, Station station, TankerkoenigDataUpdateCoordinator coordinator)
_attr_extra_state_attributes
None async_setup_entry(HomeAssistant hass, TankerkoenigConfigEntry entry, AddEntitiesCallback async_add_entities)