openweathermap node suddenly returning 'The API call returned invalid JSON'

564 views
Skip to first unread message

Paul Woodard

unread,
Oct 13, 2015, 6:21:00 AM10/13/15
to Node-RED

The openweathermap node suddenly stopped working on Oct 10th 2015 at app 5:45AM EST. This showed up on three sites I've deployed in seperate locations. I've set up a test site and the only message I get in the debug or log is:
13 Oct 06:06:34 - [error] [openweathermap:Weather] The API call returned invalid JSON 

any ideas?


I have opened an issue on github but if there is more debugging anyone can suggest I'll do it. Thanks!

Pedro Mendes

unread,
Oct 13, 2015, 6:50:17 AM10/13/15
to Node-RED
I had the same happen to me... I have since replaced it with the forecast.io module, but it has the downside that you need to register and you're limited to 1000 API calls a day.
However I find that the information you get from forecast.io is more complete, as you get a full forecast and current conditions within the same msg. Have a try with this flow to see if it works for you:

[{"id":"ccbd8c06.33427","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"bdcdeca1.42321","type":"inject","name":"Metro 1h","topic":"","payload":"","payloadType":"none","repeat":"3600","crontab":"","once":true,"x":145.57144165039062,"y":179.14285278320312,"z":"cd005873.32ffa8","wires":[["3db12042.c24ee"]]},{"id":"6b11854e.94ee7c","type":"mqtt out","name":"","topic":"home/data/weather","qos":"1","retain":"true","broker":"ccbd8c06.33427","x":786.5714721679688,"y":178.14285278320312,"z":"cd005873.32ffa8","wires":[]},{"id":"676dee99.98921","type":"comment","name":"retrieve weather conditions","info":"","x":166.57144165039062,"y":115.14285278320312,"z":"cd005873.32ffa8","wires":[]},{"id":"3db12042.c24ee","type":"forecastio","forecastio":"","name":"Weather Lisbon","lon":"-9.1333333","lat":"38.7166667","date":"","time":"","mode":"node","x":329,"y":179,"z":"cd005873.32ffa8","wires":[["e73899b9.18c768"]]},{"id":"1ea44513.e15bbb","type":"template","name":"format","field":"payload","format":"handlebars","template":"{{#data}}\n{{#currently}}\n{{summary}} - {{temperature}}ºC\n{{/currently}}\n{{/data}}","x":603,"y":179,"z":"cd005873.32ffa8","wires":[["6b11854e.94ee7c"]]},{"id":"e73899b9.18c768","type":"function","name":"F to ºC","func":"var temp = msg.data.currently.temperature;\n// convert farenheit to celsius\ntemp = ((temp-32)*5)/9;\n//round to 1 decimal place\ntemp = Math.round(temp * 10) / 10;\n\nmsg.data.currently.temperature = temp;\nreturn msg;","outputs":1,"noerr":0,"x":479,"y":179,"z":"cd005873.32ffa8","wires":[["1ea44513.e15bbb"]]}]


Mark Setrem

unread,
Oct 13, 2015, 7:04:31 AM10/13/15
to Node-RED

it looks like they are now requiring an APIkey.


If you register for the free API Key you could bodge a fix to enable it still to work until a new version is released.

You could do this by adding the API Key you receive into the weather.js file.  If you don't know what to do reply here and I'm sure we can talk you through it

Paul Woodard

unread,
Oct 13, 2015, 3:50:33 PM10/13/15
to Node-RED
thanks Mark, that did it

For anyone else, I went to /usr/local/lib/node_modules/node-red-node-openweathermap and edited 'weather.js'. At line 55 you will find this code

        //If the URL is not initialised, there has been an error with the input data,
        //and a node.error is reported.
        if (url) {
            node.status({fill:"blue",shape:"dot",text:"requesting"});

add one line after the 'if (url) {' so you have

        //If the URL is not initialised, there has been an error with the input data,
        //and a node.error is reported.
        if (url) {
            url = url + "&APPID=myapiky";
            node.status({fill:"blue",shape:"dot",text:"requesting"});

changing 'myapikey' to your actual API key and you should be set. This should work for COORDINATES or CITY 

Dave C-J

unread,
Oct 13, 2015, 5:25:36 PM10/13/15
to node...@googlegroups.com
I have now updated the node to version 0.1.2 - it now mandates the use of an API key... so should fix the problem... 

Paul Woodard

unread,
Oct 14, 2015, 5:28:30 AM10/14/15
to Node-RED
Just installed v0.1.4 and now when I added to a flow I can't do anything with it. Once added, I can't click it to open it, I can't move it, I can't even delete it from the flow.
This is on a Pi model B
Node-Red V0.10.10
Node.js v0.10.36

Paul Woodard

unread,
Oct 14, 2015, 8:45:57 PM10/14/15
to Node-RED
Hi Dave,

Any thoughts as to why the new openweathermap node can't be accessed? 

Dave C-J

unread,
Oct 15, 2015, 4:23:04 AM10/15/15
to node...@googlegroups.com
Hi Paul,

ah... in Node-RED v0.11 we added Internationalisation support ... and have been updating nodes to support that...  so we have a mismatch... the openweathermap node is expecting to use the translateable messages...

Net is ... either Node-RED needs to be upgraded... or apply a manual fix to the node as per above.

Nicholas O'Leary

unread,
Oct 15, 2015, 4:27:42 AM10/15/15
to Node-RED Mailing LIst
Just to clarify, if you are running node-red 0.10, then you need version 0.0.x of the openweathermap node - and manually apply the API fix to that.

The 0.1.x stream of the openweathermap node requires at least node-red 0.11.


We added the ability for a node to declare it's minimum level of node-red in 0.11 - so we can handle this better in the future.

Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Woodard

unread,
Oct 15, 2015, 5:44:38 AM10/15/15
to Node-RED
Ahhh thank you - updating to node-red 0.11.2 and everything is now working! Thank you very much!
Reply all
Reply to author
Forward
0 new messages