Simple push button

Hi,
when I start the web page, the button´s label is not shown. It's only shown if the button is pressed and then the it stays on. How do I fix it?
TIA

[
    {
        "id": "315df55e.e5e2da",
        "type": "function",
        "z": "9532990d.be7468",
        "name": "With icon on press",
        "func": "if (msg.payload == \"X\")\n{\n    msg.payload = \"1\";\n    msg.icon = '<font color=\"white\"><i class=\"material-icons\"> check_circle_outline</i></font>'\n}\nelse\n{\n    msg.payload = \"0\";\n    msg.icon  = \"Test push button\";\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Code added here will be run once\n",
        "finalize": "",
        "x": 210,
        "y": 160,
        "wires": [
            [
                "f2e2faad.62a68",
                "a957b58f.acad1",
                "4316179.d355a68"
            ]
        ]
    }
]

Bit tricky to say with just this code but you will need to either preload the button text or use an inject node to send msg.payload = 'whatever' on start up.

The button will have to feed msg.payload = 'whatever' or msg.payload = 'X' when pressed, or toggled, depending on how you are using the button, in order to update the text & icon.

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