Hi,
I've a push button label controlled by a function. When the button is pressed, it displays a text/icon and after a second, displays a different text/icon.
When the UI page is loaded, the button doesn't display anything unless, it's pressed. How do I show a default text when the page is loaded?
TIA
[
{
"id": "ee1479b1.ec6d68",
"type": "ui_button",
"z": "df2b4f99.163318",
"name": "btnCx",
"group": "c5612050.2ced2",
"order": 10,
"width": "3",
"height": "1",
"passthru": false,
"label": "{{msg.icon}}",
"tooltip": "",
"color": "white",
"bgcolor": "{{msg.colour}}",
"icon": "",
"payload": "ON",
"payloadType": "str",
"topic": "",
"x": 290,
"y": 2120,
"wires": [
[
"b1b14787.e6082"
]
]
},
{
"id": "b1b14787.e6082",
"type": "function",
"z": "df2b4f99.163318",
"name": "With icon on press",
"func": "if (msg.payload == \"ON\")\n{\n //if 'ON' is received, trigger relay;\n msg.payload = \"0\";\n\n msg.icon = '<font color = \"white\"><i class=\"material-icons\"> check_circle_outline</i></font>'\n}\nelse\n{\n msg.payload = \"1\";\n msg.icon = \"Centralita\";\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 310,
"y": 2200,
"wires": [
[
"ee1479b1.ec6d68",
"f753a14e.3c19c"
]
]
},
{
"id": "f753a14e.3c19c",
"type": "trigger",
"z": "df2b4f99.163318",
"name": "",
"op1": "0",
"op2": "OFF",
"op1type": "str",
"op2type": "str",
"duration": "1",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 280,
"y": 2260,
"wires": [
[
"b1b14787.e6082"
]
]
},
{
"id": "c5612050.2ced2",
"type": "ui_group",
"z": "",
"name": "Control",
"tab": "2332b0a1.2f261",
"order": 2,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "2332b0a1.2f261",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]