JSON parser
-
@skywatch here is an example,
var myImports = new JavaImporter(java.io, java.lang, java.util, java.text); with(myImports) { var response = mcApi.http().get("http://ws1.metcheck.com/ENGINE/v9_0/json.asp?lat=51.6&lon=-1.8&lid=60417&Fc=No"); var json_data = {}; if(response.responseCode == 200) { json_data = JSON.parse(response.entity); // do actions with your json data } }
-
@jkandasa Thank you for the hint!
I pasted it into a new script and it runs and gets a lot of data. What I don't currently know is how to 'get' the data I need into a dashboard display and how to run the script hourly. I guess it is some convoluted arrangement of timers/rules/scripts?
It'll be next week before I get a chance to really have a good look into this, but have watched a few youtube videos on json parsing, so learning a little.
-
@skywatch can you give some more detail on what do you want to display on the dashboard?
single value? more than one value? graph? -
@jkandasa said in JSON parser:
@skywatch can you give some more detail on what do you want to display on the dashboard?
Not any more - the whole thing is broke again - 3 days ago it stopped working at 3.45AM. I still get internal datavia mcagent but no data from any nodes. I removed and re-connected USB to serial converter and all that did was erase all the nodes showing on the resources page. I rebooted the pi, still no node data. I powered off the pi for half an hour, then restarted it - still nothing. I have checked and the GW says it is connected OK. I replaced the radio module and checked it had 3.3V - still not working. I get nothing if I stop myc and tail the serial.
-
@skywatch Can you disable gateway in MyController and check it via putty or another serial monitor tool. Are you receiving data from gateway?
-
@jkandasa You will not believe what I found - I certainly would never have believed it!
Even disabling MyC and using tail and minicom I still got no data. The system has been 'untouched' for weeks so I was not expecting it to be hardware related.
I noticed the LED on the GW pro mini was blinking at regular intervals and that seemed wrong, so I connected it to the PC and monitored it with arduino serial window. Still no data. I erased the eeprom and reflashed the GW sketch and all is working again now.
So somehow it seems that the factory installed 'blink' sketch came back and this seems to be what caused the issue. Does that even make sense???
-
@skywatch So back to the original topic.....
I would like to set it up to do the following......
-
Get latest weather data every hour. It should get the current weather and next 12 hourly forecasts.
-
I would like to display invidividual values for 'current' data on a dashboard (cloud, rain, snow,wind etc.). Then I would like to be able to display an icon for each of the next 12 hours with hourly forecast symbol.
-
It would be nice to be able to graph rain/snow fall.
-
Ideally I would like to be able to use my own weather symbols, but can wait unti ver 2.0 for that
-
-
@skywatch I will try to create a script for this. I am not sure I can cover all of your requirements by my script
-
@jkandasa It is just what I would like to do. It is not at all urgent for me, just would be nice to do sometime.
Maybe better to think of it for version 2.0 than spend time on it now and maybe find a way to make it easier for us mere mortals to do it ourselves.
-
This sounds like the solution to my weather issues. I was looking at OpenWeather and Yahoo until someone mentioned MetCheck... So @skywatch can you please tell me the procedure to pull weather information for MyC via metcheck. Is it free? Do I need to obtain a Key? Where do I append the endpoint in MyC? Can you show me a screengrab of your setup? Thanks in advance.
-
@Emenike It is free. There are no api keys needed. You go to the main Metcheck page, select your location for the weather location you want to use, then towards the bottom of the page is a button labeled 'JSON'. Click that button and it gives you a url to use (just modify the script above for the url it gives you) Sripts are under Utiliries menu in my controller main page. After that manually running the script fetches data fine, but from there on you will need jkandasas help as this is as far as I have got.