Hello everyone. I’m trying to create a flow that activates a couple of switches depending on many states and variables, but I want to be able to easily duplicate this flow and change the switches and variables it interacts with, without needing to edit all the nodes every time I duplicate the flow.
For this, the idea is to create msg and flow variables at the start of the sequence, containing the names of the switches and variables that will be read later in the sequence.
I was able to do something similar but I only used these “dynamic” variables for setting the devices, and now I am trying to use this method to set variables too, but I’m being unsuccessful making the variables work.
The real sequence would start with only two switches:
But I created a test flow with four inputs to emulate the on/off for each switch:
[{"id":"056618f10d0fcd33","type":"inject","z":"fbb020a344ed4251","name":"laundryLight1 on","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"bypassVar","v":"laundryLightBypass","vt":"str"},{"p":"otherDevice","v":"laundryLight2","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"laundryLight1","payload":"on","payloadType":"str","x":140,"y":1900,"wires":[["59a9aabac40a8b9c"]]},{"id":"d0090a82389b1492","type":"debug","z":"fbb020a344ed4251","name":"debug 17","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":1840,"wires":[]},{"id":"bc15d828433c9813","type":"change","z":"fbb020a344ed4251","name":"set bypass true","rules":[{"t":"set","p":"{{bypassVar}}","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1920,"wires":[["64471639d9b6d95a"]]},{"id":"59a9aabac40a8b9c","type":"switch","z":"fbb020a344ed4251","name":"if bypass is false","property":"{{bypassVar}}","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":1900,"wires":[["bc15d828433c9813","d0090a82389b1492"]]},{"id":"64471639d9b6d95a","type":"switch","z":"fbb020a344ed4251","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":2000,"wires":[["dd2a8c7dd06953bd"],["afbae3d9cd97438b"]]},{"id":"dd2a8c7dd06953bd","type":"api-call-service","z":"fbb020a344ed4251","name":"","server":"8a86b0cc.b2bac","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{otherDevice}}"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":1980,"wires":[["78eb5f7804f757ea"]]},{"id":"afbae3d9cd97438b","type":"api-call-service","z":"fbb020a344ed4251","name":"","server":"8a86b0cc.b2bac","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["{{otherDevice}}"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":2040,"wires":[["78eb5f7804f757ea"]]},{"id":"78eb5f7804f757ea","type":"change","z":"fbb020a344ed4251","name":"set bypass false","rules":[{"t":"set","p":"{{bypassVar}}","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":2000,"wires":[[]]},{"id":"4e9165e561071d42","type":"inject","z":"fbb020a344ed4251","name":"laundryLight1 off","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"bypassVar","v":"laundryLightBypass","vt":"str"},{"p":"otherDevice","v":"laundryLight2","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"laundryLight1","payload":"off","payloadType":"str","x":140,"y":1940,"wires":[["59a9aabac40a8b9c"]]},{"id":"3ee93036540e07ce","type":"inject","z":"fbb020a344ed4251","name":"laundryLight2 on","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"bypassVar","v":"laundryLightBypass","vt":"str"},{"p":"otherDevice","v":"laundryLight1","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"laundryLight2","payload":"on","payloadType":"str","x":140,"y":1980,"wires":[["59a9aabac40a8b9c"]]},{"id":"593e2d27d3defad4","type":"inject","z":"fbb020a344ed4251","name":"laundryLight2 off","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"bypassVar","v":"laundryLightBypass","vt":"str"},{"p":"otherDevice","v":"laundryLight1","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"laundryLight2","payload":"off","payloadType":"str","x":140,"y":2020,"wires":[["59a9aabac40a8b9c"]]},{"id":"dd6899f71541c809","type":"inject","z":"fbb020a344ed4251","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1800,"wires":[["0f64027646dd1f0a"]]},{"id":"0f64027646dd1f0a","type":"change","z":"fbb020a344ed4251","name":"","rules":[{"t":"set","p":"laundryLightBypass","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1800,"wires":[["d0090a82389b1492"]]},{"id":"a7724de6aaf8cff4","type":"comment","z":"fbb020a344ed4251","name":"Manually set bypass false","info":"","x":150,"y":1760,"wires":[]},{"id":"8a86b0cc.b2bac","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
So I’d be thankful if anyone could point me in any direction on how to achieve this
Thanks,
Rodrigo