This custom hacs-default integration adds support for real-time public transport departures from Transitous to Home Assistant, using the Motis API.
It allows you to monitor upcoming departures for stations, with optional filtering by platforms and lines.
Each configured station is represented as a device with separate entities for the next three departures.
This integration is now available as a default HACS repository!
- Install HACS if you haven't already.
- In HACS, go to Integrations โ โฎ โ Custom repositories.
- Add this repository as a custom integration repository:
- https://github.com/herrlevin/homeassistant-motis
- Set the category to
Integration.
- Restart Home Assistant
After installation, add the integration to Home Assistant (Requesting the first access token may take a while):
Or manually:
- Go to Settings โ Devices & Services โ + Add Integration
- Search for Motis
- Follow the setup flow
You can customize the integration after setup by managing stations through the options flow:
- Go to Settings โ Devices & Services.
- Find Motis Public Transport and click the cog (โ๏ธ) icon to open Options.
Inside the options menu, you can:
Enter the station name and click submit. Select the correct station from a drop down and optionally specify platforms and lines to monitor.
Select a station from your saved list to remove it (this also deletes associated devices).
Apply your changes and close the options menu.
Below are two examples showing upcoming Motis public transport departures in Home Assistant:
With this integration, two types of Home Assistant cards can be created to display upcoming departures.
For instructions on using the custom card, see the Motis Card repository.
Using the markdown card in Home Assistant an overview like this can be generated:
Use this code to replicate the card in Home Assistant. You only have to change the heading and your Motis sensor names:
type: markdown
content: |
<h3>๐ Departures</h1>
{% set sensors = [
'sensor.motis_station_xxx_r_50_next_departure',
'sensor.motis_station_xxx_r_50_second_departure',
'sensor.motis_station_xxx_r_50_third_departure'
] %}
<table border="1" width="100%" cellspacing="0" cellpadding="4">
<tr>
<th align="center">Line</th>
<th align="center">Destination</th>
<th align="center">Departure</th>
<th align="center">Platform</th>
</tr>
{%- for s in sensors %}
{%- set state = states[s] %}
{%- if state %}
<tr>
<td align="center" style="color: {{ state.attributes.route_text_color }}">
{{ state.attributes.label }}
</td>
<td align="center">{{ state.attributes.destination }}</td>
<td align="center">
{%- if state.attributes.time_until_departure -%}
{{ state.attributes.time_until_departure }}
{%- else -%}
{{ state.attributes.realtime_time_local or (state.attributes.realtime_time | default(state.attributes.planned_time) | as_timestamp | timestamp_custom('%H:%M')) }}
{%- endif -%}
</td>
<td align="center">{{ state.attributes.platform or '-' }}</td>
</tr>
{%- endif %}
{%- endfor %}
</table>
For a German Version:
type: markdown
content: |
<h3>๐ Haltestelle</h1>
{% set sensors = [
'sensor.motis_station_xxx_r_50_next_departure',
'sensor.motis_station_xxx_r_50_second_departure',
'sensor.motis_station_xxx_r_50_third_departure'
] %}
<table border="1" width="100%" cellspacing="0" cellpadding="4">
<tr>
<th align="center">Linie</th>
<th align="center">Ziel</th>
<th align="center">Abfahrt</th>
<th align="center">Steig</th>
</tr>
{%- for s in sensors %}
{%- set state = states[s] %}
{%- if state %}
<tr>
<td align="center" style="color: {{ state.attributes.route_text_color }}">
{{ state.attributes.label }}
</td>
<td align="center">{{ state.attributes.destination }}</td>
<td align="center">
{%- if state.attributes.time_until_departure -%}
{{ state.attributes.time_until_departure }}
{%- else -%}
{{ state.attributes.realtime_time_local or (state.attributes.realtime_time | default(state.attributes.planned_time) | as_timestamp | timestamp_custom('%H:%M')) }}
{%- endif -%}
</td>
<td align="center">{{ state.attributes.platform or '-' }}</td>
</tr>
{%- endif %}
{%- endfor %}
</table>
This project is licensed under the MIT License,
Forked from and based on the Home Assistant RNV integration.
Disclaimer: This project is an independent community integration and is not affiliated with or endorsed by Motis / Transitous.





