ibaaj / Paris-Dashboard

Display the Paris Metro schedules :metro: and the number of Velibs :bicyclist: (bicycle-system in Paris) available.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

update

2017 : Now, the RATP Group is letting everyone access their realtime API : I will release a proper code and tutorial for this project ASAP.

#Paris Dashboard ⚑️

πŸŒ€ Display the Paris Metro schedules πŸš‰ and the number of Velibs 🚲 (bicycle-system) available just near my home 😌.

Requirements πŸ‘œ

You need an Arduino board πŸ’Ž with PWM and Digital outputs. As "4-digit 7-segment display" πŸ’« I bought 3x TM1637 (3*~8€), which requires 1x PWM intput (CLK), 1x Digital intput (DIO) and 5V input for each.

It's very easy to communicate πŸ“’ with a TM1637.

#include "TM1637Display.h"
#define CLK_TM1637 7       
#define DIO_TM1637 42
TM1637Display tm1637(CLK_TM1637,DIO_TM1637);

void setup()
{
  tm1637.setBrightness(0x0f);
  tm1637.showNumberDec(1337,false,4,0);
}  
void loop() {
}

using this library.

To communicate with my Arduino board, I use simply the screen shell function πŸ’».

How it works ?

Get RATP schedules πŸ“‹ and alerts πŸ’© in realtime 🌟

GTFS Data

Definition from Wikipedia (en)

A GTFS feed is a collection of CSV files (with extension .txt) contained within a .zip file. Together, the related CSV tables describe a transit system's scheduled operations. The specification is designed to be sufficient to provide trip planning functionality, but is also useful for other applications such as analysis of service levels and some general performance measures. GTFS only includes scheduled operations, and does not include real-time information.

Downloads

It's a little bit difficult to understand how the data is linked πŸ”¬, but you will find the station-id of your station in stops.txt, all the stop schedules (but not the full date, just hh:mm:ss) of your station in stop_times.txt (and all the trips)..

Parser

I recommend to use a parser to aggregate the data. I extracted them with "Node-GTFS" which contains a lot of methods to query for agencies, routes, stops and times. But you can easily find another one in another language.

Real time

To detect if an issue happened πŸ”Ά, you can use the Twitter Streaming API and get all the new tweets of one RATP line. As they always use the same sentences, you will be able to detect if there is a problem or not, or when it has disappeared.

This example will print the new tweets from TWEET_ID_RATP_LINE using TwitterAPI (python)

api = TwitterAPI(consumerKey,consumerSecret,accessToken, accessTokenSecret)

r = api.request('statuses/filter', {'follow': TWITTER_ID_RATP_LINE })

for item in r:
    print(item['text'] if 'text' in item else item)

When there is a new tweet, you have to check πŸ‘“ what is happening. Check if it contains words that refer to an issue ( "colis", "ralenti", "interrompu") or an end of issue ("Retour", "reprise", "rΓ©gulier" ) or other thing.

Those words can be found by analyzing what are the most used words by the community manager.

You can get the πŸ’―x most used words in a file with :

tr -c '[:alnum:]' '[\n*]' < file.txt | sort | uniq -c | sort -nr | head  -100

Just save a html page with a lot of tweets of one RATP line account and fire that query.

They always use the same sentences 😊 :

grep RER A

Twitter accounts :

Wap πŸ’₯

You can "grep" the RATP wap site, but it's clearly not adviced ❗️ - the "CheckMyMetro" app got a lot of issues using this way with RATP.

curl --silent -A "Mozilla/5.0" "http://wap.ratp.fr/{YOURURI}" 2>&1 | grep -E -o "([0-9]+) mn"

Get the number of available bikes 🚲 in a Velib station

✏️ Register an account here and get an API key πŸ”‘.

You can get what you want with a simple query (edit STATIONID and KEY) :

URL_VELIB="https://api.jcdecaux.com/vls/v1/stations/{STATIONID}?contract=paris&apiKey={KEY}"
curl --silent "$URL_VELIB" 2>&1 \
| grep -E -o "\"available_bikes\":[0-9]+," | \
| awk -F ':' '{ print $2 }' | cut -d , -f1;

About πŸ‘€

πŸ™ Special Thanks to : Pupanimbas, Wyb0t, Mathemagie, FranΓ§oisG, E-S, & difrrr.

If you have any question, open an issue.

M.Berchon invited me to introduce this project at the Β« Paris Hardware Startup Meetup #2 Β»

Paris Hardware Startup Meetup #2 Paris Hardware Startup Meetup #2

License

About

Display the Paris Metro schedules :metro: and the number of Velibs :bicyclist: (bicycle-system in Paris) available.

License:Other