Dashticz - Module - Public Transport
Moderators: leecollings, htilburgs, robgeerts
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Could you send me your config (the transport part) so I can test with it later?
- Luxtux
- Posts: 31
- Joined: Monday 14 August 2017 15:16
- Target OS: Linux
- Domoticz version: 2021.1 β
- Location: Luxembourg
- Contact:
Re: Dashticz - Module - Public Transport
I've added the real-time public transport of Luxembourg to the public transport script. It should show the time a bus or train arrives at a public transport stop in the entire country. just use the name of your stop you normally use on mobiliteit.lu
Code: Select all
var publictransport = {}
publictransport.busstop = { show_via: false, station: 'Luxembourg/Centre, Royal', provider: 'mobiliteit',title:'Royal Stop',show_lastupdate:true, icon: 'bus', width:6, results: 4}
Code: Select all
function loadPublicTransport(random,transportobject,key){
var width = 12;
if(typeof(transportobject.width)!=='undefined') width=transportobject.width;
var html='<div data-id="publictransport.'+key+'" class="col-xs-'+width+'" style="padding-left:0px !important;padding-right:0px !important;">';
if(typeof(transportobject.title)!=='undefined') html+='<div class="col-xs-12 mh titlegroups transbg"><h3>'+transportobject.title+'</h3></div>';
html+='<div class="publictransport publictransport'+random+' col-xs-12 transbg">';
if(typeof(transportobject.icon)!=='undefined' && transportobject.icon!==''){
if(transportobject.icon.substr(0,2)!=='fa') transportobject.icon = 'fa-'+transportobject.icon;
html+='<div class="col-xs-2 col-icon">';
html+='<em class="fa '+transportobject.icon+'"></em>';
html+='</div>';
html+='<div class="col-xs-10 col-data">';
html+='<span class="state"></span>';
html+='</div>';
}
else {
html+='<div class="col-xs-12 col-data">';
html+='<span class="state"></span>';
html+='</div>';
}
html+='</div>';
html+='</div>';
//Get data every interval and call function to create block
var interval = 60;
if(typeof(transportobject.interval)!=='undefined') interval = transportobject.interval;
getData(random,transportobject);
setTimeout(function(){$('.publictransport'+random+' .state').html(language.misc.loading);},100);
if(transportobject.provider.toLowerCase() == 'ns'){
if(parseFloat(interval)<60) interval=60; // limit request because of limitations in NS api for my private key ;)
}
setInterval(function(){
getData(random,transportobject)
},(interval * 1000));
return html;
}
function getData(random,transportobject){
var provider = transportobject.provider.toLowerCase();
if(provider == 'vvs'){
dataURL = 'https://efa-api.asw.io/api/v1/station/'+transportobject.station+'/departures/';
}
else if(provider == 'mobiliteit'){
dataURL = 'https://cors-anywhere.herokuapp.com/http://travelplanner.mobiliteit.lu/restproxy/departureBoard?accessId=cdt&format=json&id=A=1@O$
}
else if(provider == '9292' || provider == '9292-train' || provider == '9292-bus' || provider == '9292-metro' || provider == '9292-tram-bus'){
dataURL = 'https://cors-anywhere.herokuapp.com/http://api.9292.nl/0.1/locations/'+transportobject.station+'/departure-times?lang=nl-NL&time=$
}
$.getJSON(dataURL,function(data){
dataPublicTransport(random,data,transportobject);
});
}
function dataPublicTransport(random,data,transportobject){
var provider = transportobject.provider.toLowerCase();
var dataPart = {}
var i = 0;
for(d in data){
if(provider == '9292' || provider == '9292-train' || provider == '9292-bus' || provider =='9292-metro' || provider == '9292-tram-bus'){
for(t in data[d]){
if(provider == '9292' ||
(data[d][t]['id']=='bus' && provider == '9292-bus') ||
(data[d][t]['id']=='metro' && provider == '9292-metro') ||
(data[d][t]['id']=='tram-bus' && provider == '9292-tram-bus') ||
(data[d][t]['id']=='trein' && provider == '9292-train')
){
deps = data[d][t]['departures'];
for(de in deps){
key = deps[de]['time'];
if(typeof(dataPart[key])=='undefined') dataPart[key]=[];
dataPart[key][i]='';
dataPart[key][i]+='<div><b>'+deps[de]['time']+'</b> ';
if(deps[de]['realtimeText']!=null) dataPart[key][i]+='<span id="latetrain">'+deps[de]['realtimeText'].replac$
if(deps[de]['platform']!=null) dataPart[key][i]+='- Spoor '+deps[de]['platform'];
else dataPart[key][i]+='- Lijn '+deps[de]['service'];
dest = deps[de]['destinationName'].split(' via ');
dataPart[key][i]+=' - '+dest[0];
if(typeof(transportobject.show_via)=='undefined' || transportobject.show_via==true){
if(typeof(dest[1])!=='undefined') dataPart[key][i]+=' via '+dest[1];
else if(typeof(deps[de]['RouteTekst'])!=='undefined') dataPart[key][i]+=' via '+deps[de]['viaNames'];
}
dataPart[key][i]+=' </div>';
i++;
}
}
}
}
else if(provider == 'mobiliteit') {
for(t in data[d]) {
if(data[d][t]['time']==null){
continue;
}
key = data[d][t]['time'];
if(typeof(dataPart[key])=='undefined') dataPart[key]=[];
BusTime = data[d][t]['time'].slice(0,-3);
dataPart[key][i]='';
dataPart[key][i]+='<div><b>'+ BusTime +'</b> ';
dataPart[key][i]+=' - '+data[d][t]['name']+' - ';
//console.log(data[d][t]['time']+ ' - ' +data[d][t]['name']+ ' - ' +data[d][t]['direction'] );
dest = data[d][t]['direction'].split(' via ');
dataPart[key][i]+=dest[0];
if(typeof(transportobject.show_via)=='undefined' || transportobject.show_via==true){
if(typeof(dest[1])!=='undefined') dataPart[key][i]+=' via '+dest[1];
}
dataPart[key][i]+=' </div>';
}
}
else if(provider == 'vvs'){
arrivalTime = data[d]['departureTime']['year']+':'+data[d]['departureTime']['month']+':'+data[d]['departureTime']['day']+':'+addZero$
arrivalTimeShow = addZero(data[d]['departureTime']['hour'])+':'+addZero(data[d]['departureTime']['minute']);
if(typeof(dataPart[arrivalTime])=='undefined') dataPart[arrivalTime]=[];
dataPart[arrivalTime][i] = '';
arrivalTimeScheduled = addMinutes(arrivalTimeShow, data[d]['delay']*-1);
dataPart[arrivalTime][i]+='<div><b>'+arrivalTimeShow+'</b> ';
if(data[d]['delay'] == 0) latecolor='notlatetrain';
if(data[d]['delay'] > 0) latecolor='latetrain';
dataPart[arrivalTime][i]+='<span id="'+latecolor+'">+'+data[d]['delay']+' Min.</span> ';
dataPart[arrivalTime][i]+='<span id="departureScheduled">('+language.misc.scheduled+': '+arrivalTimeScheduled+')</span> ';
dataPart[arrivalTime][i]+='- '+data[d]['number']+' ';
dest = data[d]['direction'].split(' via ');
dataPart[arrivalTime][i]+=dest[0];
if(typeof(transportobject.show_via)=='undefined' || transportobject.show_via==true){
if(typeof(dest[1])!=='undefined') dataPart[arrivalTime][i]+=' via '+dest[1];
}
dataPart[arrivalTime][i]+='</div>';
i++;
}
}
$('.publictransport'+random+' .state').html('');
var c = 1;
Object.keys(dataPart).forEach(function(d) {
//Object.keys(dataPart).sort().forEach(function(d) {
for(p in dataPart[d]){
if(c<=transportobject.results) $('.publictransport'+random+' .state').append(dataPart[d][p]);
c++;
}
});
if(typeof(transportobject.show_lastupdate)!=='undefined' && transportobject.show_lastupdate==true){
var dt = new Date();
$('.publictransport'+random+' .state').append('<em>'+language.misc.last_update+': '+addZero(dt.getHours()) + ":"+addZero(dt.getMinutes())+":$
}
}
function addZero(input){
if(input < 10){
return '0' + input;
}
else{
return input;
}
}
function addMinutes(time/*"hh:mm"*/, minsToAdd/*"N"*/) {
function z(n){
return (n<10? '0':'') + n;
}
var bits = time.split(':');
var mins = bits[0]*60 + (+bits[1]) + (+minsToAdd);
return z(mins%(24*60)/60 | 0) + ':' + z(mins%60);
}
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Although your code didnt work immediately (forgot an ' and forgot to add a variable to te script) I fixed this and added mobiliteit.lu to the latest beta!
Thanks!
Thanks!
- Luxtux
- Posts: 31
- Joined: Monday 14 August 2017 15:16
- Target OS: Linux
- Domoticz version: 2021.1 β
- Location: Luxembourg
- Contact:
Re: Dashticz - Module - Public Transport
little update for mobiliteit. it now shows the delay if bus/train or tram is equipped with live tracking.
Code: Select all
else if(provider == 'mobiliteit') {
for(t in data[d]) {
if(data[d][t]['time']==null){
continue;
}
key = data[d][t]['time'];
if(typeof(dataPart[key])=='undefined') dataPart[key]=[];
var fullArrivalDate = data[d][t]['date'] + ' ' + data[d][t]['time'];
var arrivalTime = moment(fullArrivalDate);
var delay = 'Null';
if (data[d][t]['rtTime']) {
var fullRealArrivalDate = data[d][t]['rtDate'] + ' ' + data[d][t]['rtTime'];
var realArrivalTime = moment(fullRealArrivalDate);
var delay = '+' + realArrivalTime.diff(arrivalTime, 'minutes');
}
dataPart[key][i]='';
dataPart[key][i]+='<div><b>'+ arrivalTime.format('HH:mm') +'</b> ';
if (delay <= 0) {
dataPart[key][i]+='<span id="notlatetrain">'+delay+'</span> ';
}
else if (delay > 0) {
dataPart[key][i]+='<span id="latetrain">'+delay+'</span> ';
}
dataPart[key][i]+=' - '+data[d][t]['name']+' - ';
dest = data[d][t]['direction'].split(' via ');
dataPart[key][i]+=dest[0];
if(typeof(transportobject.show_via)=='undefined' || transportobject.show_via==true){
if(typeof(dest[1])!=='undefined') dataPart[key][i]+=' via '+dest[1];
}
dataPart[key][i]+=' </div>';
}
}
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Added to latest beta! Thanks!
-
- Posts: 20
- Joined: Friday 18 November 2016 11:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
Is this an option already? I would love to have the option to select an offset of for example 30 min. So I will only see trains departing 30 min or later from now. At the moment I only see trains that I will never be able to make, as I need 30 min to get to the station and the list of departures in the next 30 min is too long for my screen....freakshock wrote: ↑Tuesday 16 May 2017 21:06 Idea for a configurable feature for this module:
How about making it possible to exclude results between the current time and the first departure time listed?
For instance: I have added my local trainstation near my house. It takes at least 15 minutes from my house to get there. It would be nice to be able to exclude results that show the trains leaving from the current time +15 minutes.
If I don't have this feature I have to make my list really long![]()
Re: Dashticz - Module - Public Transport
Hi everybody and special thanks to Robgeert for his huge work!
I'm trying to use the module for transportation in my city but i'm not able to develop the missing code alone
Is there someone to help me? I will send username and password by PM to the ones who want to help.
This is the URL :
This is the JSON structure :
Thank you veeeery much !
Brunard
I'm trying to use the module for transportation in my city but i'm not able to develop the missing code alone

Is there someone to help me? I will send username and password by PM to the ones who want to help.
This is the URL :
Code: Select all
http://opendata.cts-strasbourg.eu/webservice_v5_alpha/opendata_v5.svc/getnextdepartures/<USERNAME>/<PASSWORD>/<STATION NUMBER>
Code: Select all
{"departures":[{"destination":"2 Elmerforst","mode":"Bus","time":"21:03:11"},{"destination":"B Lingolsheim Tiergaertel","mode":"Tram","time":"21:05:07"},{"destination":"B Hoenheim Gare","mode":"Tram","time":"21:05:41"},{"destination":"F Elsau","mode":"Tram","time":"21:10:38"},{"destination":"2 Jardin des Deux Rives","mode":"Bus","time":"21:10:42"},{"destination":"L1 Lingolsheim Alouettes","mode":"Bus","time":"21:14:42"},{"destination":"F Place d'Islande","mode":"Tram","time":"21:15:16"}],"requestedtime":"21:01","serverdatetime":"01\/02\/2018 21:01:31","stop":"Laiterie"}
Brunard
-
- Posts: 80
- Joined: Saturday 19 March 2016 21:12
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
How can i use it with the ferry, like "https://9292.nl/alblasserdam/halte-veer-kade"robgeerts wrote: ↑Tuesday 16 May 2017 13:16 Yes, use:
Code: Select all
var publictransport = {} publictransport.ovinfobus= { station: 'andelst/bushalte-wilhelminastraat', provider: '9292-bus', icon: 'bus', results: 5 };
When i use station: 'alblasserdam/halte-veer-kade' it won't respond
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Could you test this in latest beta:
Code: Select all
var publictransport = {}
publictransport.ovinfobus= { key:'ovinfobus', show_via: false, station: 'alblasserdam/bushalte-veer-kade', provider: '9292-boat', icon: 'ship', width:5, results: 6 }
-
- Posts: 80
- Joined: Saturday 19 March 2016 21:12
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
Thanks for your reply. Tried it, only get "Loading..."robgeerts wrote: ↑Tuesday 06 February 2018 21:06 Could you test this in latest beta:
Code: Select all
var publictransport = {} publictransport.ovinfobus= { key:'ovinfobus', show_via: false, station: 'alblasserdam/bushalte-veer-kade', provider: '9292-boat', icon: 'ship', width:5, results: 6 }
Edit: Don't know if it help searching, but i noticed in the publictransport.js that provider == '9292-boat' is not in all the lines as for example 9292-train is. I tried to add them if to see if it helps, but no success so far, but i am not an programmer.
-
- Posts: 80
- Joined: Saturday 19 March 2016 21:12
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
@robgeerts, do you have any idea? Hope to get this working.clubeddie wrote: ↑Tuesday 06 February 2018 22:44Thanks for your reply. Tried it, only get "Loading..."robgeerts wrote: ↑Tuesday 06 February 2018 21:06 Could you test this in latest beta:
Code: Select all
var publictransport = {} publictransport.ovinfobus= { key:'ovinfobus', show_via: false, station: 'alblasserdam/bushalte-veer-kade', provider: '9292-boat', icon: 'ship', width:5, results: 6 }
Edit: Don't know if it help searching, but i noticed in the publictransport.js that provider == '9292-boat' is not in all the lines as for example 9292-train is. I tried to add them if to see if it helps, but no success so far, but i am not an programmer.
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Did you update to latest beta???
-
- Posts: 32
- Joined: Saturday 24 February 2018 12:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
Train is not showing any notifications. It keeps saying “0 notifications” but when you click the button rijdendetreinen.nl does give notifications.
I checked the JS file with traffic (wich is basically the same module) but cant’t find anything why i shoudn’t work. Traffic namely does work
Anyone here have a clue?
I checked the JS file with traffic (wich is basically the same module) but cant’t find anything why i shoudn’t work. Traffic namely does work
Anyone here have a clue?
-
- Posts: 32
- Joined: Saturday 24 February 2018 12:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
Found the cause for the "0 meldingen" on "train"
In NS.js
Change "item" to "title". I now have 12 notifications
In NS.js
Code: Select all
var count = 0;
$(data).find("item").each(function () { // or "item" or whatever suits your feed
var el = $(this);
if(el.find("title").text().substr(0,8)!=='Opgelost'){
count++;
Code: Select all
count = 0;
$(data).find("title").each(function () { // or "item" or whatever suits your feed
var el = $(this);
if(el.find("title").text().substr(0,8)!=='Opgelost'){
count++;
-
- Posts: 7
- Joined: Sunday 01 April 2018 14:16
- Target OS: NAS (Synology & others)
- Domoticz version: 3.9056
- Location: Netherlands
- Contact:
Re: Dashticz - Module - Public Transport
I've finally got a new NAS capable of running Domoticz/Dashticz and I am really impressed by the great work/contributions of the developers!
I wanted a title bar in my bus, but dislike the original approach. So I started fiddling and wanted to share my result with you here:
publictransport.js
* I removed transportobject.title from the top and added it to the col-icon creation.
CSS
This also gives the col-icon some more room at the bottom when it moves to the top.
Someone more gifted with CSS can perhaps make the title text disappear when the icon is situated on the left and show the title when it's at the top perhaps.
I wanted a title bar in my bus, but dislike the original approach. So I started fiddling and wanted to share my result with you here:
publictransport.js
* I removed transportobject.title from the top and added it to the col-icon creation.
Code: Select all
html+='<div class="col-icon">';
html+='<em class="fa '+transportobject.icon+'"></em>';
html+='<div class="col-title">';
if(typeof(transportobject.title)!=='undefined') html+=transportobject.title;
html+='</div>';
html+='</div>';
Code: Select all
.col-icon {
padding-bottom: 8px;
}
.fa {
display: inline
}
.col-title {
font-weight: bold;
font-size:15px;
display: inline;
padding-left: 12px;
}
@media (max-width: 1400px) {
.transbg.col-xs-1, .transbg.col-xs-2, .transbg.col-xs-3, .transbg.col-xs-4, .transbg.col-xs-5, .transbg.col-xs-6, .transbg.col-xs-7, .transbg.col-xs-8, .transbg.col-xs-9, .transbg.col-xs-10, .transbg.col-xs-11, .transbg.col-xs-12 {
padding-top: 8px;
}
.col-icon {
padding-bottom: 4px;
}
.fa {
padding-right: 3px;
}
.col-title {
padding-left: 4px;
font-size: 12px;
}
}
Someone more gifted with CSS can perhaps make the title text disappear when the icon is situated on the left and show the title when it's at the top perhaps.
DS-218+ with Jadahl Domoticz
-
- Posts: 7
- Joined: Sunday 01 April 2018 14:16
- Target OS: NAS (Synology & others)
- Domoticz version: 3.9056
- Location: Netherlands
- Contact:
Re: Dashticz - Module - Public Transport
On a different note;
I wonder if it perhaps is a good idea to put a busstop in the ovinfobus config example so people don't have to search for an hour to work out that the placename uses a forward slash as divider, and not a dash:
leusden/bushalte-rossenberglaan
I wonder if it perhaps is a good idea to put a busstop in the ovinfobus config example so people don't have to search for an hour to work out that the placename uses a forward slash as divider, and not a dash:
leusden/bushalte-rossenberglaan
DS-218+ with Jadahl Domoticz
-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Changed in latest beta!Beschuitje wrote: ↑Saturday 24 March 2018 17:42 Found the cause for the "0 meldingen" on "train"
In NS.js
Change "item" to "title". I now have 12 notificationsCode: Select all
var count = 0; $(data).find("item").each(function () { // or "item" or whatever suits your feed var el = $(this); if(el.find("title").text().substr(0,8)!=='Opgelost'){ count++;
Code: Select all
count = 0; $(data).find("title").each(function () { // or "item" or whatever suits your feed var el = $(this); if(el.find("title").text().substr(0,8)!=='Opgelost'){ count++;
-
- Posts: 16
- Joined: Thursday 26 April 2018 15:27
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Dashticz - Module - Public Transport
Hoi Rob,
allereerst complimenten voor je werk.
Ik was wat aan het neuzen, en de 9292 api is gewoon publiekelijk benaderbaar. Ik zag ook dat daar geen tijdsfiltering in zat, dus ik vermoed dat je zelf zo'n filtering in je .php hebt gebouwd? Ik zou graag een target-destination willen opgeven zodat ik alleen de bus van mijn huis naar het station in de lijst krijg, en aanvullend ook een 'aankomstlijst' zou kunnen maken. Heb je daar al iets voor op de planning staan? Anders moet ik het zelf even filteren in de javascript
allereerst complimenten voor je werk.
Ik was wat aan het neuzen, en de 9292 api is gewoon publiekelijk benaderbaar. Ik zag ook dat daar geen tijdsfiltering in zat, dus ik vermoed dat je zelf zo'n filtering in je .php hebt gebouwd? Ik zou graag een target-destination willen opgeven zodat ik alleen de bus van mijn huis naar het station in de lijst krijg, en aanvullend ook een 'aankomstlijst' zou kunnen maken. Heb je daar al iets voor op de planning staan? Anders moet ik het zelf even filteren in de javascript

-
- Posts: 1273
- Joined: Saturday 24 January 2015 22:12
- Target OS: NAS (Synology & others)
- Domoticz version: 3.7067
- Location: NL
- Contact:
Re: Dashticz - Module - Public Transport
Thanks for your compliments.Ectholian wrote: ↑Thursday 26 April 2018 15:33 Hoi Rob,
allereerst complimenten voor je werk.
Ik was wat aan het neuzen, en de 9292 api is gewoon publiekelijk benaderbaar. Ik zag ook dat daar geen tijdsfiltering in zat, dus ik vermoed dat je zelf zo'n filtering in je .php hebt gebouwd? Ik zou graag een target-destination willen opgeven zodat ik alleen de bus van mijn huis naar het station in de lijst krijg, en aanvullend ook een 'aankomstlijst' zou kunnen maken. Heb je daar al iets voor op de planning staan? Anders moet ik het zelf even filteren in de javascript![]()
I will take this in consideration!
But, if you have some spare time, you can always add a pull request

Who is online
Users browsing this forum: No registered users and 1 guest