Combine actions into single UI Switch

Hi All,
I have a NAS working purely as a backup for my home setup, it is set to only come on for couple of hours, run its backups and switch off again.

I would like to add manual overrides to my UI but i am unclear how i can achieve this. Currently there is a smart plug (switch.nas_plug_on_off) to control the power unit receives, then the NAS is on Synology Integration with WOL and Shutdown set as a switch (switch.nas_status).

[{"id":"e727234863cdba28","type":"inject","z":"492d165a.4d2518","name":"Midday","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":100,"y":2160,"wires":[["343bbb64504185ed"]]},{"id":"343bbb64504185ed","type":"api-call-service","z":"492d165a.4d2518","name":"NAS POWER ON","server":"9905c3e1.09ce1","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.nas_plug_on_off","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":270,"y":2160,"wires":[["dbe55386d5781c20"]]},{"id":"f97d67dfa0dce50a","type":"inject","z":"492d165a.4d2518","name":"1430PM","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 15 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":100,"y":2220,"wires":[["801375db6a606d1c"]]},{"id":"620df8abb93f9b05","type":"api-call-service","z":"492d165a.4d2518","name":"NAS POWER OFF","server":"9905c3e1.09ce1","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.nas_plug_on_off","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":620,"y":2220,"wires":[[]]},{"id":"dbe55386d5781c20","type":"delay","z":"492d165a.4d2518","name":"1m Delay","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":440,"y":2160,"wires":[["b4e3d7bbd65656c0"]]},{"id":"b4e3d7bbd65656c0","type":"api-call-service","z":"492d165a.4d2518","name":"NAS WAKE","server":"9905c3e1.09ce1","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.nas_status","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":2160,"wires":[[]]},{"id":"b14e20f17e2fd04a","type":"delay","z":"492d165a.4d2518","name":"4m Delay","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":440,"y":2220,"wires":[["620df8abb93f9b05"]]},{"id":"801375db6a606d1c","type":"api-call-service","z":"492d165a.4d2518","name":"NAS SLEEP","server":"9905c3e1.09ce1","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.nas_status","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":250,"y":2220,"wires":[["b14e20f17e2fd04a"]]},{"id":"9905c3e1.09ce1","type":"server","name":"Home Assistant","version":1,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

What I am trying to get is a button/switch with icon if toggled then on is run the ON sequence and off runs the OFF sequence. (including delays)

From a switch template i cannot figure out how to run node-red sequence. (instead of 2 scripts)

You could use an input boolean for the switch. The current state nodes override the inject nodes.

[{"id":"145f9ee5fa231c4c","type":"server-state-changed","z":"f80b6c338afd5483","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":830,"y":980,"wires":[["343bbb64504185ed"],["801375db6a606d1c"]]},{"id":"37a602e051771247","type":"api-current-state","z":"f80b6c338afd5483","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1000,"y":1080,"wires":[[],["801375db6a606d1c"]]},{"id":"23b83f5dfc396797","type":"api-current-state","z":"f80b6c338afd5483","name":"","server":"","version":2,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1000,"y":900,"wires":[[],["343bbb64504185ed"]]}]
1 Like

Thank you, issue i have with input booleans is they do not remember state should restart happen.
But yes that should work for most situations, just not always ideal. (Thats why i prefer switches)

I use more than a few input booleans and have never had that happen. As per the documentation it should only reset it’s state if an initial state value is set.

1 Like