# Issues with status node

**URL:** <https://discourse.nodered.org/t/issues-with-status-node/68187>\
**Category:** Industrial\
**Created:** [25 September 2022 07:01 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187 "2022-09-25T07:01:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [25 September 2022 07:01 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/1 "2022-09-25T07:01:13Z")

</div>

Hi,  
I have configured status nodes in my flow to monitor plc nodes like "pccc" but its doesn't seem to work. The message generated by the node is "undefined".

the "show node status " is enabled in the settings .

What could be the issue?...I am looking to use the status message to pass a null value to MSSQL when the plc connection drops.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 September 2022 07:34 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/2 "2022-09-25T07:34:56Z")

</div>

Did you set the debug node to `complete msg object` ?

---

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [26 September 2022 07:43 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/3 "2022-09-26T07:43:43Z")

</div>

@bakman2,  
I am able to monitor the complete message object now but need a little assistance in meeting the requirement. My flow is as given below:

```auto
[
    {
        "id": "3f52fcdee953d32c",
        "type": "status",
        "z": "924e3c32cfb47491",
        "name": "",
        "scope": [
            "66d6e76f56adf489"
        ],
        "x": 120,
        "y": 180,
        "wires": [
            [
                "ab68851ac24be479"
            ]
        ]
    },
    {
        "id": "ab68851ac24be479",
        "type": "function",
        "z": "924e3c32cfb47491",
        "name": "function 36",
        "func": "var log =msg.status\nglobal.set(\"plc_status\",log)\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 330,
        "y": 200,
        "wires": [
            [
                "da02219844b2f66d"
            ]
        ]
    },
    {
        "id": "da02219844b2f66d",
        "type": "debug",
        "z": "924e3c32cfb47491",
        "name": "debug 12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 500,
        "y": 220,
        "wires": []
    },
    {
        "id": "66d6e76f56adf489",
        "type": "pccc in",
        "z": "924e3c32cfb47491",
        "endpoint": "094e77d0aee89ede",
        "mode": "single",
        "variable": "plc",
        "diff": false,
        "name": "",
        "x": 110,
        "y": 80,
        "wires": [
            [
                "e57cf786ef412ec1"
            ]
        ]
    },
    {
        "id": "e57cf786ef412ec1",
        "type": "function",
        "z": "924e3c32cfb47491",
        "name": "",
        "func": "var status=global.get('plc_status');\n\nif(status.text==\"failure\")\n{\n global.set(\"plc\", null);\n}\nelse\n global.set(\"plc\", msg.payload);\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "094e77d0aee89ede",
        "type": "pccc endpoint",
        "address": "192.168.4.108",
        "port": "44818",
        "userouting": false,
        "routingbuf": "[1,0]",
        "cycletime": "5000",
        "timeout": "1500",
        "name": "",
        "vartable": [
            {
                "addr": "F8:1",
                "name": "plc"
            }
        ]
    }
]

```

What I am trying to do is pass a null value to the global variable "plc" when the connection to the plc (allen bradely micrologix 1400) drops.

The status text shows "failure" when it disconnects but the global variable "plc\_status" retains its past value.

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [26 September 2022 12:10 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/4 "2022-09-26T12:10:33Z")

</div>

Hi,  
The 'Change' node has an option for **Delete** (as well as Change and Move).  
I think that's what you need to do.

Cheers,

Paul

---

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [27 September 2022 04:41 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/5 "2022-09-27T04:41:41Z")

</div>

I guess , I can use the "Change" node properly only if the status of plc nodes are picked up properly ..need help there!!

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [27 September 2022 12:43 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/6 "2022-09-27T12:43:58Z")

</div>

> [@joey\_ind](#):
>
> ```auto
> [
> {
> "id": "3f52fcdee953d32c",
> "type": "status",
> "z": "924e3c32cfb47491",
> "name": "",
> "scope": [
> "66d6e76f56adf489"
> ],
> "x": 120,
> "y": 180,
> "wires": [
> [
> "ab68851ac24be479"
> ]
> ]
> },
> {
> "id": "ab68851ac24be479",
> "type": "function",
> "z": "924e3c32cfb47491",
> "name": "function 36",
> "func": "var log =msg.status\nglobal.set(\"plc_status\",log)\nreturn msg;",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "libs": [],
> "x": 330,
> "y": 200,
> "wires": [
> [
> "da02219844b2f66d"
> ]
> ]
> },
> {
> "id": "da02219844b2f66d",
> "type": "debug",
> "z": "924e3c32cfb47491",
> "name": "debug 12",
> "active": true,
> "tosidebar": true,
> "console": false,
> "tostatus": false,
> "complete": "true",
> "targetType": "full",
> "statusVal": "",
> "statusType": "auto",
> "x": 500,
> "y": 220,
> "wires": []
> },
> {
> "id": "66d6e76f56adf489",
> "type": "pccc in",
> "z": "924e3c32cfb47491",
> "endpoint": "094e77d0aee89ede",
> "mode": "single",
> "variable": "plc",
> "diff": false,
> "name": "",
> "x": 110,
> "y": 80,
> "wires": [
> [
> "e57cf786ef412ec1"
> ]
> ]
> },
> {
> "id": "e57cf786ef412ec1",
> "type": "function",
> "z": "924e3c32cfb47491",
> "name": "",
> "func": "var status=global.get('plc_status');\n\nif(status.text==\"failure\")\n{\n global.set(\"plc\", null);\n}\nelse\n global.set(\"plc\", msg.payload);\nreturn msg;\n",
> "outputs": 1,
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "libs": [],
> "x": 280,
> "y": 40,
> "wires": [
> []
> ]
> },
> {
> "id": "094e77d0aee89ede",
> "type": "pccc endpoint",
> "address": "192.168.4.108",
> "port": "44818",
> "userouting": false,
> "routingbuf": "[1,0]",
> "cycletime": "5000",
> "timeout": "1500",
> "name": "",
> "vartable": [
> {
> "addr": "F8:1",
> "name": "plc"
> }
> ]
> }
> ]
> 
> ```

Hi,

Try using the 'Switch' node to do an 'IF'... I.e. 'If the value of variable A is lower than X then set the value of my special variable to 1'.

Cheers,

Paul

---

<div class="post-metadata">

**Author:** ![joey\_ind](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@joey\_ind](https://discourse.nodered.org/u/joey_ind)\
**Post date:** [28 September 2022 04:26 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/7 "2022-09-28T04:26:36Z")

</div>

@ Paul ...got it to work with a switch and change node.

One thing that I noticed was there is no discontinuity in the chart even though I pass null values to variables when the plc disconnects. This might lead to a wrong interpretation of data by the user.  
Any workarounds for this issue?

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [28 September 2022 14:00 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/8 "2022-09-28T14:00:08Z")

</div>

Hi,

You will always need to treat NULL, 0, and no signal differently in any reporting / charting application.

I think a more robust method is to use positive integers only and map anything outside of those to 'no data' or 'error'.

NULL is also an often-used state in databases when no data has been written to that column / row yet - you can get tripped up there as well.

Cheers,

Paul

---

<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:** [27 November 2022 14:01 UTC](https://discourse.nodered.org/t/issues-with-status-node/68187/9 "2022-11-27T14:01:02Z")

</div>

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