Creating an override button to run a heating schedule

A screen shot would have sufficed.

Yes.

Though as I posted it the buttons are OFF so all messages will be blocked.

Change the inject nodes to inject 1 rather than 0 if you want them to be ON by default.

You could use only 1 inject and send it to both subflow nodes if you want them to both default to the same state.

unfortunately, you have lost me

Well, there are two inject nodes in what you posted.
Rather than having 2 of them, you could have 1 and send its output to both of my subflow nodes.

Oh, now you only have 1 of the routines.

In the code you posted there were two.

See picture of what you posted.

there will actually be 2, one for each thermostat. i have just used 'pool filter' instead of 'thermostat'. sorry.

so just confirming the code is sound for the two thermostats per the image i uploaded? one button will be presented in Homekit titled "Schedule" and only when that button is ON will the schedule run.

Correct.

Though I would get the code I posted and put a bit of test code around it to show you what it is doing.

Here is a demo flow to show you what is happening.

[
    {
        "id": "402169a8.8a791",
        "type": "subflow",
        "name": "B Toggle 2",
        "info": "Toggle output at receipt of message.\nConfigurable output and message to send back to button node.\n(2022 02 18)\n\nIf `msg.payload == 0` (number) the output is forced to the OFF condition.\n\nIf `msg.payload == 1` (number) the output is forced to the ON condition.\n\nAny other input toggles the output.\n\n## ENV variables:\n```\nOnCLR - the colour when ON condition active.\nOnTXT - the text when ON condition active.\nOffCLR - the colour when OFF condition active.\nOffTXT - the text when OFF conditin active.\nON - payload when ON condition active.\nOFF - payload when OFF condition active.\nCTOPIC - the topic of the output message.\n```\n\nOutputs:\n - 1 $OFF for OFF and $ON for ON.\n - 2 $ON for OFF and $OFF for ON.  (Opposite of 1)\n - 3 to be sent back to button with `msg.colour` to set buttons colour and `msg.txt` for the text to be displayed.\n",
        "category": "",
        "in": [
            {
                "x": 80,
                "y": 120,
                "wires": [
                    {
                        "id": "69ae694095adea75"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 670,
                "y": 110,
                "wires": [
                    {
                        "id": "5a9848b4303ef8d2",
                        "port": 0
                    },
                    {
                        "id": "8c41e6c213bcdefe",
                        "port": 0
                    }
                ]
            },
            {
                "x": 670,
                "y": 210,
                "wires": [
                    {
                        "id": "3a564786d2308bdd",
                        "port": 0
                    },
                    {
                        "id": "a2ec504194f78107",
                        "port": 0
                    }
                ]
            },
            {
                "x": 670,
                "y": 310,
                "wires": [
                    {
                        "id": "f14d0daf4ad33691",
                        "port": 0
                    },
                    {
                        "id": "aff48be4199bcfab",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "OffTXT",
                "type": "str",
                "value": ""
            },
            {
                "name": "OffCLR",
                "type": "str",
                "value": ""
            },
            {
                "name": "OnTXT",
                "type": "str",
                "value": ""
            },
            {
                "name": "OnCLR",
                "type": "str",
                "value": ""
            },
            {
                "name": "OFF",
                "type": "str",
                "value": ""
            },
            {
                "name": "ON",
                "type": "str",
                "value": ""
            },
            {
                "name": "CTOPIC",
                "type": "str",
                "value": ""
            }
        ],
        "meta": {},
        "color": "#D8BFD8",
        "outputLabels": [
            "Normal output",
            "Inverted output",
            "To button"
        ],
        "icon": "node-red-dashboard/ui_switch.png"
    },
    {
        "id": "69ae694095adea75",
        "type": "function",
        "z": "402169a8.8a791",
        "name": "toggle",
        "func": "var x = context.get(\"counter\") || 0;\nif (msg.payload == 0)\n{\n    context.set(\"counter\",0);\n    msg.payload = 0;\n    return msg;\n}\nif (msg.payload == 1)\n{\n    context.set(\"counter\",1);\n    msg.payload = 1;\n    return msg;\n}\n\nif (x === 0)\n{\n    msg.payload = 1;\n} else\nif (x === 1)\n{\n    msg.payload = 0;\n}\n\nx = (x + 1) % 2;\n\ncontext.set(\"counter\",x);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 210,
        "y": 120,
        "wires": [
            [
                "63da8f2c6a34b348",
                "0db7c2da3958ea2c"
            ]
        ],
        "info": "##  Outputs `1` or `0` for ON/OFF and `msg.colour` to send to button."
    },
    {
        "id": "63da8f2c6a34b348",
        "type": "switch",
        "z": "402169a8.8a791",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 350,
        "y": 310,
        "wires": [
            [
                "f14d0daf4ad33691"
            ],
            [
                "aff48be4199bcfab"
            ]
        ]
    },
    {
        "id": "f14d0daf4ad33691",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "OFF",
        "rules": [
            {
                "t": "set",
                "p": "colour",
                "pt": "msg",
                "to": "OffCLR",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "txt",
                "pt": "msg",
                "to": "OffTXT",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "aff48be4199bcfab",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "ON",
        "rules": [
            {
                "t": "set",
                "p": "colour",
                "pt": "msg",
                "to": "OnCLR",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "txt",
                "pt": "msg",
                "to": "OnTXT",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "0db7c2da3958ea2c",
        "type": "switch",
        "z": "402169a8.8a791",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 350,
        "y": 120,
        "wires": [
            [
                "5a9848b4303ef8d2",
                "3a564786d2308bdd"
            ],
            [
                "8c41e6c213bcdefe",
                "a2ec504194f78107"
            ]
        ]
    },
    {
        "id": "5a9848b4303ef8d2",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "OFF",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "OFF",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "CTOPIC",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 90,
        "wires": [
            []
        ]
    },
    {
        "id": "8c41e6c213bcdefe",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "ON",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "ON",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "CTOPIC",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "a2ec504194f78107",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "OFF",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "OFF",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "CTOPIC",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 230,
        "wires": [
            []
        ]
    },
    {
        "id": "3a564786d2308bdd",
        "type": "change",
        "z": "402169a8.8a791",
        "name": "ON",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "ON",
                "tot": "env"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "CTOPIC",
                "tot": "env"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "959cebfd3196dcbf",
        "type": "subflow:402169a8.8a791",
        "z": "650fc4d9.b1c234",
        "name": "",
        "env": [
            {
                "name": "OffTXT",
                "value": "STOP",
                "type": "str"
            },
            {
                "name": "OffCLR",
                "value": "red",
                "type": "str"
            },
            {
                "name": "OnTXT",
                "value": "GO",
                "type": "str"
            },
            {
                "name": "OnCLR",
                "value": "lime",
                "type": "str"
            },
            {
                "name": "OFF",
                "value": "close",
                "type": "str"
            },
            {
                "name": "ON",
                "value": "open",
                "type": "str"
            },
            {
                "name": "CTOPIC",
                "value": "control",
                "type": "str"
            }
        ],
        "x": 700,
        "y": 1940,
        "wires": [
            [
                "b50228807e096ed2",
                "987cb97f3c279c6e"
            ],
            [],
            [
                "d962ee785f487a2f"
            ]
        ]
    },
    {
        "id": "d962ee785f487a2f",
        "type": "ui_button",
        "z": "650fc4d9.b1c234",
        "name": "",
        "group": "80b3bbc5.69a8d8",
        "order": 36,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "{{msg.txt}}",
        "tooltip": "",
        "color": "",
        "bgcolor": "{{msg.colour}}",
        "className": "",
        "icon": "",
        "payload": "X",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 700,
        "y": 1870,
        "wires": [
            [
                "959cebfd3196dcbf"
            ]
        ]
    },
    {
        "id": "bcee5f742b5aaf2e",
        "type": "inject",
        "z": "650fc4d9.b1c234",
        "name": "Default state on boot",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 420,
        "y": 1940,
        "wires": [
            [
                "959cebfd3196dcbf"
            ]
        ]
    },
    {
        "id": "b50228807e096ed2",
        "type": "gate",
        "z": "650fc4d9.b1c234",
        "name": "Option 2",
        "controlTopic": "control",
        "defaultState": "open",
        "openCmd": "open",
        "closeCmd": "close",
        "toggleCmd": "toggle",
        "defaultCmd": "default",
        "statusCmd": "status",
        "persist": false,
        "storeName": "memory",
        "x": 700,
        "y": 2060,
        "wires": [
            [
                "656f365229b5fdc2"
            ]
        ]
    },
    {
        "id": "f5dc8b1b6658a0fe",
        "type": "inject",
        "z": "650fc4d9.b1c234",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 480,
        "y": 2060,
        "wires": [
            [
                "b50228807e096ed2"
            ]
        ]
    },
    {
        "id": "656f365229b5fdc2",
        "type": "debug",
        "z": "650fc4d9.b1c234",
        "name": "debug 39",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 900,
        "y": 2060,
        "wires": []
    },
    {
        "id": "987cb97f3c279c6e",
        "type": "debug",
        "z": "650fc4d9.b1c234",
        "name": "debug 40",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 950,
        "y": 1910,
        "wires": []
    },
    {
        "id": "80b3bbc5.69a8d8",
        "type": "ui_group",
        "name": "Group 2",
        "tab": "72cdf15e.05dee",
        "order": 2,
        "disp": true,
        "width": "12",
        "collapse": false
    },
    {
        "id": "72cdf15e.05dee",
        "type": "ui_tab",
        "name": "NEW",
        "icon": "dashboard",
        "order": 28,
        "disabled": false,
        "hidden": false
    }
]

WARNING!

(Sorry - don't panic)

I stuffed up with the code I posted. Easy fix.

This WILL work. The code I posted won't because I goofed with the config of the subflow nodes.

Easy fix - again.

Open them up and edit the ON/OFF text and change it from GO / STOP to open close
Or copy the subflow from this flow to the other one.

The test flow:
Press the inject node and see the output in the debug node.
Press the button - on the dashboard - and press the inject node. You shouldn't get any output.

(oh, go back to your post number 15 where you posted the code incorrectly.
You can delete it.)
Just makes it less scrolling for others reading this thread.
Click on the three dots at the bottom then select delete.

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