How to Get Started Creating Complex Rules in SmartThings

(This is a wiki post: feel free to edit it or add to it as needed. Also, I can’t take any screenshots since I can’t use the app at this time due to its incompatibility with voiceover, so feel free to add screenshots where they would be helpful.)

At one point, one of the biggest advantages of using the SmartThings platform was the wide variety of devices that it supported. However, by the end of 2017 several competing platforms had caught up in that regard.

Where SmartThings still holds a significant advantage over some of the other low-cost home automation solutions is in the ability to really build really complex rules in a fairly simple manner. You won’t have to be a programmer, but you may need the help of other community members to get the logic constructed just right.

So how can you take advantage of this ability? This thread is intended as a basic introduction to building complex rules in SmartThings and was created at the request of @Raeven, who was looking for guidance on getting started in this area. Again, this thread is not intended for programmers, who will probably want to instead go straight into the developer materials for the SmartThings platform. This thread is intended for people who are not programmers who want to use some of the existing tools to create complex rules. :sunglasses: If you add to the thread, please keep this audience in mind.

A Basic Rule: If A, then B

There are many low-cost, automation systems that can perform basic rules of the “if A, then B” format.

if I arrive home, turn on the porch lights

if I press this switch, turn on that outlet

if the closet door opens, turn on the closet light

if it is 15 minutes before sunset, turn on the Living room light

if there has been no motion in the bathroom for 15 minutes, turn off the Bathroom lights

Although there are some variations in the exact devices and options available, this basic “If A, then B” setup is available with everything from HomeKit to echo plus.

There is also a free service, IFTTT (“If This, Then That”) which will let you tie devices from many different companies together in this kind of basic rule. “If the thermostat drops below 68°, turn my hue lights blue.”

In SmartThings, you can do this basic structure with the official Smart Lighting feature, the official Smart Home Monitor feature, and the official Routines feature. You may need to check all three of these locations to find the exact options you’re looking for. For example, if you want to get an alert when the temperature on a specific sensor is too high, you have to use smart home manager, not a routine or the smart lights feature.

It also participates in the IFTTT service.

Level 2: If A and B, then C

The next most complicated type of rule is a compound rule. It lets you combine some additional conditions, usually from a very limited set of possibilities, with your original rule. In low-cost home automation systems, the most typical kind of compound rule lets you also check home/away or time of day.

If I arrive home AND the time is between sunset and sunrise, turn on the porch lights

If I press this switch AND it is before 11 PM, turn on that outlet

If the closet door opens AND it is before 9 pm, turn on the closet light ( to keep from waking the baby up :baby:t3:)

If it is 15 minutes before sunset AND I am home, turn on the Living room light

Many Low cost home automation systems can do this, but not all. At the time of this writing, for example, the Echo Plus could not do an AND condition. HomeKit can, but only for time of day and home/away.

Also, the free IFTTT service does not have compound rules.

Smartthings has compound rules for both time of day and home/away in the official smartlights feature and in the official routines. The official features also offer the option to use “Mode” which adds some additional compound rule capabilities.


Level 3: Stacked Conditionals: Or, While, Unless

The next level is where the rules start to get really complicated, and most of the low-cost home automation systems fall away. This is when you start combining conditions and also checking for the absence of a condition.

If I arrive home AND the time is between sunset and sunrise OR if the motion sensor on the front porch detects motion during the same time, turn on the porch lights UNLESS The date is between Thanksgiving and New Years (keeps the porch lights from spoiling the effect from the outdoor holiday lighting)

If I press this switch AND it is before 11 PM, turn on that outlet UNLESS I have guests, in which case ignore the time restriction

If the closet door opens AND it is before 9 pm OR the mode is “baby sleeping” turn on the closet light ( to keep from waking the baby up :baby:t3:)

If it is 15 minutes before sunset AND I am home, turn on the Living room light UNLESS I am watching a movie

If there has been no motion in the bathroom for 15 minutes AND the humidity levels have not been rising, turn off the bathroom lights (this keeps the lights on if someone is in the shower where the motion sensor might not detect them)

If the indoor temperature is above 78° AND The bedroom window is not open, start the bedroom air conditioner UNLESS I am not home

And a community favorite:

If there has been no motion in the living room AND I am home turn off the Living room lights UNLESS the lights were turned on with the wall switch (manual override of the automatic light turn off)

Stacked conditionals can get really complex. Maybe you want to combine several different devices, so that a rule only gets triggered if a door is open AND there is motion in the room AND you are not home. (so your dog moving around doesn’t trigger your burglar alarm siren)

The point is that most low-cost home automation systems, including HomeKit and Wink and Echo Plus, just can’t handle these kinds of rules. But SmartThings can, and much more complex ones as well. However, it can’t do all of these kinds of stacked conditional rules through the official features.

(Note that the new V3 Version of the SmartThings mobile app has an official rules creator which does offer more stacked conditional options than the classic app did, so that’s worth taking a look at also. You can run both versions of the mobile app if you want to, and some people do, because the classic app may support some devices not yet supported in the new app, but they do like the rules creator in the new V3 app better.)

If you can’t find the options you want in the official features, you will have to write your own code, use a third-party app like SharpTools, or learn to use the free community created rules engine, webCoRE.

If you do happen to have an android phone, there is one third-party app which let you create simple “if A while B then C” compound rules with a nice visual interface. It costs about $10 and is quite popular for people who just need one level up from the basic type of rules. For example, this is the simplest way to set up a rule “if the garage door is open and has stayed that way for 20 minutes while I am away then send me a notification.” You install it like any other app from the App Store. But again, it is only available for Android phones at present.

( they also offer a dashboard product which works with any web browser.)

To Infinity and Beyond: Webcore and other ways of creating stacked conditional rules

In the early days of SmartThings, if you wanted to set up a stacked conditional rule, you had to write your own code. People did share the code with others in the community, but still. It was a lot of work and hard to follow.

Eventually, one grandmaster coder in the community, Bruce R, created “Rule Machine,” a smartapp that let you create some stacked conditionals. It was immediately very popular with the more technical community members, but eventually the author moved on to other projects and the code was withdrawn.

Seeking to fill the gap made by its absence, @ady624 , with some help from other community members, designed and wrote a very sophisticated rules engine, CoRE (Community’s Own Rules Engine). This did everything rule machine had done and more, but was still restricted by the size limits of running within the smartthings mobile app.

So in 2017, he created a new improved version, webCoRE, which let you work in a regular web browser to create your rules (called “pistons” in both CoRE and webCoRE).

webCoRE is essentially a scripting language for SmartThings, and it does most of the heavy lifting as far as managing devices and variables. It lets you create extremely complex stacked conditionals, with everything from built-in holiday schedules to web hooks to internal counters. :christmas_tree::tada:And it has a very active support community, and even its own forum, so you will be able to get lots of help setting up any individual piston even if you have no programming background at all.

And in 2020, SmartThings introduced an official feature, “The Rules API,” which is similar to WebCore, although not as yet as fully developed or documented. But it is expected that in the future it will eventually provide full support for these kind of complex rules.

Neither WebCore nor the Rules API can address any of the underlying SmartThings architecture issues, like cloud latency or reliability, but they definitely answer the question of “why would I want to use SmartThings instead of HomeKit or Echo Plus?”

The answer is simple: if you want to go above basic “if A then B” rules and start creating automations that include OR, UNLESS, and WHILE, most of the low-cost competition won’t be able to do it and SmartThings will. But you are going to need to either write your own code or use something like webcore to accomplish that.

*A Note About Stringify: Now Discontinued

Sometimes referred to as “IFTTT on Steroids,” stringify was a third-party app which let you create visual “flows” which are stacked conditional rules tying together devices from different systems. It was quite popular with people who liked a more visual approach to rules design and management.

Unfortunately it was recently bought by Comcast, and in April 2019 it was announced that Comcast was bring adding it to their own home automation system, and would stop supporting the free version. So any references you see to it in the forum refer to the time when it was available to anyone, but no longer apply. :disappointed_relieved:

Stringify shutting down (April 2019)

Getting started creating your own rules for SmartThings

Personally, I’m a great believer in practical applications. So I usually recommend that people start by designing rules that they actually intend to use, rather than just trying to come up with the craziest most complicated rule they can imagine and then implementing that. But it’s your choice. :stuck_out_tongue_winking_eye:

It’s also your choice whether you want to just start with the official smart lighting feature and play around with rules in that until you hit something that you can’t accomplish and then move on to webcore or Stringify, or whether you want to jump right in with the more complex rules engines from the beginning and do even your simple rules with those.

The official smartlights feature does have one advantage over the others in that its rules can “run locally” even when the SmartThings cloud is not available provided The rule is only using devices that are using device type handlers that can also run without the cloud.

This aspect is why there are some people who continue to use both the official smartlights feature and webcore. They will use smartlights for everything they can, then shift to webcore if they need it to support more complex rules.

But there are other people who prefer to do everything in webcore, even though they know those rules will not run if the SmartThings cloud is not available, because they just find that a simpler approach. Choice is good.

Getting More Help

If you have any questions about setting up a specific rule, please do not add them to this thread.

Instead, if it is a question about a webCoRE piston, go straight to their forum and you will get the quickest and most expert help:

If it is a question about any of the official features or just how to set up a rule in general, start a new thread in the following section of the forum:

And if you want to write your own code and you need help with that, see the developer section of the forum and again you will get the quickest and most expert responses:

Have fun! :sunglasses:

SmartThings is a very powerful, versatile system even for non-programmers. You will have to do a little research to get started, but it definitely has rules capabilities far beyond many of the other low-cost home automation systems, so if you want those kinds of complex rules, it may be a very good match for you.

On the other hand, if you decide all you need are the most basic rules, then you may prefer to choose a system which is simpler, more intuitive, or less dependent on the cloud . Choice is good. :wink:

Even more ideas

And for more ideas and inspiration on what you can do with SmartThings, check out the quick browse lists in the community – created wiki, particularly the project reports section.

There is a “get started“ list there that includes topics like “the top 10 things to do with SmartThings“ and “what device should I get next?” as well as lists for everything from holiday projects to baby nurseries.

Some of those involve complex rules, some are done with very basic rules, but there’s a lot of ideas from the community that are worth checking out. :sunglasses::tada:

Light on when arriving home after sunset?
Where to start - Checking the status of two or more "things" before triggering an action
Smarthings And/OR?
IFTTT I need more options
Difference between IFTTT, Stringify, WebCore, Device Handlers and SmartApps
Perform routine based on temperature in the Classic app?
Thinking of Switching from zipabox: anyway to use wired sensors with a smartthings system?
Introduction: New kid on the block finds ST alternately enjoyable and frustrating
Condition Logic for Custom Automations
Turn on the AC in the evening, but only if the door is closed?
Garage Doors Again: check doors at a specific time each day?
I'm just gonna ask: help explain automations to someone new? (2019)
Multiple Actions?
Trying to Intergrate a sensor open / close to send a URL command
Temperature control & dog feeding alerts
Use light switch to turn on multiple devices?
Door to backyard pool. Best way to have it alarmed? --- One Button to Set Off an Alarm? --
SmartThings vs Aurora AOne hub?
New to SmartThings should I avoid Wifi devices over alternative Z Wave or Zigbee devices?
Top Level Priorities Checklist: what to consider before you start selecting smart home devices (2019)
Looking for use cases. What can SmartThings do for you?
I thought this was supposed to be easy
Button not listed under Contact Sensors
My Migration from IRIS
Automation that can have WHILE and not just IF and THAN
New from Iris: easiest way to create rules?
Alerts / triggers based on mold risk
Boat Alarm System
Boat Alarm System
Using CoRE or SmartRules app
Complex Timed event with automation?
Aqara contact sensor + Alexa routines
Control Hue bulbs with a dimmer switch with no load?
IFTTT lacks persistence: how do I stop the "that" later?
Ecolink Z Wave Plus Motion Sensor - Association Group Command Access
Schedule Event based on calendar entry?
Smart Things step by steps / explanation guides?
Smart Lighting feature request
Stacked conditional rules
Working with devices that do not show current state
Automating a Meat Curing Chamber
Why use SmartThings or any Hub for that matter? (Not a troll, real question)
Multipurpose Sensor status as enabler of routine or app
Routine to Arm Monitor based on lock AND presence?
Best Brand? Is it OK to mix and match?
Can anyone help? Looking for an “if this has not happened by x time each day, please alert me”
Trigger a light based on temperature?
Light switch on and off based on sensor—but not every time?
Can routines call other routines?
Z-wave momentary switch using Alexa
Setting a preset that isn’t overridden by switch?
N00b: Automate via ST when Device is Paired to Alexa
Question about multiple trigger automation
Need ideas for multi-zone heat pump thermostats
Who wants to get paid Write Code?
Activate a siren on multiple conditions?
Arm "Away" vs "Stay" Based on Switch?
Notify Me When Door Has Been Left Open at Sunset?
Turn on device for a few minutes repeatedly throughout the day?
Do WebCore and SmartThings Connect Play Nice Together?
New to st. Building a house
Notifications after multiple motion sensors?
Disable Motion sensor in the bedroom when in night mode?
Is Smartthings for me?
Motion Sensor to turn light on? How does this all work?
Door sensors to shut down AC?
Struggling with my first automation
First Post - Using IFTTT with SmartThings lights such as CREE or Hue
If X, Then Y, if Z ? (Stacked conditionals)
'New' smartthings app and classic app: Advice for someone new?
Lights turn on based on multiple criteria (AND)
Schlage Smartlocks: setting up complex rules?
What's the best way to select ANY or ALL in official features like Smart Lights?
Using smartthings hub to trigger multiple devices from different companies at once?
Status update every 6 hours
Newby looking for some guidance (UK)
Newbie: First automation of Keen HVAC vent. Misc questions
Routines vs. Modes, etc
New to Smartthings (clsanchez77) -- looking for suggestions or feedback
Old thread: please delete
Need another “this” in IFTTT
Looking for advice about how to turn a smart app on or off (keep a cat out of the front room)
Automate Lights with Lots of Conditions?
Smartapps and routines (overlapping)
Help with Philips Hue and Motion Sensors scenarios
Control crawlspace fan based on humidity?
Turn a GE Smart switch off after 10 minutes
Is programming ST Hub more "unstructured" than ISY?
Help with Moving to SmartThings and Possible HomeKit
New user - not a happy user
Automation help with scene changes
Newbie just starting with SmartThings
Honeywell Dimmer switch dim level—how to set it to 15%?
Original & Aqara Xiaomi Zigbee Sensors (contact, temp, motion, button, outlet, leak, etc)
Alert when door opens after certain time = classic app
Help - Automation Scenarios Poll
SThings Automation/Scenes vs. Google Routines
Help with SmartApp
Water tank pump - IFTTT to turn off pump if running for more than x minutes
Using SmartThings As An Alarm/ Security System (UK)
Considering ST to replace Insteon. What ST options are there for dimmers that don’t have a neutral?
Turn lights off after so many minutes?
Deeper integration with Ring Alarm using Alexa as bridge?
Want to start a smart home, have a few questions about where to begin

Incredible writeup @JDRoberts. This will be highly beneficial for prospective and new members!


Another great write up from the master, JD!!

For those wanting to dip their toes into webCoRE, myself and the other ‘webCoRE minions’ are ready and willing to help as best we can!


Is JD the last JeDi?


Agreed…he’s a god among children. :slight_smile:

Wow. On behalf of all users, thank you for the detailed write up, covering a lot of bases and options. Thank you.


Well, if you hadn’t written WebCoRE, there wouldn’t have been so much to write about! So the bases are mostly on you. LOL :stuck_out_tongue_winking_eye:


Thanks for this intro and summary @JDRoberts :+1:

I learned several things that I didn’t know before :slightly_smiling_face:


Can you point me to the rules creator in Smartthings new app?

“Note that the new V3 Version of the SmartThings mobile app has an official rules creator which does offer more stacked conditional options”


You access it anytime you “add an automation.“ So just click on the + and then choose automation.

There is also a new “rules API“ which can do even more complex things, but it’s still in development. :sunglasses:


Thanks @JDRoberts!
I was confused with the wording Rules Creator and thought that Rules api was already implemented.

So within Smartthings,
Automation = Official Rules Creator

There are also features like
Smart Lighting
Webcore Rules Engine
Smartthings Home Monitor

All of them have ‘If A then B function’ and some have more complex ones. Are there plans to merge all these functionalities into 1 single smartapp?


1 Like

Webcore is unofficial, community-created, And the official equivalent is the new rules API. So it will remain standalone.

As for the others, there’s no telling what will be combined. They haven’t said anything official one way or the other. :sunglasses:

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.