Skip to content

Commit

Permalink
Fix/transilien 2023 (#14)
Browse files Browse the repository at this point in the history
* feature(transilien): switch to new API - WIP

* test(transilien): adapt / disable unit tests - WIP

* test(transilien): clean test code - WIP

* feature(transilien): convert unicode characters

* doc(README): update instructions for transilien

* feature(transilien): handle unknown platform data

* chore(git): ignore coverage files

* test(support): add unit tests for cache

* chore(support): enable flow on cache tests

* test(support): add unit tests for configuration

* test(server): add unit tests for helper

* doc(api/README): add normalization instructions

* feature(server): handle empty schedules for transilien (end of service)

* feature(server): return default schedule when no info available + unit tests

* feature(client): dynamically adjust marquee speed for traffic messages

* doc(images): add transilien screen

* doc(README): add screenshot

* doc(README): update CI branch

* doc(README): try with encoded branch name for CI status badge

* doc(README): change CI badge URL

* chore(release): prepare release version
  • Loading branch information
djey47 authored Mar 2, 2024
1 parent ece58b5 commit b6f815e
Show file tree
Hide file tree
Showing 30 changed files with 57,791 additions and 2,836 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ A module to display:
# Screenshots
![screenshot](https://github.com/djey47/MMM-IDF-LOCALTRANSPORT/blob/master/images/MMM-IDF-LOCALTRANSPORT1.png)
![screenshot](https://github.com/djey47/MMM-IDF-LOCALTRANSPORT/blob/master/images/MMM-IDF-LOCALTRANSPORT2.png)
![screenshot](https://github.com/djey47/MMM-IDF-LOCALTRANSPORT/blob/master/images/MMM-IDF-LOCALTRANSPORT-TRANSILIEN-2023.png)

# API
API examples are provided into `api` subdirectory, as [POSTMAN collections](https://www.getpostman.com/).
* RERs, Metros, Buses and Tramways infos are provided by [P.Grimaud's API](https://github.com/pgrimaud/horaires-ratp-api) via RATP services
* Transilien infos are based on the REST API provided by [TRANSILIEN](https://ressources.data.sncf.com/explore/dataset/api-temps-reel-transilien/) and [SNCF](https://ressources.data.sncf.com)
* Transilien infos are based on the REST API provided by [IDF Mobilités](https://data.iledefrance-mobilites.fr/pages/home/)
* Traffic data for transilien comes from [Citymapper API](https://citymapper.com/paris)
* It also uses [Paris Open Data for Velib](https://opendata.paris.fr/explore/dataset/stations-velib-disponibilites-en-temps-reel/) (use it to get the 5 digits stations you will need for the configuration)

Expand All @@ -30,12 +31,10 @@ To use this API you need to request credentials, please create account [HERE](ht

Once key has been given to you back, you've just to enter it in configuration file for `citymapperToken` value.

## Transilien realtime API
To use this API you need to request credentials, please ask by sending email [HERE](mailto:innovation-transilien@sncf.fr?subject=Demande%20acc%C3%A8s%20API%20prochains%20d%C3%A9parts&body=nom,%20pr%C3%A9nom,organisation,utilisation).
## Transilien realtime API with IDF Mobilités
To use this API you need to create an account and request a dynamic token, please submit it [HERE](https://prim.iledefrance-mobilites.fr/fr/mes-jetons-authentification).

Once login/password have been given to you back, generate token value: open a browser window, press F12 and execute following code in console: `window.btoa(unescape(encodeURIComponent('LOGIN:PASSWORD')))`. Copy result to clipboard.

Finally, `transilienToken` value to be entered in configuration file will be `Basic <pasted value from keyboard>`.
Finally, `transilienToken` value to be entered in configuration file will be the generated token value.

# Install

Expand Down Expand Up @@ -73,32 +72,32 @@ Finally, `transilienToken` value to be entered in configuration file will be `Ba
- `line`: Mandatory for 'bus', 'rers', and 'tramways': typically the official name but you can check through:
- 'bus-metros-rers-tramways': https://api-ratp.pierre-grimaud.fr/v3/lines/bus, https://api-ratp.pierre-grimaud.fr/v3/lines/rers, https://api-ratp.pierre-grimaud.fr/v3/lines/tramways, https://api-ratp.pierre-grimaud.fr/v3/lines/metros
- traffic: https://api-ratp.pierre-grimaud.fr/v3/traffic, set the line as: [type, line], such as: ['metros', 6], ['rers', 'A']...
- transiliensTraffic: set the line as code, such as: 'L', 'J'...
- not used for 'transiliens' and 'transiliensTraffic' .
- transiliens and transiliensTraffic: set the line as code, such as: 'L', 'J'...
- `station`: Mandatory: [name of the station] ->
- for 'bus-rers-tramways-metros', https://api-ratp.pierre-grimaud.fr/v3/stations/{type}/{line}
- for 'velib', you can search here: https://opendata.paris.fr/explore/dataset/stations-velib-disponibilites-en-temps-reel/
- for 'transiliens', https://ressources.data.sncf.com/explore/dataset/referentiel-gares-voyageurs/?sort=intitule_gare
- for 'transiliens', valid stations names are listed [HERE](https://data.iledefrance-mobilites.fr/explore/dataset/arrets/export/?refine.arrtype=rail) and line names are [HERE](https://data.iledefrance-mobilites.fr/explore/dataset/referentiel-des-lignes/export/?disjunctive.transportmode&disjunctive.transportsubmode&disjunctive.operatorname&disjunctive.networkname&refine.transportmode=rail)
- not used for 'traffic' and 'transiliensTraffic'.
- `destination`:
- Mandatory for 'metros', 'bus', 'rers' & 'tramways': either 'A' or 'R'
- Optional for 'velib': ['leaving', 'arriving', '']: indicate if only one value is needed //not in use yet
- Optional for 'transiliens': shows train matching this destination only (see station repository above)
- not used for 'traffic' and 'transiliensTraffic'.
- `uic`: ('transiliens' only) : UIC codes for station and destination (useful when names are not sufficient to identify)
- Optional, if not provided, station and destination codes will be resolved from names provided above
- `station` element: code
- `destination` element (optional): code
- `transilienRefData`: ('transiliens' only) : reference data codes for line, station (stop area) and destination (useful when names are not sufficient to identify)
- Optional, if not provided, line, station and destination codes will be resolved from names provided above
- `lineRef` element: code from 'id_line'
- `stopAreaRef` element: code from 'zdaid'
- `destinationRef` element (optional): code fomr 'arrid'
- `label`: Optional, to rename the line differently if needed.
* `transilienToken`: 'Basic xxxxxxxx' : mandatory to access transilien realtime API (account required, see section above)
* `transilienToken`: 'xxxxxxxx' : mandatory to access transilien realtime API (account required, see section above)
* `citymapperToken`: 'xxxxxxxx' : mandatory to access citymapper realtime API (account required, see section above)
* `messages`: (Optional, see example below) : key-values to convert generic messages to your preferred language
- If not provided, some default messages are used (in english)
- To make changes, paste ALL default values and modify to your likings.

Example:
```javascript
transilienToken: 'Basic bG9naW46cGFzc3dvcmQ=',
transilienToken: 'bG9naW46cGFzc3dvcmQ',

stations: [
// Next transport at stops (bus, metros, rers, tramways)
Expand All @@ -109,11 +108,11 @@ stations: [

// Next transport at stops (transiliens)
// With station name only to catch all destinations:
{type: 'transiliens', station: 'BECON LES BRUYERES', label: 'Becon L'},
{type: 'transiliens', station: 'BECON LES BRUYERES', label: 'Becon L', line: 'L'},
// With station and destination names to filter:
{type: 'transiliens', station: 'BECON LES BRUYERES', destination: 'NANTERRE UNIVERSITE'},
// With UIC codes:
{type: 'transiliens', station: 'BECON LES BRUYERES', destination: 'SAINT NOM LA BRETECHE', uic: { station: '87382002', destination: '87382481'} },
{type: 'transiliens', station: 'BECON LES BRUYERES', destination: 'NANTERRE UNIVERSITE', line 'L'},
// With reference data codes:
{type: 'transiliens', station: 'BECON LES BRUYERES', destination: 'SAINT NOM LA BRETECHE', transilienRefData: { lineRef: 'C01740', stopAreaRef: '87382002', destinationRef: '471811'} },

// Traffic status (bus, metros, rers, tramways)
{type: 'traffic', line: ['rers', 'B']},
Expand Down
3 changes: 2 additions & 1 deletion css/module.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
left: 100%;
height: inherit;
white-space: nowrap;
animation: marquee 20s linear infinite;

/* Animation parameters handled from JS */
}

@keyframes marquee {
Expand Down
Binary file added images/MMM-IDF-LOCALTRANSPORT-TRANSILIEN-2023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b6f815e

Please sign in to comment.