# MQTT Subscription

**URL:** https://discourse.nodered.org/t/mqtt-subscription/25931
**Category:** Dashboard
**Created:** [2 May 2020 15:23 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931 "2020-05-02T15:23:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ritwikris26](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@ritwikris26](https://discourse.nodered.org/u/ritwikris26)
#### Post date: [2 May 2020 15:23 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/1 "2020-05-02T15:23:22Z")

</div>

Hello

My device takes the value in the JSON format like {Flow:65} where Flow is the Tag name and 65 is the set value when i use inject to MQTT out its working fine but i want to send this by using slider and MQTT out .

Please guide how to use it i tried to insert function in between to add value from slider like  
D={Flow:{value}}  
return D;

but its not working as output is coming value is not defined

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [2 May 2020 20:57 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/2 "2020-05-02T20:57:36Z")

</div>

Welcome to the forum.

> [@ritwikris26](#):
>
> Please guide how to use it i tried to insert function in between to add value from slider like  
> D={Flow:{value}}  
> return D;

It isn't at all clear where you are putting that code. Is that in a function node? If so, you need to go back and look again how data is passed into a function node and how it is passed out again.

---

<div class="post-metadata">

### Author: ![ritwikris26](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@ritwikris26](https://discourse.nodered.org/u/ritwikris26)
#### Post date: [2 May 2020 23:27 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/3 "2020-05-02T23:27:45Z")

</div>

I am using a slider to pass data to function node. And i want the output of function node to be in this format {"Flow":value} where value should come from slider.

---

<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: [3 May 2020 09:27 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/4 "2020-05-03T09:27:15Z")

</div>

maybe try

```auto
msg.payload = { Flow : msg.payload };
return msg

```

---

<div class="post-metadata">

### Author: ![ritwikris26](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@ritwikris26](https://discourse.nodered.org/u/ritwikris26)
#### Post date: [3 May 2020 15:41 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/5 "2020-05-03T15:41:42Z")

</div>

Thanks for your support , its working now.

---

<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: [17 May 2020 15:41 UTC](https://discourse.nodered.org/t/mqtt-subscription/25931/6 "2020-05-17T15:41:44Z")

</div>

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