Home Assistant custom component for MBTA predictions. Adding this custom component allows adding sensors for specific routes to Home Assistant. After the sensors are set up, they can be visualised in LoveLace using the custom mbta-card.
The custom component source code is located here. Copying the custom_component
directory into the root directory (alongside the configuration.yml
file) for users using HASSIO.
To enable this sensor, add the following lines to your configuration.yaml
file:
sensor:
- platform: mbta_predictions
predictions:
- stop: STOP_NAME
destination: DESTINATION_NAME
route: ROUTE_NAME
example configuration.yml
:
# adds sensor info for MBTA Predictions
sensor:
- platform: mbta_predictions
predictions:
- depart_from: JFK/UMass
arrive_at: Alewife
route: Red Line # Subway
- depart_from: Montserrat
arrive_at: North Station
route: Newburyport/Rockport Line # Commuter Rail
return_trips: True
- depart_from: Timson St @ Brookline Ave
arrive_at: Highland Ave @ Wyman Ave
route: Salem Depot - Central Square, Lynn # Bus
- depart_from: Charlestown
arrive_at: Long Wharf (South)
route: Charlestown Ferry # Ferry
(string) (Required) the stop in which you will begin transit from (e.g.
JFK/UMass
)
(string) (Required) the stop in which you will end your trip (e.g.
Alewife
)
(string) (Required) the route (e.g.
Red Line
,Newburyport/Rockport Line
,Salem Depot - Central Square, Lynn
)
(string) (Optional) the name of the sensor (default: "mbta_DEPARTURE_TO_ARRIVAL")
(boolean) (Optional) when true, will generate a second entity with depart_from/arrive_at swapped (default: False)
(int) (Optional) the minimum minutes remaining before arrival (default: 0)
(int) (Optional) the maximum number of predictions to send back (default: 10)
As we're pulling these values from the MBTA API, the easiest method to find the values needed is to navigate to MBTA Schedules Page. You'll see all of the routes available, so click the one you want to integrate. At the top of the screen you'll see the route name, which should be used as the route in your configuration (excluding any numbers that might appear before the name). Below that, you'll either see a table or a list of stops. Use those stop names as depart_from and arrive_to values.
-
Create PR for custom component in the Home Asistant Repo
-
Create custom component in HACS