Newbie Question from data link to msg.payload

hello
i have a idea in mind but can't find out where to start.
i have this data
https://app-prod-ws.meteoswiss-app.ch/v1/stationOverview?station=WYN

in a fist step i just wish to put them out in the msg.payload nice splited out
time, temperature, windDirection, windGust and so one

the other part will be to send theme to influxDB and Grafana - but its a long way to go :wink:

have a nice day
vinc

You don't tell us what you are doing to get the payload.
here is an example of retrieving the payload as an object rather than a string, and how to move the WYN object to msg.payload.

[{"id":"932ab456.59e2b","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":2100,"wires":[["7f4eb0d.3bae9d"]]},{"id":"7f4eb0d.3bae9d","type":"http request","z":"8d22ae29.7df6d","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-prod-ws.meteoswiss-app.ch/v1/stationOverview?station=WYN","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":2100,"wires":[["54f03fee.1ad538","5078c38.40f15bc"]]},{"id":"5078c38.40f15bc","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"move","p":"payload.WYN","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":2160,"wires":[["54f03fee.1ad538"]]},{"id":"54f03fee.1ad538","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":2100,"wires":[]}]

@E1cid
this helped to get a start. i need a timer to trigger it.
And now will have to find out how to split the output to save the Air-Temperature

and to find out the math to get Date/time of 1607172334543

You can set a time trigger in the inject node

For date and time you can use a function node or change node. Or install the moment node.


I see no air temp but to access any value you would use msg.payload.temperature or msg.payload.windSpeed If WYN object moved, or if not moved msg.payload.WYN.temperature

Quickly built this for you. It uses the 'node-red-contrib-moment' node to manipulate the epoch value.

[{"id":"932ab456.59e2b","type":"inject","z":"1e0fcc6f.6695dc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":220,"wires":[["7f4eb0d.3bae9d"]]},{"id":"7f4eb0d.3bae9d","type":"http request","z":"1e0fcc6f.6695dc","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-prod-ws.meteoswiss-app.ch/v1/stationOverview?station=WYN","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":220,"wires":[["54f03fee.1ad538","5078c38.40f15bc"]]},{"id":"5078c38.40f15bc","type":"change","z":"1e0fcc6f.6695dc","name":"","rules":[{"t":"move","p":"payload.WYN","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":220,"wires":[["a1553d85.af74e8","415ea3b.4a86b5c","2994781f.194d48"]]},{"id":"54f03fee.1ad538","type":"debug","z":"1e0fcc6f.6695dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":160,"wires":[]},{"id":"a1553d85.af74e8","type":"function","z":"1e0fcc6f.6695dc","name":"Split out the temperature","func":"msg.payload = msg.payload.temperature; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":950,"y":220,"wires":[["21b119f2.968bfe"]]},{"id":"21b119f2.968bfe","type":"debug","z":"1e0fcc6f.6695dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":220,"wires":[]},{"id":"415ea3b.4a86b5c","type":"moment","z":"1e0fcc6f.6695dc","name":"","topic":"","input":"payload.time","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"en-US","output":"payload","outputType":"msg","outTz":"Europe/London","x":940,"y":280,"wires":[["366de2dc.d5cc76"]]},{"id":"366de2dc.d5cc76","type":"debug","z":"1e0fcc6f.6695dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":280,"wires":[]},{"id":"2994781f.194d48","type":"debug","z":"1e0fcc6f.6695dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":160,"wires":[]}]

The moment node really is heavyweight for something that may be simple. (and indeed is already built into jsonata in the change node ) - so no need to install it twice.

1 Like

Thanks Dave for the 'heads-up' on that.

@dynamicdave
this did help - and give a nice base to play around!
did try to use the function to get to information at on, did not work in a first step but read and copy other example

Just had a bit of spare time to redo the flow with a Change node with jsonata Date/Time function.
I've removed the Moment node as per comments/suggestion by @dceejay

[{"id":"932ab456.59e2b","type":"inject","z":"d32bc828.464fe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":520,"wires":[["7f4eb0d.3bae9d"]]},{"id":"7f4eb0d.3bae9d","type":"http request","z":"d32bc828.464fe","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app-prod-ws.meteoswiss-app.ch/v1/stationOverview?station=WYN","tls":"","persist":false,"proxy":"","authType":"","x":330,"y":520,"wires":[["54f03fee.1ad538","a1553d85.af74e8","253dc617.b0ea6a"]]},{"id":"54f03fee.1ad538","type":"debug","z":"d32bc828.464fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":530,"y":460,"wires":[]},{"id":"a1553d85.af74e8","type":"function","z":"d32bc828.464fe","name":"Split out the temperature","func":"msg.payload = msg.payload.WYN.temperature; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":520,"wires":[["21b119f2.968bfe"]]},{"id":"21b119f2.968bfe","type":"debug","z":"d32bc828.464fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":520,"wires":[]},{"id":"366de2dc.d5cc76","type":"debug","z":"d32bc828.464fe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":580,"wires":[]},{"id":"253dc617.b0ea6a","type":"change","z":"d32bc828.464fe","name":"Format time as MM/DD/YYYY hh:mm","rules":[{"t":"set","p":"payload","pt":"msg","to":"$fromMillis(msg.payload.WYN.time,'[M01]/[D01]/[Y0001] [h#1]:[m01][P]')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":580,"wires":[["366de2dc.d5cc76"]]}]
1 Like

@dynamicdave Thank you very much for your help
doing the first steps - is not easy - but the scirpt and import like this helps a lot Thank you.

But with testing other question comme up.
Like i take the information from a weatherstation, which is close to a river (so it is a bit warmer 1-2C).
there is another one a bit higher a couple of kilometer away. yes i did thake this information too and looks nice. But then - should i store the Data like this in influxDB.
it is possible to take from 2 or more Station the temperature and have a avereage.
should this be done in Node-Red or in InfluxDB or just at the end in Grafana?

have a nice day
vinc

Storing the values in a database is a good idea as you can extract the data in different ways and display nice graphs and charts. Personally, I would store the readings separately and do the 'maths' on the way out (post-processing) so you could do all sorts of comparisons.

I'm not familar InfluxDB and Grafana (I've only used MySQL and hand-crafted code to extract and graph the data from a dB). I must put some time aside to get up the learning curve (like you).

There are lots of members on the forum who will probably jump in and offer valuable advice.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.