Read the statement by Michael Teeuw here.
Can't get json feed to display in any module
-
I’ve tried all the json modules on my rpi3 that I can find (MMM-json-feed, MMM-jsontable, MMM-Tabulator) to get a return from my Windows install of Virtual Radar Server (VRS). I have an rpi2 running a python script that sorts the data from VRS and displays data about the aircraft closest to me, but I didn’t write the script; a friend wrote it for me and I’ve simply modified it over time.
Anyway, I now would like to do the same within MagicMirror2. The url for the json query is http://192.xxx.xxx.xxx/VirtualRadar/AircraftList.json?lat=&lng=&fDstU= where:
is decimal degrees, like 41.54321
is decimal degrees, like -81.12345
is a distance in kilometersThe resulting json is formatted like this:
{"src":1,"feeds":[{"id":1,"name":"ModeSDeco2South","polarPlot":true},{"id":2,"name":"ModeSDeco2West","polarPlot":true},{"id":3,"name":"PiAwareMlatSouth","polarPlot":true},{"id":4,"name":"PiAwareMlatWest","polarPlot":true},{"id":5,"name":"Merged Feed","polarPlot":false}],"srcFeed":1,"showSil":true,"showFlg":true,"showPic":true,"flgH":20,"flgW":85,"acList":[{"Id":12597448,"Rcvr":1,"HasSig":true,"Sig":5,"Icao":"C038C8","Bad":false,"Reg":"C-FVNB","FSeen":"\/Date(1549465130117)\/","TSecs":14,"CMsgs":325,"Alt":1425,"GAlt":1531,"InHg":30.0262051,"AltT":0,"TAlt":4992,"Call":"ACA737","Lat":43.680405,"Long":-79.595947,"PosTime":1549465144594,"Mlat":false,"Tisb":false,"Spd":150.7,"Trak":42.6,"TrkH":false,"TTrk":56.953125,"Type":"B789","Mdl":"787 9","Man":"Boeing","CNum":"38359","From":"YYZ Lester B. Pearson, Toronto, Canada","To":"SFO San Francisco, United States","Op":"Air Canada","OpIcao":"ACA","Sqk":"6316","Help":false,"Vsi":3328,"VsiT":0,"Dst":23.78,"Brng":214.1,"WTC":3,"Species":1,"Engines":"2","EngType":3,"EngMount":0,"Mil":false,"Cou":"Canada","HasPic":false,"Interested":false,"FlightsCount":327,"Gnd":false,"SpdTyp":0,"CallSus":true,"Trt":5},{"Id":12617623,"Rcvr":1,"HasSig":true,"Sig":7,"Icao":"C08797","Bad":false,"Reg":"C-GZJA","FSeen":"\/Date(1549465036968)\/","TSecs":107,"CMsgs":2046,"Alt":4200,"GAlt":4306,"InHg":30.0262051,"AltT":0,"TAlt":7008,"Call":"GGN7385","Lat":43.740875,"Long":-79.492791,"PosTime":1549465144531,"Mlat":false,"Tisb":false,"Spd":285.8,"Trak":79.5,"TrkH":false,"Type":"CRJ2","Mdl":"CRJ 200ER","Man":"Bombardier","CNum":"8018","Op":"Air Canada Express","OpIcao":"GGN","Sqk":"6312","Help":false,"Vsi":1344,"VsiT":0,"Dst":13.92,"Brng":201.1,"WTC":2,"Species":1,"Engines":"2","EngType":3,"EngMount":1,"Mil":false,"Cou":"Canada","HasPic":false,"Interested":false,"FlightsCount":3604,"Gnd":false,"SpdTyp":0,"CallSus":false,"Trt":5},{"Id":12591678,"Rcvr":1,"HasSig":true,"Sig":5,"Icao":"C0223E","Bad":false,"Reg":"C-FMZD","FSeen":"\/Date(1549463057436)\/","TSecs":2087,"CMsgs":7834,"Alt":475,"GAlt":605,"InHg":30.0501976,"AltT":0,"Call":"ACA592","Lat":43.672097,"Long":-79.666901,"PosTime":1549465112804,"Mlat":true,"Tisb":false,"Spd":118.8,"Trak":46.4,"TrkH":false,"Type":"E190","Mdl":"EMB-190 AR","Man":"Embraer","CNum":"19000115","From":"LAS McCarran, Las Vegas, United States","To":"YYZ Lester B. Pearson, Toronto, Canada","Op":"Air Canada","OpIcao":"ACA","Sqk":"7241","Help":false,"Vsi":-640,"VsiT":1,"Dst":28.05,"Brng":222.7,"WTC":2,"Species":1,"Engines":"2","EngType":3,"EngMount":0,"Mil":false,"Cou":"Canada","HasPic":false,"Interested":false,"FlightsCount":2760,"Gnd":false,"SpdTyp":0,"CallSus":true,"Trt":2},{"Id":12706173,"Rcvr":1,"HasSig":true,"Sig":6,"Icao":"C1E17D","Bad":false,"Reg":"YZTX1B","FSeen":"\/Date(1549197839964)\/","TSecs":267304,"CMsgs":151719,"Alt":-1000,"GAlt":-869,"InHg":30.0501976,"AltT":0,"Call":"YZTX1B","Lat":43.674611,"Long":-79.629887,"PosTime":1549465130850,"Mlat":true,"Tisb":false,"Spd":1.4,"Trak":45.0,"TrkH":false,"Type":"BCN","Mdl":"Beacon","Man":"","CNum":"","Op":"Nav Canada","OpIcao":"NAVCAN","Sqk":"0525","Help":false,"Vsi":640,"VsiT":1,"Dst":25.91,"Brng":218.3,"WTC":0,"Species":0,"EngType":0,"EngMount":0,"Mil":false,"Cou":"Canada","HasPic":false,"Interested":false,"FlightsCount":173,"Gnd":false,"SpdTyp":0,"CallSus":false,"Tag":"","Trt":2},{"Id":12706172,"Rcvr":1,"HasSig":true,"Sig":5,"Icao":"C1E17C","Bad":false,"Reg":"YZTX1A","FSeen":"\/Date(1549197839746)\/","TSecs":267305,"CMsgs":197755,"Alt":925,"GAlt":1055,"InHg":30.0501976,"AltT":0,"Call":"YZTX1A","Lat":43.674378,"Long":-79.630476,"PosTime":1549464912944,"Mlat":true,"PosStale":true,"Tisb":false,"Spd":6.1,"Trak":170.5,"TrkH":false,"Type":"BCN","Mdl":"Beacon","Man":"","CNum":"","Op":"Nav Canada","OpIcao":"NAVCAN","Sqk":"3336","Help":false,"Vsi":-2368,"VsiT":1,"Dst":25.96,"Brng":218.3,"WTC":0,"Species":0,"EngType":0,"EngMount":0,"Mil":false,"Cou":"Canada","HasPic":false,"Interested":false,"FlightsCount":147,"Gnd":true,"SpdTyp":0,"CallSus":false,"Tag":"","Trt":2}],"totalAc":95,"lastDv":"636847577530507341","shtTrlSec":120,"stm":1549465144797}
I’d like the closest aircraft from “acList” to be displayed but as I said off the top I can’t get any of the existing json modules to do that. Any clues as to why?
Cheers,
Rob
-
@sonicgoose Can I see some of the code you’ve tried using? It’ll help me help you :)
-
This is the python code I have running on my rpi2. I haven’t tried any code on the rpi3 with MagicMirror2. I was hoping I could just pass the url to one of the 3rd party modules, but it seems not.
#!/usr/bin/python3 import json,requests url = requests.get("http://192.xxx.xxx.xxx/VirtualRadar/AircraftList.json?lat=MYLATITUDE&lng=MYLONGITUDE&fDstU=30") data = json.loads(url.text) acList = (data["acList"]) sortedac = sorted(acList, key=lambda d: d["Dst"]) closestac = (sortedac[0]) print 'Content-type: text/html' print print '<html>' print '<head>' print '<meta http-equiv="refresh" content="5">' print '<link rel="stylesheet" type="text/css" href="../html/proximity.css">' print '<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700" rel="stylesheet">' print '<title>VRS Proximity</title>' print '</head>' print '<body>' try: Reg = closestac['Reg'] except KeyError: Reg = "" pass try: Call = (closestac['Call'] + " -- ") except KeyError: Call = "" pass try: Dst = closestac['Dst'] except KeyError: Dst = "" pass try: OpIcao = closestac['OpIcao'] except KeyError: OpIcao = "" pass try: Op = closestac['Op'] except KeyError: Op = "" pass try: Man = closestac['Man'] except KeyError: Man = "" pass try: Mdl = closestac['Mdl'] except KeyError: Mdl = "" pass try: Brng = closestac['Brng'] except KeyError: Brng = "" pass try: Alt = closestac['Alt'] except KeyError: Alt = "" pass try: Spd = closestac['Spd'] except KeyError: Spd = "" pass print '<h1>',Call,Dst,'kms</h1>' print '<h1>',Reg,'</h1>' print '<h1>',OpIcao,Op,'</h1>' print '<h1>',Man,Mdl,'</h1>' print '<h1>',Brng,'deg,',Alt,'ft,',Spd,'kts</h1>' if OpIcao != "": print ('<img src="../html/images/') + OpIcao + ('_MD.png" height=100 width=425 border=0>') print '</body>' print '</html>'
I appreciate the reply and any help you can provide!
-
@sonicgoose it might be easier for you to just do it through javascript. I’m always looking for something to do so I’d be happy to help you where I can.