# Status node refresh on startup

**URL:** <https://discourse.nodered.org/t/status-node-refresh-on-startup/35360>\
**Category:** General\
**Created:** [5 November 2020 08:30 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360 "2020-11-05T08:30:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![harveyd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/harveyd/32/31436_2.png) [@harveyd](https://discourse.nodered.org/u/harveyd)\
**Post date:** [5 November 2020 08:30 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/1 "2020-11-05T08:30:12Z")

</div>

Hi,

I'm new to Node-Red so I do apologise.

I'm using `node-red-contrib-simple-gate` and have used the 'status' node to see if the gate is open or closed which then updates a Dashboard text field.

This works fine under normal usage and I have enabled the 'Restore from saved state' option along with file persistence and the state is preserved between deploys.

However, if I do a full restart of Node-Red or reboot the server the text field does not populate after a reboot until I interact with the gate (I have a button to toggle its status). Is there any way to force the status node to periodically refresh the status node or make it run on startup so the status is displayed without needing to interact with the gate?

Alternatively, can the 'get status of node' be replicated in a 'function'? That way I could use the inject node to trigger it just after start?

Any advice would be appreciated.

---

<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 November 2020 08:38 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/2 "2020-11-05T08:38:53Z")

</div>

That sounds like a bug in that node that should be reported to the author. If it is restoring state OK then it should be able to set its status. If not in restore mode then it is totally valid to not be set until it receives an input.

---

<div class="post-metadata">

**Author:** ![harveyd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/harveyd/32/31436_2.png) [@harveyd](https://discourse.nodered.org/u/harveyd)\
**Post date:** [5 November 2020 08:46 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/3 "2020-11-05T08:46:46Z")

</div>

Hi, Thanks for the quick reply. To verify I found the json file with the matching node id in ~/.node-red/context/ and it's contents is reflected (albeit after 30 seconds as expected). So it suggests I set that up correctly.

Is there a function way to replicate the status node as a work around?

How do I report bugs to node-red?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 November 2020 09:22 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/4 "2020-11-05T09:22:33Z")

</div>

The Status cannot 'get' the status of a node - it can only report changes to the status when the node in question sets its status.

When Dave suggested it was "a bug in that node" - he was referring to node-red-contrib-simple-gate and whether that node is correctly setting its status when things restart - not a bug in the Status node.

However there is another aspect to this - the node _might_ be setting its status properly on startup (you can check that by seeing what it reports in the editor after a restart) - however if it is reporting that status during startup, it is entirely possible the Status node has not been started yet, or that any of the nodes connected to the Status node have not yet been started.

I _think_ it starts Status/Catch/Complete nodes _first_ (I'd have to go double check that....) - so it could the latter.

---

<div class="post-metadata">

**Author:** ![harveyd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/harveyd/32/31436_2.png) [@harveyd](https://discourse.nodered.org/u/harveyd)\
**Post date:** [5 November 2020 09:34 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/5 "2020-11-05T09:34:33Z")

</div>

Hi, thats does make sense. Thank you for the clarification.

I suspect I could work around it if I could create a 'function' that could query the current status of the 'gate' node. Is it possible to get the current state (open|closed) of the gate programatically?

---

<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:** [5 November 2020 10:03 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/6 "2020-11-05T10:03:17Z")

</div>

As a workaround you could send the status to a Retained topic in MQTT. Then where you use the status connect to an MQTT In node to pick it up. Then on startup it will automatically pickup the status from before the restart.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [5 November 2020 16:24 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/7 "2020-11-05T16:24:08Z")

</div>

> [@knolleary](#):
>
> it is entirely possible the Status node has not been started yet, or that any of the nodes connected to the Status node have not yet been started.

This question has come up a few times [before](https://discourse.nodered.org/t/getting-the-initial-status-of-nodes/22162) and in connection with [other nodes](https://discourse.nodered.org/t/serial-status-node-on-boot-start/5419) as well, and I think the issue is what Nick describes. My guess is that if there were an easy fix for this in the runtime, it would already have been done.

For the `gate `node in particular, the status is set before any input is received, and I recall either @knolleary or @dceejay having checked the code and given it a clean bill of health, although I can't find the post at the moment.

I have a kluge you can try while I implement a workaround. You can replace the `gate` node with the [q-gate](https://flows.nodered.org/node/node-red-contrib-queue-gate) node, which operates in essentially the same way if you ignore its queueing functions. One difference, however, is that I recently added a `status` command to `q-gate` that causes the node to refresh its status. If you connect the node to an `inject` node that sends the `status` command on startup with a short delay, you should have the flow fully deployed and the `status` node ready to accept input. I happen to be working on a bug-fix release of the `gate` node, and I should be able to add the `status` command and publish it in a few days.

---

<div class="post-metadata">

**Author:** ![harveyd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/harveyd/32/31436_2.png) [@harveyd](https://discourse.nodered.org/u/harveyd)\
**Post date:** [6 November 2020 01:26 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/8 "2020-11-06T01:26:32Z")

</div>

I appreciate your input. I’ll test and experiment with your recommendations

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [8 November 2020 16:42 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/9 "2020-11-08T16:42:20Z")

</div>

The workaround I mentioned is now [available](https://discourse.nodered.org/t/new-feature-node-red-contrib-simple-gate-version-0-4-0/35536). You can use [node-red-contrib-simple-gate](https://flows.nodered.org/node/node-red-contrib-simple-gate) version 0.4.0.

---

<div class="post-metadata">

**Author:** ![harveyd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/harveyd/32/31436_2.png) [@harveyd](https://discourse.nodered.org/u/harveyd)\
**Post date:** [8 November 2020 21:07 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/10 "2020-11-08T21:07:24Z")

</div>

Hi, thanks. Yes, I saw the release. I’ve tested it and it worked perfectly. Thank you very 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:** [22 November 2020 21:07 UTC](https://discourse.nodered.org/t/status-node-refresh-on-startup/35360/11 "2020-11-22T21:07:25Z")

</div>

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