I need some guidance on how to keep track/change of statusses from different inputs.
Example:
I use a dashboard switch and homekit switch, both switch the same device.
If I switch the dashboard button, I can update the homekit button on it's input, but not on the output, else I will create a neverending loop. (and vice versa).
How can both be used as a switch while keeping track, without creating a loop ? I could use an RBE node, but feel that is like a "hack".
The way I do it is to disagregate the input switches from the actual (output) switch.
So my UI's will send an MQTT message with a topic something like "COMMAND/SWITCH03". Each UI would also need to subscribe to that topic so that it gets any updates from any source. Then a separate flow also monitors the "COMMAND/#" topic and translates the commands to actual outputs to different devices.
Now, it doesn't matter which input does what or when, as long as your system is responding well, you shouldn't get any issues.
Occasionally of course, you may get a slight race condition because of things triggering in the wrong order. You can deal with this by adding a filter on the output flow to only allow - lets say - one command per second and to filter out repeat commands. On the input side, you might need to play with some slight delays.
I'd use the simple approach first and then see if you get any issues.
The dashboard switch node (ui_switch
) has a feature you may find helpful. By disabling (unchecking) the "If msg
arrives on input, pass through to output" option, you can break the loop at that point. (You can then choose whether the switch displays its input or its output on the dashboard.) I'm not familiar with the homekit nodes, so I can't be sure whether this will actually help.
1 Like