# \[newbie\] Using message properties as the source for openweathermap settings

**URL:** <https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612>\
**Category:** General\
**Created:** [16 August 2020 16:06 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612 "2020-08-16T16:06:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugocoolens](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hugocoolens](https://discourse.nodered.org/u/hugocoolens)\
**Post date:** [16 August 2020 16:06 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/1 "2020-08-16T16:06:46Z")

</div>

I was wondering whether it is possible to use a msg.payload from a node-red flow as the input  
of a field in the settings of a node. As an example I added a screenshot of the settings of an openweathermap-node. You can see the field for the City is now filled out with the word Brussels,  
but I'd like this rather to be a msg.payload or a variable related to a msg.payload from somewhere else  
in the flow. That way I wouldn't have to make an openweathermapnode for each city I'd like to check the weather of.  
[openweathermapnodesettings](https://www.dropbox.com/s/7y03j2hgq8hmnxb/openweathermapsettings.png?dl=1)

kind regards,  
hugo

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 August 2020 16:31 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/2 "2020-08-16T16:31:00Z")

</div>

Hi Hugo,

you should always read the built in help...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/fff0636d15387d0a45d071dcde110260b7fddb36.png)

So try adding a change node and setting these values in a change node & passing the `msg` to the map node.

---

<div class="post-metadata">

**Author:** ![hugocoolens](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hugocoolens](https://discourse.nodered.org/u/hugocoolens)\
**Post date:** [17 August 2020 13:03 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/3 "2020-08-17T13:03:37Z")

</div>

Thank you for answering my question. I have made a flow in which I tried to follow you suggestion but  
I didn't succeed. Could you help me further. The idea is to inject a city name to get the weather report of that city.  
Here is my attempt:

```auto
[{"id":"ae46cfb1.dce128","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"e0b1dccc.971618","type":"inject","z":"ae46cfb1.dce128","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Gent","payloadType":"str","x":190,"y":260,"wires":[["13f1b9bb.30627e"]]},{"id":"1c8c4efc.9c3f29","type":"debug","z":"ae46cfb1.dce128","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":260,"wires":[]},{"id":"2264ad42.461f4a","type":"inject","z":"ae46cfb1.dce128","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Brussel","payloadType":"str","x":190,"y":220,"wires":[["13f1b9bb.30627e"]]},{"id":"88831334.c3e4d8","type":"inject","z":"ae46cfb1.dce128","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Aalst","payloadType":"str","x":190,"y":300,"wires":[["13f1b9bb.30627e"]]},{"id":"c927ea1f.01c138","type":"openweathermap","z":"ae46cfb1.dce128","name":"CurrentOpenWeatherReportCity","wtype":"current","lon":"","lat":"","city":"","country":"Belgium","language":"msg","x":690,"y":260,"wires":[["1c8c4efc.9c3f29"]]},{"id":"13f1b9bb.30627e","type":"change","z":"ae46cfb1.dce128","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"location.city","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["c927ea1f.01c138"]]}]

```

or via this link:  
[https://www.dropbox.com/s/e8h8dncbrjrkd4v/wheatherflow.json?dl=1](https://www.dropbox.com/s/e8h8dncbrjrkd4v/wheatherflow.json?dl=1)

kind regards,  
Hugo

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 August 2020 13:08 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/4 "2020-08-17T13:08:18Z")

</div>

You have these the wrong way around...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5bb00ac1e0f6b578841709a8da6f8a8c248a3a1e.png)  
It reads as **Set `msg.payload` to the value of `msg.location.city`**

What you need is **Set `msg.location.city` to the value of `msg.payload`**

also, you will need to set the msg.location to an object before trying to add the city property.

e.g...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6860ea63668239fe9b278c66748fe3de33b10e6.png)

---

<div class="post-metadata">

**Author:** ![hugocoolens](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hugocoolens](https://discourse.nodered.org/u/hugocoolens)\
**Post date:** [17 August 2020 13:36 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/5 "2020-08-17T13:36:05Z")

</div>

Thanks Steve for being patient with me. I tried to follow your suggestions but it still does not work,  
I get the error-message "Invalid location information provided" in the debug-node at the output.  
Here is my adapted flow:

```auto
[{"id":"e66a1702.7b949","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"c746b31c.76bd","type":"inject","z":"e66a1702.7b949","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Gent","payloadType":"str","x":230,"y":180,"wires":[["202d9c26.2b8abc"]]},{"id":"604d3752.81f1a","type":"debug","z":"e66a1702.7b949","name":"payloadout","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":200,"wires":[]},{"id":"6ebb087.515f4f8","type":"inject","z":"e66a1702.7b949","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Brussel","payloadType":"str","x":230,"y":140,"wires":[["202d9c26.2b8abc"]]},{"id":"eba44b57.a25ad","type":"inject","z":"e66a1702.7b949","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Aalst","payloadType":"str","x":230,"y":220,"wires":[["202d9c26.2b8abc"]]},{"id":"a897b695.e9883","type":"openweathermap","z":"e66a1702.7b949","name":"CurrentOpenWeatherReportCity","wtype":"current","lon":"","lat":"","city":"","country":"Belgium","language":"msg","x":731.3333129882812,"y":130.16666412353516,"wires":[["604d3752.81f1a"]]},{"id":"202d9c26.2b8abc","type":"change","z":"e66a1702.7b949","name":"WhichCity?","rules":[{"t":"set","p":"location","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"location.city","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":180,"wires":[["a897b695.e9883"]]}]

```

kind regards,  
hugo

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 August 2020 13:37 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/6 "2020-08-17T13:37:26Z")

</div>

Alternatively, if you use Move msg.payload To msg.location.city then you don't need to create msg.location first.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 August 2020 13:38 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/7 "2020-08-17T13:38:25Z")

</div>

To paste a flow here you should use the `</>` button and paste it in, otherwise it is not importable.

**[Edit]** I have corrected it for you.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 August 2020 13:44 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/8 "2020-08-17T13:44:03Z")

</div>

> [@hugocoolens](#):
>
> Invalid location information provided

I haven't used that node but the help suggests you need country as well as city.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 August 2020 13:47 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/9 "2020-08-17T13:47:43Z")

</div>

Your flow is now correctly setting msg.location.city

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c752ed6292eaf017353ba64d19dce096cfe78699.png)

However, I am not familiar with that node nor its internal workings.

You might have to ALSO leave `country` (empty on the UI) and pass that in `msg.location.country`

e.g..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f1550c72fe457f330d5753824f1bca84940a5020.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97ddd71de083cf6919df099c30938fc38ebc335b.png)

... but i am guessing now

---

<div class="post-metadata">

**Author:** ![hugocoolens](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hugocoolens](https://discourse.nodered.org/u/hugocoolens)\
**Post date:** [17 August 2020 14:10 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/10 "2020-08-17T14:10:34Z")

</div>

OK, I was not totally sure about using the block quote or the `</>` button, I'll take care of it in the future.

kind regards,  
Hugo

---

<div class="post-metadata">

**Author:** ![hugocoolens](https://avatars.discourse-cdn.com/v4/letter/h/e95f7d/32.png) [@hugocoolens](https://discourse.nodered.org/u/hugocoolens)\
**Post date:** [17 August 2020 15:03 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/11 "2020-08-17T15:03:13Z")

</div>

Thanks a lot for helping me out, I appreciate it very much.  
Het is my final flow:

`[{"id":"8bb43132.919c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5dfcb174.eded28","type":"inject","z":"8bb43132.919c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Gent","payloadType":"str","x":190,"y":260,"wires":[["c5ddd569.f17f6"]]},{"id":"7cb699e8.641a1","type":"debug","z":"8bb43132.919c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":260,"wires":[]},{"id":"d3e1d838.101d78","type":"inject","z":"8bb43132.919c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Brussel","payloadType":"str","x":190,"y":220,"wires":[["c5ddd569.f17f6"]]},{"id":"8b355116.4dc3e8","type":"inject","z":"8bb43132.919c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Aalst","payloadType":"str","x":190,"y":300,"wires":[["c5ddd569.f17f6"]]},{"id":"d70b1257.1c61f","type":"openweathermap","z":"8bb43132.919c","name":"CurrentOpenWeatherReportCity","wtype":"current","lon":"","lat":"","city":"","country":"","language":"msg","x":690,"y":260,"wires":[["7cb699e8.641a1"]]},{"id":"c5ddd569.f17f6","type":"change","z":"8bb43132.919c","name":"","rules":[{"t":"set","p":"location","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"location.city","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"location.country","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["d70b1257.1c61f"]]}]`

thanks again and kind regards,  
Hugo

---

<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:** [16 October 2020 15:03 UTC](https://discourse.nodered.org/t/newbie-using-message-properties-as-the-source-for-openweathermap-settings/31612/12 "2020-10-16T15:03:17Z")

</div>

Closed on 16 October 2020 15:03 UTC

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