You might try this plugin
https://www.indigodomo.com/pluginstore/129/I installed it last year, but didn't have much time to try it out... looks like a new version was released just a few months ago, so this may help.
Like you, if/then has been a problem.... and the more devices, the bigger the problem. I've been able....
with the incredible help here online... to construct some basic if/ then options in Python... so if it is something simple, I'll be glad to try to help, but pat that, posting your issue online will most likely provide the best answer for you.