A beautiful, feature-rich custom Lovelace card for Home Assistant that displays UK rail departure information in a station-board-inspired interface. Designed to work seamlessly with the My Rail Commute integration.
✨ Multiple View Modes
- Full View: Complete train information with all details
- Compact View: Space-efficient layout for mobile dashboards
- Next-Only View: Focus on the immediate next train
- Departure Board View: Classic UK station board aesthetic
🎨 Beautiful Design
- Mimics real railway station departure boards
- Auto, light, and dark theme support
- Customizable colors for each status
- Smooth animations and transitions
- Responsive design for all screen sizes
⚙️ Highly Customizable
- Show/hide any information (platform, operator, calling points, delay reasons)
- Filter trains by delay time or disruption status
- Adjustable font sizes
- Compact height mode
- Custom tap, hold, and double-tap actions
📱 Interactive
- Tap to view more information
- Hold to refresh data
- Visual feedback on interactions
🖱️ Easy Configuration
- Visual card editor in Lovelace UI
- No manual YAML editing required (but supported!)
- Comprehensive examples included
- Open HACS in Home Assistant
- Go to "Frontend"
- Click the "+" button
- Search for "My Rail Commute Card"
- Click "Install"
- Refresh your browser
-
Download
my-rail-commute-card.jsfrom the latest release -
Copy it to
/config/www/my-rail-commute-card.js -
Add the resource to your Lovelace configuration:
resources: - url: /local/my-rail-commute-card.js type: module
-
Refresh your browser
Add this to your Lovelace dashboard:
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summaryThat's it! The card will display with sensible defaults.
- In edit mode, click "Add Card"
- Search for "My Rail Commute Card"
- Select your summary entity
- Configure options using the visual interface
- Save!
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
# Display Options
title: Morning Commute
view: full # Options: full | compact | next-only | board
theme: auto # Options: auto | light | dark
show_header: true
show_route: true
show_last_updated: false
# Train Details
show_platform: true
show_operator: true
show_calling_points: false
show_delay_reason: true
show_journey_time: false
max_calling_points: 3
# Filtering
hide_on_time_trains: false
only_show_disrupted: false
min_delay_to_show: 0 # Only show trains delayed by X+ minutes
# Styling
font_size: medium # Options: small | medium | large
compact_height: false # Reduce vertical spacing
show_animations: true # Enable transition animations
status_icons: true # Show ✓ ⚠️ ❌ icons
# Interaction
tap_action:
action: more-info # Options: more-info | url | navigate | none
hold_action:
action: refresh
double_tap_action:
action: none
# Advanced
disruption_entity: binary_sensor.morning_commute_severe_disruption
refresh_interval: 60
# Custom Colors (optional)
colors:
on_time: '#4caf50'
minor_delay: '#ff9800'
major_delay: '#f44336'
cancelled: '#d32f2f'| Option | Type | Default | Description |
|---|---|---|---|
entity |
string | Required | Your rail commute summary sensor entity |
title |
string | 'Rail Commute' | Card title |
view |
string | 'full' | View mode: full, compact, next-only, or board |
theme |
string | 'auto' | Theme: auto, light, or dark |
show_header |
boolean | true | Show card header |
show_route |
boolean | true | Show origin → destination |
show_last_updated |
boolean | false | Show last update time |
show_platform |
boolean | true | Show platform numbers |
show_operator |
boolean | true | Show train operator |
show_calling_points |
boolean | false | Show calling points list |
show_delay_reason |
boolean | true | Show delay reasons |
show_journey_time |
boolean | false | Show journey duration (* shown if delayed) |
max_calling_points |
number | 3 | Max calling points to display |
hide_on_time_trains |
boolean | false | Only show delayed/cancelled trains |
only_show_disrupted |
boolean | false | Only show when disruption sensor is on |
min_delay_to_show |
number | 0 | Minimum delay in minutes to show train |
font_size |
string | 'medium' | Font size: small, medium, or large |
compact_height |
boolean | false | Reduce vertical spacing |
show_animations |
boolean | true | Enable animations |
status_icons |
boolean | true | Show status icons (✓ |
disruption_entity |
string | - | Binary sensor for disruption detection |
refresh_interval |
number | 60 | Seconds between updates |
tap_action |
object | {action: 'more-info'} |
Action on tap |
hold_action |
object | {action: 'refresh'} |
Action on hold |
colors |
object | - | Custom status colors |
The default view showing all train information with complete details.
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: fullPerfect for:
- Desktop dashboards
- Detailed monitoring
- Full information display
Space-efficient layout showing essential information only.
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: compact
compact_height: truePerfect for:
- Mobile dashboards
- Limited screen space
- Quick glance information
Shows only the next departing train with full details.
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: next-only
show_calling_points: true
font_size: largePerfect for:
- Focus on immediate departure
- Glanceable displays
- Wall-mounted tablets
Classic UK railway station board aesthetic with monospace font.
type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: boardPerfect for:
- Authentic station board look
- Retro aesthetic
- Public displays
type: vertical-stack
cards:
- type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
title: Morning Trains
view: full
show_delay_reason: true
- type: conditional
conditions:
- entity: binary_sensor.morning_commute_severe_disruption
state: "on"
card:
type: markdown
content: |
## ⚠️ Service Disruption Alert
There is currently severe disruption on your route.
Check National Rail for updates.type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: compact
compact_height: true
show_header: false
font_size: small
show_animations: falsetype: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
title: Delayed Services
hide_on_time_trains: true
min_delay_to_show: 5
show_delay_reason: true
colors:
minor_delay: '#ff9800'
major_delay: '#f44336'type: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: board
show_header: false
theme: darktype: custom:my-rail-commute-card
entity: sensor.morning_commute_summary
view: next-only
title: Next Departure
show_calling_points: true
tap_action:
action: url
url_path: https://www.nationalrail.co.uk/See examples/automations.yaml for complete automation examples including:
- Notify on severe disruption
- Alert when train is delayed
- Morning commute reminder
- TTS announcements via smart speakers
- Flash lights on cancellation
- Conditional dashboard visibility
Problem: Card appears as "Custom element doesn't exist: my-rail-commute-card"
Solution:
- Verify the card is installed in
/config/www/or via HACS - Check that you've added the resource to your Lovelace configuration
- Hard refresh your browser (Ctrl+Shift+R or Cmd+Shift+R)
- Clear browser cache
- Check browser console for errors
Problem: Card shows "No trains found"
Solution:
- Verify your My Rail Commute integration is working
- Check that the entity specified in the card config exists
- Check the entity state in Developer Tools → States
- Verify the entity has
all_trainsattribute with data - Check your time window configuration in the integration
Problem: "Entity not found: sensor.xxx"
Solution:
- Verify the entity ID is correct
- Check if the My Rail Commute integration is properly configured
- Restart Home Assistant if you just added the integration
- Check Developer Tools → States to find the correct entity ID
Problem: Card looks unstyled or broken
Solution:
- Hard refresh your browser
- Check browser console for CSS loading errors
- Verify you're using a compatible browser (Chrome, Firefox, Safari, Edge)
- Try switching to a different theme in the card config
Problem: Icons appear as boxes or are missing
Solution:
- Ensure Home Assistant has internet connectivity (for loading MDI icons)
- Hard refresh your browser
- Check if other cards with icons work properly
- Try disabling status_icons:
status_icons: false
Problem: Visual editor doesn't appear or is broken
Solution:
- Verify you're in edit mode (click three dots → Edit Dashboard)
- Check browser console for JavaScript errors
- Try manual YAML configuration instead
- Ensure your Home Assistant is up to date
# Clone the repository
git clone https://github.com/adamf83/lovelace-my-rail-commute-card.git
cd lovelace-my-rail-commute-card
# Install dependencies
npm install
# Build
npm run build
# Watch mode (auto-rebuild on changes)
npm run watchThe built file will be in dist/my-rail-commute-card.js.
- Build the project:
npm run build - Copy
dist/my-rail-commute-card.jsto/config/www/ - Add as a resource with
?v=Xparameter to bust cache:resources: - url: /local/my-rail-commute-card.js?v=1 type: module
- Increment
vparameter each time you update
lovelace-my-rail-commute-card/
├── src/
│ ├── my-rail-commute-card.js # Main card component
│ ├── styles.js # CSS styles
│ ├── editor.js # Visual editor
│ └── utils.js # Helper functions
├── dist/ # Built files
├── examples/ # Example configurations
├── screenshots/ # Screenshots for docs
├── package.json # Dependencies
├── rollup.config.js # Build config
└── README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test thoroughly
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGELOG.md for version history.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Lit
- Icons from Material Design Icons
- Inspired by UK railway station departure boards
- My Rail Commute Integration - The integration this card is designed for
- UK Transport Sensor - Alternative transport integration
Made with ❤️ for the Home Assistant community
