How to Build Complex Rules in SmartThings?

I’d like to create a rules such as:
If A or B then C else D

I don’t think Preconditions will do this (unless I’ve missed the point). I have read on the Internet that it’s possible to create complex rules but I can’t discover how. It also seems possible to create rules at coding level rather than through the GUI but again I can’t seem to get traction on where to start with it (Rules | Developer Documentation | SmartThings)
Any pointers would be appreciated.


If you just use the basic SmartThings app, then preconditions give you an “or“ in the if clause, but not in the then clause.

There is an official feature, the rules API, which will allow you to create much more complex rules. It is covered in a different section of the forum.

If you want a simple, easy, visual interface to a powerful rules engine, there is a very popular third-party app, sharptools, that will give you this. They have both a free tier and a pro tier with an annual license. There’s a free trial for the pro tier if you want to check it out. You’ll find lots of discussion of this in this forum, as I said it’s very popular. They also have their own active forum.

There are other options if you have strong technical skills and are willing to set up your own server device, including one using node red or using Webcore over at hubitat or using MQTT, or writing your own smartapp.

See the following thread for discussion and links on those:

Replace Groovy with Automations—what’s your plan?

So there are several different possible options, depending on your own technical skills and interests, and if you are willing to pay a third-party license or not.

Using the rules API gives you an official feature at no extra cost, but it does have a pretty steep learning curve.

Using sharptools gives you something which is very easy to learn and use, with strong community support, and doesn’t require any additional devices, but you may have to pay an annual fee for it.

Or there are the other options like node red, but those do require more work to set up and strong technical skills to use.

Choice is good. :sunglasses:


Thanks v much. Lots to go at.