Problem with node.status after redeploy

Hi,

I have the following flow:

After redeploy (only the Label in switch node was changed! - see the uploaded images), the light have no state displayed, the code jumps over this code fragment...

P:S: The this.on('close', function(done) {} works as expected and completes the tidy up.

Please, help me to fix this.
Thanks.

Looks plausible. After deploy the switch state is not determined until it receives an input, and it won’t do that until the lamp is initialised. If you want to preset the switch on deploy then use and inject set to one only at deploy time.

Or am I missing the point ?

Hi,
thank you very much for the quick response.
You are right. :slight_smile:
I understand now.

I solved it. :slight_smile:
Thank you once again! :+1:

I'm having a similar issue that I just can't resolve, even with an inject node.
Anytime I restart node-red, all values are re-assigned with some arbitrary value.
I have no idea where they came from.
With the inject nodes, everything is OK if I redeploy. However, if I restart the program, it reverts back to these values.
Sorry if I'm missing the obvious as I'm very new to this.

Can you confirm what version of Node-RED & nodejs you are using and also export your flow and paste it here

Hi UKmoose,
Thanks for the reply. It's all below.

7 Aug 07:20:19 - [info] Node-RED version: v0.20.7
7 Aug 07:20:19 - [info] Node.js version: v10.16.0

[
    {
        "id": "a33a28cd.e5fef8",
        "type": "tab",
        "label": "Veranda",
        "disabled": false,
        "info": ""
    },
    {
        "id": "67f052ca.a97dec",
        "type": "ui_dropdown",
        "z": "a33a28cd.e5fef8",
        "name": "Lights Menu",
        "label": "",
        "tooltip": "",
        "place": "Lights Menu",
        "group": "8c7e3004.f0922",
        "order": 1,
        "width": "3",
        "height": "1",
        "passthru": false,
        "options": [
            {
                "label": "OFF",
                "value": 0,
                "type": "num"
            },
            {
                "label": "ON - FULL",
                "value": 1023,
                "type": "num"
            }
        ],
        "payload": "",
        "topic": "hse/ver/lit",
        "x": 670,
        "y": 160,
        "wires": [
            [
                "e239c7e3.477528"
            ]
        ]
    },
    {
        "id": "16988160.4c48cf",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/lit",
        "qos": "0",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 120,
        "y": 320,
        "wires": [
            [
                "e8a612a4.a575d",
                "d4212739.87e058",
                "a791f5ae.4aab18",
                "67f052ca.a97dec"
            ]
        ]
    },
    {
        "id": "a791f5ae.4aab18",
        "type": "ui_slider",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "label": "DIMMER",
        "tooltip": "",
        "group": "8c7e3004.f0922",
        "order": 3,
        "width": "6",
        "height": "2",
        "passthru": false,
        "outs": "all",
        "topic": "hse/ver/lit",
        "min": "0",
        "max": "1023",
        "step": "1",
        "x": 660,
        "y": 280,
        "wires": [
            [
                "e239c7e3.477528"
            ]
        ]
    },
    {
        "id": "294d6b31.5f4164",
        "type": "debug",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 230,
        "y": 140,
        "wires": []
    },
    {
        "id": "1ac85329.0e4d4d",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/orr",
        "qos": "0",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 120,
        "y": 260,
        "wires": [
            [
                "294d6b31.5f4164",
                "a0291127.b838e"
            ]
        ]
    },
    {
        "id": "a0291127.b838e",
        "type": "ui_switch",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "label": "ON-OVERRIDE",
        "tooltip": "",
        "group": "8c7e3004.f0922",
        "order": 2,
        "width": "3",
        "height": "1",
        "passthru": false,
        "decouple": "false",
        "topic": "hse/ver/or",
        "style": "",
        "onvalue": "10",
        "onvalueType": "num",
        "onicon": "",
        "oncolor": "",
        "offvalue": "0",
        "offvalueType": "num",
        "officon": "",
        "offcolor": "",
        "x": 680,
        "y": 100,
        "wires": [
            [
                "3aec5eb3.5f7eb2",
                "172b6c53.6b8624"
            ]
        ]
    },
    {
        "id": "e8a612a4.a575d",
        "type": "ui_gauge",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "group": "8c7e3004.f0922",
        "order": 4,
        "width": "3",
        "height": "3",
        "gtype": "gage",
        "title": "Brightness",
        "label": "PWM",
        "format": "{{(100/1023)*value | number:0}}%",
        "min": 0,
        "max": "1023",
        "colors": [
            "#000080",
            "#8000ff",
            "#ffff00"
        ],
        "seg1": "",
        "seg2": "",
        "x": 410,
        "y": 440,
        "wires": []
    },
    {
        "id": "d4212739.87e058",
        "type": "ui_numeric",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "label": "JOG",
        "tooltip": "",
        "group": "8c7e3004.f0922",
        "order": 6,
        "width": "2",
        "height": "1",
        "passthru": false,
        "topic": "hse/ver/lit",
        "format": "{{(100/1023)*value | number:0}}%",
        "min": "0",
        "max": "1023",
        "step": "2",
        "x": 670,
        "y": 340,
        "wires": [
            [
                "e239c7e3.477528"
            ]
        ]
    },
    {
        "id": "4964b8ec.7dc148",
        "type": "ui_button",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "group": "8c7e3004.f0922",
        "order": 11,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "RESET",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "45",
        "payloadType": "str",
        "topic": "hse/ver/rst",
        "x": 660,
        "y": 420,
        "wires": [
            [
                "d9de2659.c01088"
            ]
        ]
    },
    {
        "id": "4678d33.405112c",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/rst",
        "qos": "0",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 140,
        "y": 420,
        "wires": [
            [
                "b8a7fbeb.912968"
            ]
        ]
    },
    {
        "id": "b8a7fbeb.912968",
        "type": "debug",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 350,
        "y": 400,
        "wires": []
    },
    {
        "id": "deed46c4.7bef58",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/tmp1",
        "qos": "0",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 150,
        "y": 480,
        "wires": [
            [
                "d988ef7f.ab399"
            ]
        ]
    },
    {
        "id": "d988ef7f.ab399",
        "type": "ui_gauge",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "group": "8c7e3004.f0922",
        "order": 5,
        "width": "3",
        "height": "3",
        "gtype": "gage",
        "title": "Temperature",
        "label": "CELSIUS",
        "format": "{{value | number:1}}°",
        "min": 0,
        "max": "48",
        "colors": [
            "#000080",
            "#00ff00",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 670,
        "y": 480,
        "wires": []
    },
    {
        "id": "8a8ef71c.4c2b48",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/sts",
        "qos": "0",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 140,
        "y": 540,
        "wires": [
            [
                "4e01223a.c026cc",
                "486751e.b783cb"
            ]
        ]
    },
    {
        "id": "4e01223a.c026cc",
        "type": "function",
        "z": "a33a28cd.e5fef8",
        "name": "Light Output",
        "func": "msg.color = (msg.payload === \"yellow\")?\"yellow\":\"blue\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 410,
        "y": 540,
        "wires": [
            [
                "802f4089.c1c0b"
            ]
        ]
    },
    {
        "id": "802f4089.c1c0b",
        "type": "ui_text",
        "z": "a33a28cd.e5fef8",
        "group": "8c7e3004.f0922",
        "order": 8,
        "width": "2",
        "height": "1",
        "name": "",
        "label": "Light Output",
        "format": "<font color={{msg.color}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>",
        "layout": "col-center",
        "x": 670,
        "y": 540,
        "wires": []
    },
    {
        "id": "8dd0e888.700918",
        "type": "function",
        "z": "a33a28cd.e5fef8",
        "name": "LUX",
        "func": "msg.color = (msg.payload === \"ON\")?\"lime\":\"red\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 430,
        "y": 600,
        "wires": [
            [
                "d0dfddba.7006f"
            ]
        ]
    },
    {
        "id": "d0dfddba.7006f",
        "type": "ui_text",
        "z": "a33a28cd.e5fef8",
        "group": "8c7e3004.f0922",
        "order": 9,
        "width": "2",
        "height": "1",
        "name": "",
        "label": "LUX",
        "format": "<font color={{msg.color}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>",
        "layout": "col-center",
        "x": 650,
        "y": 600,
        "wires": []
    },
    {
        "id": "b4bb5dd3.b3d15",
        "type": "ui_text",
        "z": "a33a28cd.e5fef8",
        "group": "8c7e3004.f0922",
        "order": 10,
        "width": "2",
        "height": "1",
        "name": "",
        "label": "Smoke~Fire",
        "format": "<font color={{msg.color}} ><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>",
        "layout": "col-center",
        "x": 670,
        "y": 660,
        "wires": []
    },
    {
        "id": "d315316f.0ff1",
        "type": "mqtt in",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "smk/ver",
        "qos": "2",
        "datatype": "utf8",
        "broker": "e0d9704b.0af71",
        "x": 130,
        "y": 660,
        "wires": [
            [
                "b0b46bae.83b578"
            ]
        ]
    },
    {
        "id": "b0b46bae.83b578",
        "type": "function",
        "z": "a33a28cd.e5fef8",
        "name": "smk/ver",
        "func": "msg.color = (msg.payload === \"0\")?\"lime\":\"red\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 420,
        "y": 660,
        "wires": [
            [
                "b4bb5dd3.b3d15"
            ]
        ]
    },
    {
        "id": "3aec5eb3.5f7eb2",
        "type": "debug",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 970,
        "y": 140,
        "wires": []
    },
    {
        "id": "486751e.b783cb",
        "type": "debug",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 350,
        "y": 500,
        "wires": []
    },
    {
        "id": "172b6c53.6b8624",
        "type": "mqtt out",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/or",
        "qos": "",
        "retain": "",
        "broker": "e0d9704b.0af71",
        "x": 1120,
        "y": 240,
        "wires": []
    },
    {
        "id": "e239c7e3.477528",
        "type": "mqtt out",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/lit",
        "qos": "",
        "retain": "",
        "broker": "e0d9704b.0af71",
        "x": 1110,
        "y": 300,
        "wires": []
    },
    {
        "id": "d9de2659.c01088",
        "type": "mqtt out",
        "z": "a33a28cd.e5fef8",
        "name": "hse/ver/rst",
        "topic": "",
        "qos": "",
        "retain": "",
        "broker": "e0d9704b.0af71",
        "x": 1120,
        "y": 360,
        "wires": []
    },
    {
        "id": "64f94fb1.7fca",
        "type": "inject",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "hse/ver/lit",
        "payload": "1023",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 440,
        "y": 260,
        "wires": [
            [
                "67f052ca.a97dec",
                "a791f5ae.4aab18",
                "d4212739.87e058"
            ]
        ]
    },
    {
        "id": "e7759b7d.f974f8",
        "type": "inject",
        "z": "a33a28cd.e5fef8",
        "name": "",
        "topic": "smk/ver",
        "payload": "0",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 220,
        "y": 720,
        "wires": [
            [
                "b0b46bae.83b578"
            ]
        ]
    },
    {
        "id": "8c7e3004.f0922",
        "type": "ui_group",
        "z": "",
        "name": "Veranda Controls",
        "tab": "1dcd646f.4755fc",
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "e0d9704b.0af71",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "0",
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": ""
    },
    {
        "id": "1dcd646f.4755fc",
        "type": "ui_tab",
        "z": "",
        "name": "Veranda",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

You have a birth message configured in your MQTT broker config, try removing it...

1 Like

They should bottle your blood and sell it. You're an absolute legend mate.
I found within the mosquitto.conf file a persistence setting that I never thought of.
All fixed up and working perfectly.
Thank you so much!!