Creating an override button to run a heating schedule

Using HomeKit integration I have successfully created a schedule that activates the thermostats at a certain time and then turns them off at a scheduled time.
The issue? Wish to create a “Winter Mode” button that when activated runs the schedules and when OFF ignores the schedules.
To date I have created a button but the schedules ignore it and operate anyway.

Depending on which node you are using, there are ways and ways to do that.

node-red-contrib-ui-time-scheduler is a good place to start.

Thanks Andrew.

We are using EZtimer for the scheduling

I am not sure how good that node will be for you, but I use it for plant watering schedules.

I have an OFF, AWAY and DAILY mode I select from a drop down.

Again, not exactly sure it would be good for you, but it a GUI and I found it helpful.

That looks good but once set how do i turn it off? does that have to be done via a browser? my objective is to have a single button within homekit that turns the schedule on or off.

Oh, you want a button to do it. Sorry. My mistake.

If you just want a very crude ON/OFF button, there are options too.

(Mind if I share a subflow with you?)

Please do. Schedules work perfectly, just want a button within Homekit that either ENABLES or DISABLES the schedules. I tried to get Nodered to check the status of the button and if ON then run the schedules, however that hasnt worked.

Oh, how amicable to foreign nodes are you?
(Do you mind using other nodes?)

This is an EXAMPLE flow I put together.

Not tested, but the idea is there.

You will have to work out where in your flow you put it.
But I'd say just before it does what it does.

[{"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":680,"y":110,"wires":[{"id":"5a9848b4303ef8d2","port":0},{"id":"8c41e6c213bcdefe","port":0}]},{"x":680,"y":210,"wires":[{"id":"3a564786d2308bdd","port":0},{"id":"a2ec504194f78107","port":0}]},{"x":680,"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":"c0d3891213382315","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3750,"y":1680,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"]]},{"id":"24d5e3906d93e8ca","type":"subflow:402169a8.8a791","z":"0918ee609bf69fc7","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":"STOP","type":"str"},{"name":"ON","value":"GO","type":"str"},{"name":"CTOPIC","value":"control","type":"str"}],"x":3980,"y":1610,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"],[],["efaa09e9779c383d"]]},{"id":"efaa09e9779c383d","type":"ui_button","z":"0918ee609bf69fc7","name":"","group":"fe65c87a.f14ca8","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":3980,"y":1540,"wires":[["24d5e3906d93e8ca"]]},{"id":"6de2e57d21f70489","type":"function","z":"0918ee609bf69fc7","name":"Option 1","func":"if (msg.topic ==  \"control\")\n{\n    if (msg.payload == \"STOP\")\n    {\n        context.set(\"flow\",\"STOP\");\n        return;\n    }\n    if (msg.payload == \"GO\")\n    {\n        context.est(\"flow\",\"GO\");\n        return;\n    }\n}\nvar condition = context.get(\"flow\");\nif (condition == \"STOP\")\n{\n    return;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3970,"y":1680,"wires":[["5cf4fc64e6746595"]]},{"id":"cffe8f3ad2cdbd3a","type":"gate","z":"0918ee609bf69fc7","name":"Option 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":3980,"y":1730,"wires":[["5cf4fc64e6746595"]]},{"id":"5cf4fc64e6746595","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":4220,"y":1680,"wires":[[]]},{"id":"fe65c87a.f14ca8","type":"ui_group","name":"Group 1","tab":"d70f1990.9bd528","order":1,"disp":true,"width":6},{"id":"d70f1990.9bd528","type":"ui_tab","name":"Test Tab","icon":"dashboard","order":36,"disabled":false,"hidden":false}]

Sorry about the global config stuff. Delete that. Not needed.

There are TWO options.
One way goes with context and the other uses an external node:
node-red-contrib-simple-gate
This one

would it help if i send you the flow of what i have?

Not really. I don't have HomeKit installed.
So I would be missing those nodes.
Though not critical for me to see the flow, what I just sent you should work so long are you put it after the schedule message is created and before anything happens with it.

Do you understand what the flow I posted does?

not entirely unfortunately

The TWO function nodes are there only to represent your existing flow and there be an in and out point. Or more so: an out and in point.

The parts in the middle are what do the magic.
There is a button node and my subflow. That part control either of the two nodes below.
There is a function node and a gate node. You can pick either. NOT both!

Pressing the button toggles if your message will pass through the node you picked to use.

Sorry, ONE small thing I missed.

An INJECT node to set the default state of the button at boot time.
Otherwise the button is blank.

Better code - sorry.
(The inject node sends 0 to set the condition OFF and 1 to set it ON)

[{"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":"24d5e3906d93e8ca","type":"subflow:402169a8.8a791","z":"0918ee609bf69fc7","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":"STOP","type":"str"},{"name":"ON","value":"GO","type":"str"},{"name":"CTOPIC","value":"control","type":"str"}],"x":4300,"y":1550,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"],[],["efaa09e9779c383d"]]},{"id":"efaa09e9779c383d","type":"ui_button","z":"0918ee609bf69fc7","name":"","group":"48d9dd9c.267f3c","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":4300,"y":1480,"wires":[["24d5e3906d93e8ca"]]},{"id":"a573a4c56bf00df8","type":"inject","z":"0918ee609bf69fc7","name":"Default state on boot","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":4020,"y":1550,"wires":[["24d5e3906d93e8ca"]]},{"id":"6de2e57d21f70489","type":"function","z":"0918ee609bf69fc7","name":"Option 1","func":"if (msg.topic ==  \"control\")\n{\n    if (msg.payload == \"STOP\")\n    {\n        context.set(\"flow\",\"STOP\");\n        return;\n    }\n    if (msg.payload == \"GO\")\n    {\n        context.est(\"flow\",\"GO\");\n        return;\n    }\n}\nvar condition = context.get(\"flow\");\nif (condition == \"STOP\")\n{\n    return;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":4290,"y":1620,"wires":[["5cf4fc64e6746595"]]},{"id":"cffe8f3ad2cdbd3a","type":"gate","z":"0918ee609bf69fc7","name":"Option 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":4300,"y":1670,"wires":[["5cf4fc64e6746595"]]},{"id":"c0d3891213382315","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3800,"y":1620,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"]]},{"id":"5cf4fc64e6746595","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":4810,"y":1620,"wires":[[]]},{"id":"48d9dd9c.267f3c","type":"ui_group","d":true,"name":"Full_Remote","tab":"b128eb09.9f681","order":1,"disp":false,"width":"3","collapse":false},{"id":"b128eb09.9f681","type":"ui_tab","name":"HDMI_TV_control","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I'm sure you can work that bit out.

Nah, you have to use the </> button to get it so other's to be able to actually copy your code.
Edit your post and format it correctly.
Posting it again is a waste of time.
Just as easy to edit the existing post.
Edit it - open the edit screen.
Select all text (ctl a) press delete then press the </> button.
Press the <enter> button.
Paste the code.
Press the <enter> button again.
Then press the </> button again.

Save.

Sorry,

[{"id":"667f78ca948064d5","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"ec2904862438084a","type":"ui_time_scheduler","z":"667f78ca948064d5","group":"c2b982ebddd42361","name":"1230am","startDay":0,"refresh":60,"devices":["On 12:30am"],"singleOff":false,"onlySendChange":false,"customPayload":false,"eventMode":false,"eventOptions":[],"sendTopic":false,"lat":"","lon":"","customContextStore":"","outputs":2,"order":0,"width":0,"height":0,"x":100,"y":180,"wires":[["f28082041c7bb63d"],[]]},{"id":"02dbcfef3c203257","type":"homekit-service","z":"667f78ca948064d5","isParent":true,"hostType":"1","bridge":"","accessoryId":"b694c5344ce8cba0","parentService":"","name":"Schedule","serviceName":"Switch","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":100,"y":80,"wires":[[],[]]},{"id":"56c4ed0b39d82d09","type":"ui_time_scheduler","z":"667f78ca948064d5","group":"c2b982ebddd42361","name":"8am","startDay":0,"refresh":60,"devices":["Off 8am"],"singleOff":false,"onlySendChange":false,"customPayload":false,"eventMode":false,"eventOptions":[],"sendTopic":false,"lat":"","lon":"","customContextStore":"","outputs":2,"order":0,"width":0,"height":0,"x":90,"y":260,"wires":[["01d5afac6742b7b1"],[]]},{"id":"f28082041c7bb63d","type":"homekit-status","z":"667f78ca948064d5","serviceNodeId":"02dbcfef3c203257","name":"","outputs":1,"x":270,"y":180,"wires":[["87e1df110bbafb08"]]},{"id":"87e1df110bbafb08","type":"switch","z":"667f78ca948064d5","name":"","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":180,"wires":[["b80207c5facd7b05"]]},{"id":"b80207c5facd7b05","type":"change","z":"667f78ca948064d5","name":"","rules":[{"t":"set","p":"payload.On","pt":"msg","to":"true","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":180,"wires":[["e8b77f3fc61128e1"]]},{"id":"01d5afac6742b7b1","type":"homekit-status","z":"667f78ca948064d5","serviceNodeId":"02dbcfef3c203257","name":"","outputs":1,"x":270,"y":260,"wires":[["6ba724ca03888545"]]},{"id":"6ba724ca03888545","type":"switch","z":"667f78ca948064d5","name":"","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":260,"wires":[["89dd5cff4dec2928"]]},{"id":"89dd5cff4dec2928","type":"change","z":"667f78ca948064d5","name":"","rules":[{"t":"set","p":"payload.On","pt":"msg","to":"false","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":260,"wires":[["110e0a1dfd84acc9"]]},{"id":"110e0a1dfd84acc9","type":"hb-control","z":"667f78ca948064d5","name":"Pool Filter","Homebridge":"homebridge","Manufacturer":"TP-Link","Service":"Switch","device":"homebridge0E:CA:55:88:D3:65TP-LinkPool Filter00000049","conf":"03d4bb4a53f5b6d3","outputs":0,"x":880,"y":260,"wires":[]},{"id":"e8b77f3fc61128e1","type":"hb-control","z":"667f78ca948064d5","name":"Pool Filter","Homebridge":"homebridge","Manufacturer":"TP-Link","Service":"Switch","device":"homebridge0E:CA:55:88:D3:65TP-LinkPool Filter00000049","conf":"03d4bb4a53f5b6d3","outputs":0,"x":880,"y":180,"wires":[]},{"id":"c2b982ebddd42361","type":"ui_group","name":"Pool Pumps","tab":"d168a090e93a2ec3","order":1,"disp":true,"width":"6","collapse":true,"className":""},{"id":"b694c5344ce8cba0","type":"homekit-standalone","accessoryCategory":"8","bridgeName":"Schedule","hostType":1,"pinCode":"348-39-601","port":"","advertiser":"bonjour-hap","allowInsecureRequest":false,"manufacturer":"jamie","model":"1","serialNo":"1","firmwareRev":"1","hardwareRev":"1","softwareRev":"1","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"03d4bb4a53f5b6d3","type":"hb-conf","username":"276-45-276","macAddress":"dc:a6:32:44:e4:11"},{"id":"d168a090e93a2ec3","type":"ui_tab","name":"Timers","icon":"clock","disabled":false,"hidden":false}]

Put my code here....

No problems. It is (or can be) confusing to new people.

We all have to start and there is nothing wrong with making mistakes.
Believe me I've made my fair share of them.

Like this?

[{"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":"667f78ca948064d5","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"ec2904862438084a","type":"ui_time_scheduler","z":"667f78ca948064d5","group":"c2b982ebddd42361","name":"1230am","startDay":0,"refresh":60,"devices":["On 12:30am"],"singleOff":false,"onlySendChange":false,"customPayload":false,"eventMode":false,"eventOptions":[],"sendTopic":false,"lat":"","lon":"","customContextStore":"","outputs":2,"order":0,"width":0,"height":0,"x":100,"y":180,"wires":[["f28082041c7bb63d"],[]]},{"id":"02dbcfef3c203257","type":"homekit-service","z":"667f78ca948064d5","isParent":true,"hostType":"1","bridge":"","accessoryId":"b694c5344ce8cba0","parentService":"","name":"Schedule","serviceName":"Switch","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":100,"y":80,"wires":[[],[]]},{"id":"56c4ed0b39d82d09","type":"ui_time_scheduler","z":"667f78ca948064d5","group":"c2b982ebddd42361","name":"8am","startDay":0,"refresh":60,"devices":["Off 8am"],"singleOff":false,"onlySendChange":false,"customPayload":false,"eventMode":false,"eventOptions":[],"sendTopic":false,"lat":"","lon":"","customContextStore":"","outputs":2,"order":0,"width":0,"height":0,"x":70,"y":540,"wires":[["01d5afac6742b7b1"],[]]},{"id":"f28082041c7bb63d","type":"homekit-status","z":"667f78ca948064d5","serviceNodeId":"02dbcfef3c203257","name":"","outputs":1,"x":270,"y":180,"wires":[["87e1df110bbafb08"]]},{"id":"87e1df110bbafb08","type":"switch","z":"667f78ca948064d5","name":"","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":180,"wires":[["b80207c5facd7b05"]]},{"id":"b80207c5facd7b05","type":"change","z":"667f78ca948064d5","name":"","rules":[{"t":"set","p":"payload.On","pt":"msg","to":"true","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":180,"wires":[["cffe8f3ad2cdbd3a"]]},{"id":"01d5afac6742b7b1","type":"homekit-status","z":"667f78ca948064d5","serviceNodeId":"02dbcfef3c203257","name":"","outputs":1,"x":250,"y":540,"wires":[["6ba724ca03888545"]]},{"id":"6ba724ca03888545","type":"switch","z":"667f78ca948064d5","name":"","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":540,"wires":[["89dd5cff4dec2928"]]},{"id":"89dd5cff4dec2928","type":"change","z":"667f78ca948064d5","name":"","rules":[{"t":"set","p":"payload.On","pt":"msg","to":"false","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":540,"wires":[["f995e713c6bb74d8"]]},{"id":"110e0a1dfd84acc9","type":"hb-control","z":"667f78ca948064d5","name":"Pool Filter","Homebridge":"homebridge","Manufacturer":"TP-Link","Service":"Switch","device":"homebridge0E:CA:55:88:D3:65TP-LinkPool Filter00000049","conf":"03d4bb4a53f5b6d3","outputs":0,"x":1220,"y":620,"wires":[]},{"id":"e8b77f3fc61128e1","type":"hb-control","z":"667f78ca948064d5","name":"Pool Filter","Homebridge":"homebridge","Manufacturer":"TP-Link","Service":"Switch","device":"homebridge0E:CA:55:88:D3:65TP-LinkPool Filter00000049","conf":"03d4bb4a53f5b6d3","outputs":0,"x":1120,"y":180,"wires":[]},{"id":"24d5e3906d93e8ca","type":"subflow:402169a8.8a791","z":"667f78ca948064d5","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":"STOP","type":"str"},{"name":"ON","value":"GO","type":"str"},{"name":"CTOPIC","value":"control","type":"str"}],"x":930,"y":100,"wires":[["cffe8f3ad2cdbd3a"],[],["efaa09e9779c383d"]]},{"id":"efaa09e9779c383d","type":"ui_button","z":"667f78ca948064d5","name":"","group":"48d9dd9c.267f3c","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":930,"y":30,"wires":[["24d5e3906d93e8ca"]]},{"id":"a573a4c56bf00df8","type":"inject","z":"667f78ca948064d5","name":"Default state on boot","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":650,"y":100,"wires":[["24d5e3906d93e8ca"]]},{"id":"cffe8f3ad2cdbd3a","type":"gate","z":"667f78ca948064d5","name":"Option 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":930,"y":220,"wires":[["e8b77f3fc61128e1"]]},{"id":"c1d7515583a79d72","type":"subflow:402169a8.8a791","z":"667f78ca948064d5","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":"STOP","type":"str"},{"name":"ON","value":"GO","type":"str"},{"name":"CTOPIC","value":"control","type":"str"}],"x":950,"y":620,"wires":[["f995e713c6bb74d8"],[],["15264bdd8629d831"]]},{"id":"15264bdd8629d831","type":"ui_button","z":"667f78ca948064d5","name":"","group":"48d9dd9c.267f3c","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":950,"y":550,"wires":[["c1d7515583a79d72"]]},{"id":"bc9d00dd9bcfabc7","type":"inject","z":"667f78ca948064d5","name":"Default state on boot","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":670,"y":620,"wires":[["c1d7515583a79d72"]]},{"id":"f995e713c6bb74d8","type":"gate","z":"667f78ca948064d5","name":"Option 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":950,"y":740,"wires":[["110e0a1dfd84acc9"]]},{"id":"c2b982ebddd42361","type":"ui_group","name":"Pool Pumps","tab":"d168a090e93a2ec3","order":1,"disp":true,"width":"6","collapse":true,"className":""},{"id":"b694c5344ce8cba0","type":"homekit-standalone","accessoryCategory":"8","bridgeName":"Schedule","hostType":1,"pinCode":"348-39-601","port":"","advertiser":"bonjour-hap","allowInsecureRequest":false,"manufacturer":"jamie","model":"1","serialNo":"1","firmwareRev":"1","hardwareRev":"1","softwareRev":"1","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"03d4bb4a53f5b6d3","type":"hb-conf","username":"276-45-276","macAddress":"dc:a6:32:44:e4:11"},{"id":"48d9dd9c.267f3c","type":"ui_group","d":true,"name":"Full_Remote","tab":"b128eb09.9f681","order":1,"disp":false,"width":"3","collapse":false},{"id":"d168a090e93a2ec3","type":"ui_tab","name":"Timers","icon":"clock","disabled":false,"hidden":false},{"id":"b128eb09.9f681","type":"ui_tab","name":"HDMI_TV_control","icon":"dashboard","order":1,"disabled":false,"hidden":false}]