Get opening times
The Tankerkoenig: Get opening times action retrieves the regular opening times of one or more gas stations from tankerkoenig.de, together with temporary changes such as a closure over the holidays.
This is useful when you want a dashboard, an automation, or a script to show when a gas station opens or closes, beyond whether it is open right now. That part is already covered by the Status binary sensor.
Targets of the action
This action requires a target. The target is the object of the action. You can point the action at a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label, and Home Assistant will run the action on every matching binary_sensor entity behind that target.
-
Entity: one specific binary_sensor entity, such as
binary_sensor.living_room. - Device: every binary_sensor entity that belongs to a device.
- Area: every binary_sensor entity in a room or area.
- Floor: every binary_sensor entity on a floor.
- Label: every binary_sensor entity that shares a label.
You can also select different target types in one action. For example, you can add a specific entity and an area as targets in the same action to run the action on both of them at once.
To learn which entities Home Assistant includes for a device, area, floor, or label, and how it handles several entities, refer to Automation targets.
To leave out some of these entities, refer to Excluding targets. For example, you can leave out one binary_sensor entity in an area.
Using this action from the user interface
If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.
To get the opening times from an automation or a script:
- Go to Settings > Automations & scenes.
- Open an existing automation or script, or select Create automation > Create new automation.
- If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
- In the Then do section, select Add action.
- From the search box, search for and select Tankerkoenig: Get opening times.
- Select the
Statusbinary sensor of each gas station as the target. - In the Response variable field, enter a name to store the opening times in, such as
opening_times. You’ll use this name to read the opening times in later steps. - Select Save.
Options in the UI
This action has no additional options beyond the target.
Using this action in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required. For how an automation or a script is built in YAML, refer to Automations in YAML and Scripts.
In YAML, refer to this action as tankerkoenig.get_opening_times. Because this action returns data, use response_variable to capture the result. A basic example looks like this:
action: tankerkoenig.get_opening_times
target:
entity_id: binary_sensor.my_favorite_gas_station_status
response_variable: opening_times
This retrieves the opening times of the gas station and stores them in the opening_times variable.
Options in YAML
This action has no additional YAML options beyond the target.
Response data
The response is a mapping of the targeted Status binary sensors, each containing these fields:
-
opening_times: The regular opening times. Each entry hasdays,start_time, andend_time. A gas station that is open 24 hours a day returns a single entry withdaysMo-So,start_time00:00:00, andend_time23:59:59. A gas station without any known opening times returns an empty list. -
overrides: Temporary changes to the regular opening times, such as a closure over the holidays or different hours on a single day, as the text Tankerkönig provides. It is empty when there are none.
The response looks similar to this:
binary_sensor.my_favorite_gas_station_status:
opening_times:
- days: Mo-Fr
start_time: "06:00:00"
end_time: "22:00:00"
- days: Sa-So
start_time: "08:00:00"
end_time: "20:00:00"
overrides:
- "24.12.2026, 14:00:00 - 26.12.2026, 23:59:00: geschlossen"
Good to know
- To stay within the API limits, the opening times are fetched from Tankerkönig at most once an hour. Within that hour, the action returns the stored opening times without contacting Tankerkönig.
- Once the stored opening times are older than an hour, the action fetches them again. If Tankerkönig can’t be reached at that point, the action fails with an error instead of returning the older opening times.
Try it yourself
Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.
Still stuck?
To test the action on its own, run it in the automation editor with Run action, and check the message that it shows. To see what the action did when the automation ran, open the trace of that run. For details, refer to Testing automations. For common problems and their solutions, refer to Troubleshooting automations.
If that doesn’t help, the Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.