# MQTT Node doesnt give status on Node-Red Boot

**URL:** <https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872>\
**Category:** General\
**Created:** [8 February 2023 06:22 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872 "2023-02-08T06:22:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [8 February 2023 06:22 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/1 "2023-02-08T06:22:54Z")

</div>

I have a case where I need to get the status of MQTT node. Currently I am using a Status node to get the status once the state in MQTT node changes and save it to context for later state retrieval. But I do find difficult in capturing the status of the Node whenever I restart Node-Red or force a deploy.

Note: I have set an empty object while loading the context data. So when I start the NR. My context value is empty and gets updated only when the status node throws a state change. But initially the MQTT node doesn't throw or Status node doesn't report the initial state of the node.

---

<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:** [8 February 2023 07:48 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/2 "2023-02-08T07:48:11Z")

</div>

> [@Josh](#):
>
> I have set an empty object while loading the context data. So when I start the NR. My context value is empty and gets updated

I suspect this is the issue.

Please show us exactly what you are doing.

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [8 February 2023 18:45 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/3 "2023-02-08T18:45:30Z")

</div>

Im trying to get the status of MQTT out node whenever I deploy the flow.

Case 1: Mqtt is connected --- In this case when I initiate a deploy status node wont send a status because the node is already connected. This is where my context remains empty.

case 2: Mqtt is disconnected -- In this case the status node reports the change and my context is updated.

Problem: In case 1 when the node is already connected why wont the status node send the status when ever I deploy?

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

---

<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:** [8 February 2023 19:05 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/4 "2023-02-08T19:05:25Z")

</div>

> [@Josh](#):
>
> Mqtt is connected --- In this case when I initiate a deploy status node wont send a status because the node is already connected. This is where my context remains empty

The status node only reports changes. Because you deployed only The status node, no changes were detected. This will be because you have the deploy mode set to only deploy changed nodes. If you did a full deploy you would get the status.

To be fair, this is not really an issue in running production only when you're modifying flows. In these instances, it is fair to say you could use an inject node to set up the value of the global. However, if you are in a position to do a full deploy then it will automatically pick up.

---

<div class="post-metadata">

**Author:** ![Josh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josh/32/62208_2.png) [@Josh](https://discourse.nodered.org/u/Josh)\
**Post date:** [9 February 2023 05:11 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/5 "2023-02-09T05:11:12Z")

</div>

Thanks @Steve-Mcl I tried it out and it worked. Thanks much !!!

---

<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:** [23 February 2023 05:11 UTC](https://discourse.nodered.org/t/mqtt-node-doesnt-give-status-on-node-red-boot/74872/6 "2023-02-23T05:11:29Z")

</div>

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