Skip to content

Commit e051838

Browse files
authored
Merge pull request #25 from da4throux/hideStatus
2.1 - Hide status
2 parents dd79541 + 023333c commit e051838

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

MMM-Paris-RATP-PG.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ Module.register("MMM-Paris-RATP-PG",{
3939
concatenateArrivals: true, //if for a transport there is the same destination and several times, they will be displayed on one line
4040
initialLoadDelay: 0, // start delay seconds
4141
showUpdateAge: true,
42-
pluieAsText: false
42+
pluieAsText: false,
43+
conversion: {},
44+
hideTraffic: [],
4345
},
46+
updateDomFrequence: 10000,
4447
},
4548

4649
// Define required scripts.
@@ -59,6 +62,7 @@ Module.register("MMM-Paris-RATP-PG",{
5962
for (i=0; i < this.config.lines.length; i++) {
6063
this.config.infos[i]={};
6164
l = Object.assign(JSON.parse(JSON.stringify(this.config.line_template)),
65+
JSON.parse(JSON.stringify(this.config.lineDefault)),
6266
JSON.parse(JSON.stringify(this.config.lines[i])));
6367
l.id = i;
6468
switch (l.type) {
@@ -85,7 +89,7 @@ Module.register("MMM-Paris-RATP-PG",{
8589
setInterval(function () {
8690
self.caller = 'updateInterval';
8791
self.updateDom();
88-
}, 1000);
92+
}, this.config.updateDomFrequence);
8993
},
9094

9195
getHeader: function () {
@@ -146,13 +150,15 @@ Module.register("MMM-Paris-RATP-PG",{
146150
row.appendChild(firstCell);
147151
secondCell = document.createElement("td");
148152
secondCell.className = "align-left";
149-
secondCell.innerHTML = d.status ? this.config.conversion[d.status.message] || d.status.message : 'N/A';
153+
secondCell.innerHTML = d.status ? l.conversion[d.status.message] || d.status.message : 'N/A';
150154
secondCell.colSpan = 2;
151155
if (lineColor) {
152156
secondCell.setAttribute('style', lineColor);
153157
}
154158
row.appendChild(secondCell);
155-
table.appendChild(row);
159+
if (l.hideTraffic.indexOf(d.status.message) < 0) {
160+
table.appendChild(row);
161+
}
156162
break;
157163
case "bus":
158164
case "metros":

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Three different kind of objects are in the configuration:
4545
* destination: mandatory, either 'A' or 'R'
4646
### Traffic
4747
* line: mandatory, based on https://api-ratp.pierre-grimaud.fr/v3/traffic set the line as: [type, line], such as: ['metros', 6], ['rers', 'A']...
48+
* hideTraffic: optional, array of string, if a traffic status belongs to the array, then the traffic is not shown (see the example for usage)
4849
### Common in Transportation lines
4950
* maximumEntries: optional, int, default = 2, //if the APIs sends several results for the incoming transport how many should be displayed
5051
* converToWaitingTime: optional, boolean, default = true, // messages received from API can be 'hh:mm' in that case convert it in the waiting time 'x mn'
@@ -56,22 +57,34 @@ Three different kind of objects are in the configuration:
5657
* pluieAsText: optional, boolean, default = false, // show the weather in the coming hour as text and not icons
5758
* iconSize: optional, example: 0.70, //set the em for the weather icon (each icon is 5 minutes: i.e. there's 12 icons for an hour)
5859
### common in all lines
60+
* common means: not shared value, but meaningful for all the lines
5961
* label: Optional: to rename the object differently if needed
6062
* updateInterval: optional, int, default: 60000, time in ms between pulling request for new times (update request)
6163
* showUpdateAge: optional, boolean, default = true, //add a circled integer next to the line name showing the tenths digits of the number of seconds elapsed since update.
6264
* firstCellColor: optional, color name, // typically first column of the line (superseed the line color): https://dataratp2.opendatasoft.com/explore/dataset/indices-et-couleurs-de-lignes-du-reseau-ferre-ratp/ or wikipedia can give you insights
6365
* lineColor: optional, color name, //set the color of the line
6466
## Global element
6567
* debug: false, //console.log more things to help debugging
68+
## lineDefault
69+
* lineDefault contains properties that will be common to all lines, but can be superseed at the line level also: so any property from the line, can be set here also, but the following ones, make more sense here also:
6670
* conversion: object of key/ values to convert traffic message. Those message can be very long, and it might worth to convert them in a simpler text. by default:
6771
- conversion: {"Trafic normal sur l'ensemble de la ligne." : 'Traffic normal'}
6872
- don't hesitate to add more when there's works on a specific line or others...
73+
* updateInterval: see above
6974

7075
Config Example:
7176
```javascript
7277
config: {
73-
conversion: { "Trafic normal sur l'ensemble de la ligne." : 'Traffic normal'},
7478
debug: false,
79+
lineDefault: {
80+
hideTraffic: [
81+
"le trafic est interrompu entre Aulnay et Aeroport Charles de Gaulle 2 TGV de 23:00 à fin de service jusqu'au 16/03/18. Bus de remplacement à dispo. (travaux de modernisation)",
82+
"Trafic normal sur l'ensemble de la ligne.",
83+
"le trafic est interrompu entre Nanterre-Prefecture et Cergy/ Poissy de 21:30 à fin de service jusqu'au 16/02/18. Bus de remplacement à dispo. (travaux)",
84+
],
85+
conversion: { "Trafic normal sur l'ensemble de la ligne." : 'Traffic normal'},
86+
updateInterval: 1 * 2 * 60 * 1000,
87+
},
7588
lines: [
7689
{type: 'bus', line: 38, stations: 'observatoire+++port+royal', destination: 'A', firstCellColor: '#0055c8'},
7790
{type: 'bus', line: 91, stations: 'observatoire+++port+royal', destination: 'A', firstCellColor: '#dc9600'},
@@ -83,4 +96,4 @@ config: {
8396
],
8497
},
8598
```
86-
# v2.0
99+
# v2.1

0 commit comments

Comments
 (0)