WeatherUnderground flow to Emoncms

281 views
Skip to first unread message

Blue Collar Ingenuity

unread,
Dec 8, 2015, 7:56:32 PM12/8/15
to Node-RED
It looks like it should work but it doesn't! I know my javascript is weak, been at this for 3 hours with every combination I can think of. I have my Energy and local temp reporting to Emoncms. I can't figure out why this wont work? 
Emoncms see's my inject temp:7 ok , but doesn't see any of my parsed weather data. 

[{"id":"5a65afcb.a59a5","type":"emoncms-server","z":"","server":"http://emoncms.org","name":"cormad"},{"id":"c27e139.f3d81f","type":"wunderground","z":"ff2aad21.00d55","name":"Belleville Weather ","lon":"-77.3","lat":"44.1","city":"","country":"","x":451,"y":504,"wires":[["d95fa94b.26a058","964c2dd2.69b3d","98754aa2.678ab8"]]},{"id":"ebaafd61.1455","type":"inject","z":"ff2aad21.00d55","name":"Every 10 Minutes","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"x":209,"y":498,"wires":[["c27e139.f3d81f"]]},{"id":"c263fbd5.3d9c08","type":"debug","z":"ff2aad21.00d55","name":"","active":true,"console":"false","complete":"false","x":887,"y":471,"wires":[]},{"id":"d95fa94b.26a058","type":"function","z":"ff2aad21.00d55","name":"Temperature","func":"msg.payload = \"OutTemp :\" +Number(msg.payload.tempc) ;\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":437,"wires":[["c263fbd5.3d9c08","86433edc.79bcc"]]},{"id":"964c2dd2.69b3d","type":"function","z":"ff2aad21.00d55","name":"Humidity","func":"msg.payload = \"HumidityOutside :\" +parseInt(msg.payload.humidity) ;\nreturn msg;","outputs":1,"noerr":0,"x":658,"y":489,"wires":[["c263fbd5.3d9c08","86433edc.79bcc"]]},{"id":"98754aa2.678ab8","type":"function","z":"ff2aad21.00d55","name":"Windspeed","func":"msg.payload = \"WindSpeed :\"+parseFloat(msg.payload.windspeed).toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":659,"y":555,"wires":[["86433edc.79bcc","c263fbd5.3d9c08"]]},{"id":"a99fd64b.566028","type":"comment","z":"ff2aad21.00d55","name":"Belleville Weather","info":"","x":186,"y":403,"wires":[]},{"id":"86433edc.79bcc","type":"emoncms","z":"ff2aad21.00d55","name":"Emoncms","emonServer":"5a65afcb.a59a5","nodegroup":"3","x":893,"y":556,"wires":[]},{"id":"8f306398.70cfa","type":"inject","z":"ff2aad21.00d55","name":"","topic":"","payload":"Temp :8","payloadType":"string","repeat":"","crontab":"","once":false,"x":491,"y":674,"wires":[["86433edc.79bcc","d513af91.2aec5"]]},{"id":"d513af91.2aec5","type":"debug","z":"ff2aad21.00d55","name":"","active":true,"console":"false","complete":"false","x":777,"y":706,"wires":[]}]

Jeff 

Jon Murphy

unread,
Dec 8, 2015, 10:01:14 PM12/8/15
to Node-RED
Hey Jeff - I am parsing WU data to a local emoncms (on on emonPi).
On the output of the WU I added a "json" node (from the Function area).  This converts the javascript object to a JSON string.  Then add a Function node with something like this:

var wxdata = JSON.parse(msg.payload);
msg.payload={};
msg.payload=wxdata.current_observation.temp_c  + ","
+ wxdata.current_observation.relative_humidity.replace("%","") + ","
+ wxdata.current_observation.observation_epoch;
return msg;

Hope this helps!   Jon

Dave C-J

unread,
Dec 9, 2015, 4:21:32 AM12/9/15
to node...@googlegroups.com
Hi,

actually this has highlighted a bug in the emoncms node... - the WU node is returning msg.time - but in the wrong format for emoncms - so the data post is failing.
I have now fixed the node and republished it as version 0.0.7.
so you can either update... or the simple fix is to delete the msg.time property in your functions like this

[{"id":"79466e1b.86b99","type":"emoncms-server","z":"","server":"http://emoncms.org","name":"cormad"},{"id":"7c91d42e.836e2c","type":"wunderground","z":"9e538f88.61ac7","name":"Belleville Weather ","lon":"-77.3","lat":"44.1","city":"","country":"","x":439,"y":1873,"wires":[["6b706f0f.948f9","dcc32283.233ce","4b581661.b4a7e8"]]},{"id":"4dab24fa.b254dc","type":"inject","z":"9e538f88.61ac7","name":"Every 10 Minutes","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"x":212,"y":1869,"wires":[["7c91d42e.836e2c"]]},{"id":"43bf423b.bc40bc","type":"debug","z":"9e538f88.61ac7","name":"","active":true,"console":"false","complete":"payload","x":911,"y":1849,"wires":[]},{"id":"6b706f0f.948f9","type":"function","z":"9e538f88.61ac7","name":"Temperature","func":"msg.payload = \"OutTemp :\" +Number(msg.payload.tempc) ;\ndelete msg.time;\nreturn msg;","outputs":1,"noerr":0,"x":684,"y":1815,"wires":[["43bf423b.bc40bc","80e27048.7f1d9"]]},{"id":"dcc32283.233ce","type":"function","z":"9e538f88.61ac7","name":"Humidity","func":"msg.payload = \"HumidityOutside :\" +parseInt(msg.payload.humidity) ;\ndelete msg.time;\nreturn msg;","outputs":1,"noerr":0,"x":654,"y":1867,"wires":[["43bf423b.bc40bc","80e27048.7f1d9"]]},{"id":"4b581661.b4a7e8","type":"function","z":"9e538f88.61ac7","name":"Windspeed","func":"msg.payload = \"WindSpeed :\"+parseFloat(msg.payload.windspeed).toFixed(2);\ndelete msg.time;\nreturn msg;","outputs":1,"noerr":0,"x":644,"y":1923,"wires":[["80e27048.7f1d9","43bf423b.bc40bc"]]},{"id":"ac8cd141.53733","type":"comment","z":"9e538f88.61ac7","name":"Belleville Weather","info":"","x":210,"y":1781,"wires":[]},{"id":"80e27048.7f1d9","type":"emoncms","z":"9e538f88.61ac7","name":"Emoncms","emonServer":"79466e1b.86b99","nodegroup":"3","x":917,"y":1934,"wires":[]},{"id":"5c940392.a36bfc","type":"inject","z":"9e538f88.61ac7","name":"","topic":"","payload":"Temp :8","payloadType":"string","repeat":"","crontab":"","once":false,"x":515,"y":2052,"wires":[["80e27048.7f1d9","630dd639.9cf228"]]},{"id":"630dd639.9cf228","type":"debug","z":"9e538f88.61ac7","name":"","active":true,"console":"false","complete":"false","x":801,"y":2084,"wires":[]}]

Blue Collar Ingenuity

unread,
Dec 9, 2015, 10:33:49 AM12/9/15
to Node-RED
Thanks Jon, 
                   Going to give it a try tonight. Hoping to advance my programming knowledge :) . 

Jeff 

Blue Collar Ingenuity

unread,
Dec 9, 2015, 10:36:10 AM12/9/15
to Node-RED

Thanks Dave, 
                      Glad I could assist in finding a bug :). Flow is up and running!

You guys Rock! 

Jeff 

Jon Murphy

unread,
Dec 9, 2015, 4:44:06 PM12/9/15
to Node-RED
Dave - One item I forgot to mention.  I was using the msg.data (for the above) instead of msg.payload.  I did see the date was in the wrong format for emoncms, so I grabbed the epoch time (current_observation.observation_epoch) instead.  Grabbing the observation_epoch as part of the msg.payload would be a nice add (for me anyway!).

Dave C-J

unread,
Dec 9, 2015, 5:47:10 PM12/9/15
to node...@googlegroups.com
Hi Jon,

do you mean to set  msg.payload.epoch = msg.data.current_observation.observation_epoch; ?

or to use with emoncms set
msg.time = msg.data.current_observation.observation_epoch;

so it doesn't need to be in the payload ? 

Jon Murphy

unread,
Dec 9, 2015, 7:16:59 PM12/9/15
to Node-RED
Hi Dave,

I was looking for the first one  --  msg.payload.epoch = msg.data.current_observation.observation_epoch

and while I am asking can you add  --  msg.payload.tempf = msg.data.current_observation.temp_f  for us in the US?

Thank you!   Jon

Dave C-J

unread,
Dec 10, 2015, 3:43:49 AM12/10/15
to node...@googlegroups.com
Seriously guys... it's about time you moved over to degrees C ;-)

Julian Knight

unread,
Dec 10, 2015, 6:52:06 AM12/10/15
to Node-RED
+1 :)

Jon Murphy

unread,
Dec 10, 2015, 5:34:13 PM12/10/15
to Node-RED
The metric system just seemed way too easy.  The current system keeps the mind active and fresh!

Dave C-J

unread,
Dec 10, 2015, 5:55:32 PM12/10/15
to node...@googlegroups.com
PS - the WU node was updated/republished earlier today.

Jon Murphy

unread,
Dec 12, 2015, 3:44:33 PM12/12/15
to Node-RED
Dave - Thank you for the changes to WU!  I grabbed the current version of WU and emoncms.  And I am getting an odd error with emoncms when I deploy a change.  

"Confirm deploy - The workspace contains some unused configuration nodes: [Sheet 1] emonPi (emoncms-server)  Are you sure you want to deploy?"

If I confirm the deploy all works as expected.  I've torn down my flow and rebuilt it but I still get the same error.  How do I troubleshoot this error?

[{"id":"588e948a.a7716c","type":"emoncms-server","z":"a73df52.f58c208","server":"http://192.168.40.230/emoncms","name":"emonPi 2"},{"id":"5f31a05e.a0ce6","type":"wunderground","z":"a73df52.f58c208","name":"WU PWK","lon":"","lat":"","city":"KPWK","country":"IL","x":224,"y":100,"wires":[["674fba42.98b044"]]},{"id":"3f792fac.c086d","type":"inject","z":"a73df52.f58c208","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"*/10 0-23 * * *","once":false,"x":96,"y":100,"wires":[["5f31a05e.a0ce6"]]},{"id":"e403fa0.f1bfc08","type":"comment","z":"a73df52.f58c208","name":"WX to emonPi via emoncms","info":"Gathers Weather Underground data and posts to emoncms\n(posted into emoncms Input area - http://emonPi-IP-Addr/emoncms/input/view)","x":134,"y":58,"wires":[]},{"id":"674fba42.98b044","type":"function","z":"a73df52.f58c208","name":"get WU Data","func":"msg.payload={};\nmsg.payload=\"temp:\" + msg.data.current_observation.temp_f + \",\"\n+ \"humidity:\" + msg.data.current_observation.relative_humidity.replace(\"%\",\"\") + \",\"\n+ \"epoch:\" + msg.data.current_observation.observation_epoch + \",\"\n+ \"tempC2F:\" + (msg.data.current_observation.temp_c * 1.8 + 32);\nmsg.time = msg.data.current_observation.observation_epoch;\nreturn msg;","outputs":1,"noerr":0,"x":373,"y":100,"wires":[["3adaaf5f.c5255","6ad23249.952dcc"]]},{"id":"3adaaf5f.c5255","type":"debug","z":"a73df52.f58c208","name":"to emonpi","active":true,"console":"false","complete":"payload","x":537,"y":58,"wires":[]},{"id":"6ad23249.952dcc","type":"emoncms","z":"a73df52.f58c208","name":"emonPi emoncms 3","emonServer":"588e948a.a7716c","nodegroup":"12","x":567,"y":100,"wires":[]}]

Jon

Jon Murphy

unread,
Dec 12, 2015, 3:48:20 PM12/12/15
to Node-RED
One other item - I notice Node changed to Nodegroup.  My node was "12".  Is a Nodegroup become "1:12"?

Zenofmud

unread,
Dec 12, 2015, 3:49:57 PM12/12/15
to node...@googlegroups.com
Did you go to the hamburgeer menu ->sidebar->Configuration Nodes and see if any were empty?

--
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.

Jon Murphy

unread,
Dec 12, 2015, 4:04:16 PM12/12/15
to Node-RED
the 1st one is grayed out and states "0" in the right column.  the other is normal and states "1".  both have the correct info entered (URL, apikey)
Screen Shot 2015-12-12 at 3.01.07 PM.png

Dave C-J

unread,
Dec 12, 2015, 4:06:29 PM12/12/15
to node...@googlegroups.com
Hi Jon,
as Zenofmud says i-  under the menu - sidebar - configuration nodes
is a view that shows all config type nodes... - you may well find an "old" one that says it has 0 things using it... - double click it to open then hit the delete button to remove it. - Deploy should then be clean.

Apologies for the filed name change - While I was editing I saw the internal variable was called that - and thought that as things can be grouped it may make more sense... - but you're right... looking on the Emoncms website they are just called Node... and you just have to know that you can assign multiple things to the same Node. I'll revert the label and push it up soon.

Nicholas O'Leary

unread,
Dec 12, 2015, 4:06:32 PM12/12/15
to Node-RED

The one with the 0 indicates there are no nodes that use that config node - it is what that warning was telling you about.

From a ux point if view, we're still not happy with how we present that warning and how intuitive it is to deal with...

Nick


Jon Murphy

unread,
Dec 12, 2015, 4:12:25 PM12/12/15
to Node-RED
Bingo!  The delete of the unused did it!  Thank you Paul, Dave & Nick!

I never really understood the Config area - this all helped!  Thank you!   Jon

Dave C-J

unread,
Dec 12, 2015, 4:14:28 PM12/12/15
to node...@googlegroups.com
hmm - actually what confused me was the help/info said  " If Node is left blank msg.nodegroup will used." which seems a little inconsistent - so I was trying to align them... and the easy way to do that without breaking anyone already using msg.nodegroup was to re-label the field...  so should I revert it or not... ??? opinions please.

Mark Setrem

unread,
Dec 12, 2015, 4:34:21 PM12/12/15
to Node-RED
I think it needs to be reverted to behave as it used to, as the thought of when I upgrade node-red having to go in and modify all my feeds in emoncms scares me!

Jon Murphy

unread,
Dec 12, 2015, 4:49:24 PM12/12/15
to Node-RED
Dave - I have not heard of a nodegroup as it relates to emoncms.    Glyn H (who posted a question here a few hours ago) would know better than I would.

Dave C-J

unread,
Dec 12, 2015, 5:03:59 PM12/12/15
to node...@googlegroups.com

OK will revert.
Don't worry Mark. Was just the text label in the configuration box that changed... No internals. So nothing should have broken... Just confusion.

Reply all
Reply to author
Forward
0 new messages