A Home Assistant Lovelace card that shows upcoming departures from a Trafiklab timetable sensor.
- Shows type, line, destination, time, minutes until departure, and status (on time / delayed / cancelled)
- Shows the Platform/Stand/Bay where the service departures from or arrives to
- Real-time indicator (RT) when applicable
- Configurable number of items, optional heading
- English and Swedish translations
- Home Assistant 2024.1+ (tested)
- Trafiklab Integration 0.4.6+
- Add this repository as a custom repository in HACS (Frontend).
- Install "Trafiklab Timetable Card".
- Reload resources when prompted.
- Download
trafiklab-timetable-card.jsfrom the latest GitHub release. - Copy it to
config/www/trafiklab-timetable-card/on your HA instance. - Add a Lovelace resource:
- URL:
/local/trafiklab-timetable-card/trafiklab-timetable-card.js - Type:
module
- URL:
- Refresh your browser cache (append
?v=1to resource URL as needed).
You can add the card from the UI (recommended) or via YAML.
- Go to Dashboards → Edit Dashboard → Add Card → search for "Trafiklab Timetable".
- Choose the sensor in the CONFIG tab and adjust options.
type: custom:trafiklab-timetable-card
entity: sensor.trafiklab_upcoming
show_name: true
max_items: 6entity(required): Sensor entity id.show_name(optional, defaulttrue): Show the sensor's friendly name as the card heading.max_items(optional, default5): Max number of departures to display.
The card supports two formats:
- Array format (preferred):
sensor.attributes.upcomingis a list of departures, where each item may include:
line,destination,scheduled_time,expected_time,time_formatted,minutes_until,transport_mode,real_time,delay_minutes/delay,canceled,platform,agency
- Single-trip format: Card will map base attributes from the entity itself if
upcomingis not an array.
- Status: Derived from
canceledanddelay_minutes/delay. - Time: Uses
time_formattedif provided; otherwise showsexpected_timeorscheduled_timeas HH:mm. - Minutes label: Shows localized "Now" when
minutes_untilis 0; otherwise "in X min". - Platform label:
- Platform: train, metro
- Stand: bus, taxi, tram
- Bay: boat
- Icons: Based on
transport_mode(mdi icons).
- Header overlay and line pill are keyboard-activatable (Enter/Space) to open more-info.
- Install deps:
npm ci - Dev server:
npm run dev - Build:
npm run build(output indist/)
The build outputs a single trafiklab-timetable-card.js bundle (with a .map for debugging). Only the .js is required in HA.
- Card not found: Make sure the resource is added and cache is cleared.
- Blank config tab: Ensure HA’s frontend components are loaded; this card falls back to plain inputs if needed.
- No updates: The card re-renders on HA state changes via the
hasssetter; verify the sensor updates and the entity id is correct.
MIT
