# Newbie Question from data link to msg.payload

**URL:** <https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047>\
**Category:** General\
**Created:** [5 December 2020 12:08 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047 "2020-12-05T12:08:14Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [5 December 2020 12:08 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/1 "2020-12-05T12:08:14Z")

</div>

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](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 😉

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 December 2020 12:17 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/2 "2020-12-05T12:17:54Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [5 December 2020 12:55 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/3 "2020-12-05T12:55:36Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 December 2020 13:06 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/4 "2020-12-05T13:06:41Z")

</div>

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.

> **[JavaScript getDate() Method](https://www.w3schools.com/jsref/jsref_getdate.asp)**

  

> **[Date/Time functions · JSONata](https://docs.jsonata.org/date-time-functions)**
>
> \## \`$now()\`

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`

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [5 December 2020 13:12 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/5 "2020-12-05T13:12:40Z")

</div>

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

 ![Screen Shot 12-05-20 at 01.11 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43aa77f9e6844fbb78a7bb7c602da0b5e54dc3c4.jpeg)

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 December 2020 14:45 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/6 "2020-12-05T14:45:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [5 December 2020 15:11 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/7 "2020-12-05T15:11:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [5 December 2020 15:49 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/8 "2020-12-05T15:49:00Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [7 December 2020 08:58 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/9 "2020-12-07T08:58:26Z")

</div>

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

 ![Screen Shot 12-07-20 at 08.54 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b981667df9b189ea391e5009011a393afb2c8694.jpeg)

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [10 December 2020 12:18 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/10 "2020-12-10T12:18:06Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 December 2020 12:26 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/11 "2020-12-10T12:26:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 February 2021 12:26 UTC](https://discourse.nodered.org/t/newbie-question-from-data-link-to-msg-payload/37047/12 "2021-02-08T12:26:39Z")

</div>

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