Support for RATP API [Paris Public Transport]

Hi all!

I don’t have the skills to do so, but integrating Paris public transport into our components would be amazing. The transport operator, RATP has an API that details all the states of the lines (metro, RER, tram and bus), as well as the next arrivals at each stop in each direction.

As you can imagine, a lot of the existing efforts are in French. Regardless, here are a few things I found that could help:

REST API: https://github.com/pgrimaud/ratp-api-rest
Python Package: https://pypi.org/project/ratp/
Another Python implementation: https://gilleschardon.fr/demo_ratp.html

Of course I can help with translating anything!

Good idea. I have no time currently as I’m focused on weather alerts from météo France component.
Perhaps after but I’m not in Paris anymore since decades. Can you perhaps share some use cases ? What type of information available in the API could be usefull for frontend display or for automation ?

It’s not so complicated if a pyton package already exist. Go to home-assistant source, find a simple componet like weather component or waze, you can reverse engineer easily.

Salut oncleben,

I understand :slight_smile:
A couple of use cases:

  • During the morning routine, let a user know of any travel alerts on lines they use. If delays are expected, follow up with a Google Maps call to give the user a better/faster travel itinerary.
  • If traffic is normal, you could have a system where you say “leave in the next 5min in order to catch train x”.
1 Like

That’s an amazing Idea,
Unfortunatly i don’t have the time to work on it but it would be great to have it.

1 Like

After some researches I have found that city mapper’s API is better than RATP, because you can use directly the Latitude/longitude location rather than using the name of the station.

Citymapper is an app for public transport in multiple cities and it would be worth adding it to Home assistant.

the link of the API is : https://citymapper.3scale.net/docs

1 Like

Has anyone tried getting this to work?

1 Like

I would also be interested!

You can tag me in your draft/PR for a review or a help.

1 Like

That documentation only talks about travel time? You can already get travel time between two points, specifying public transport, here: https://www.home-assistant.io/integrations/google_travel_time/

Personally I’m much more interested in having access to a given station’s schedules, any alerts for lateness, etc.

1 Like

hello everyone,

After doing some reseach i have found an API that showes next metro/train/RER/Bus in a station

I am trying to implement it with a Sensor.REST but don’t succeed.

here is the link : https://api-ratp.pierre-grimaud.fr/v4/
And exemple of a station : https://api-ratp.pierre-grimaud.fr/v4/schedules/metros/9/marcel%2Bsembat/A%2BR

i ll give you my updates

Hey,

I’m guessing many have solved this problem already, but just in case, I thought I’d chime in. I’ve used the REST API linked just above and since I couldn’t find any way to nicely display the “schedules” attribute that the REST sensor contained, I built a very simple Lovelace card that does just that. If anyone’s interested, I guess I could try to make it proper enough to publish it in HACS and improve it with the suggestions you might all have.

Cheers,

I think that would be a great contribution to HACS! :slight_smile:

I have implemented an Arduino / Json device with this API from pierre grimaud.

1 Like

Hi all,

@lesensei : I’m very interested in this kind of implementation in HA.

I let you know if i found something interessting

Hey there,

I’ve actually built a Lovelace card to display the next passages of whatever transport system vianavigo can deal with. It’s displayed in a way that’s supposed to mimic how the RATP does it, but it’s far from perfect (pretty broken on mobile, pretty ugly on “night” themes, etc.).
It’s not based on Pierre Grimaud’s API, because it was broken when I began working on it and because it’s limited compared to what vianavigo.com can do. So it uses the vianavigo “API” (it makes the same REST API calls as the vianavigo website).

What’s the catch ?
Well at the moment setting it up requires getting your line and station identifier by browsing the vianavigo website with developer tools open, which kinda sucks. I want to use the visual editor to allow anyone to easily select line and station from readable menus, but my understanding of polymer and the web components used in HA is too limited for me to work it out. And my real work has gotten a bit too hectic to allow me to spend time on this for a few months now, so I thought I’d let you guys have a look at it. If someone with web experience happens to read this and wishes to “tutor” me, I’ll happily get back to coding as soon as I can. But at the moment, I feel I can’t do much more by myself.

The code is here for anyone willing to have a look:

Cheers !

2 Likes

Hey,

First of all thanks for your repo !

I’ve tryed to use your work but as a new HA user I might have done it in the wrong way :confused:

Installation :

I have downloaded the package “idfm-card-master” and installed in “\local.ip\config\www\community”
I haded the module in Configuration>LovelaceUI>Ressources ==> My first question here : I couldn’t find a “idfm-card.js” so I puted “rollup.config.js” as root but I wasn’t really convinced about it. Was it the good file ?

See cap bellow:

Configuration :

I created an empty card and filled it like this

type: 'custom:idfm-card'
entity: config
name: ratp
line: 'RAT:M1'
station: 'RAT:SA:BASTI'
way: A

But as a result I have “Custom element doesn’t exist: idfm-card.” my guess is that the installation part didn’t went so well.

My second question is where can I find the dictionnary of all lines/stations ? I went here and here but i couldn’t find the right information (so I puted the parameters i found in the api exemple)

I’ll keep working on it but if you can help me that would be nice.

Wow, I’m sorry you had to go through all this just to try it. I just updated the README to add an installation section for the souls brave enough to try and use this horrid piece of code :wink:

This got me to see that Ile de France Mobilités actually scrapped the vianavigo website, which is not newsworthy in itself, but that the new website actually has everything needed to configure the card in its URLs, which gave me an idea to make this whole deal simpler within the configuration card. So for those that get sick just reading the readme, I might make time in the coming weeks/months to update the card with a simpler config flow. We’ll see :thinking:

Oh, and to answer your dictionary question, I have no clue ! I kinda lost hope of finding something with all line IDs and associated stop_area IDs, which would make the config flow way more user-friendly :slight_smile:

As I hinted to above, I published a new release that should make setting up the card easier. Let me know how it works for you !

Hey,

I’m sorry it took me so long to respond yet but I’ve been pretty busy last week.

Thank for all the information and the update.

I’ll try to have a look this week and give you a feedback :slight_smile: