# Smartthings Rules, Triggers, Conditions

**URL:** <https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475>\
**Category:** General Discussion\
**Tags:** smartrules\
**Created:** [November 8, 2016, 1:29pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475 "2016-11-08T13:29:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![penright](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/penright/32/41212_2.png) [@penright](https://community.smartthings.com/u/penright)\
**Post date:** [November 8, 2016, 1:29pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/1 "2016-11-08T13:29:57Z")

</div>

I am looking for how ST handles triggers, conditions that fire a scenes. I am coming from a Tuxedo environment. I loved it integration on the security vs HA. It only supports z wave, and with all the z wave devices that it not too bad, but it has really basic support for devices. Basicly it supports alarm faults, garage door, thermostat, water, and simple binary switches. For example it does not support multichannel binary switches.

I am moving into a new house and will have a clean slate for both security and HA.  
After studying the STNP (Smartthing Node Proxy), looks like I can still use a monitored Honeywell security and glue it to the ST. Also, I like the idea of adding a plugin to the STNP for foreign devices. The way STNP adds a somewhat “offline” capability.

I going to ask some real generic questions to help me learn ST terminology and to build context for more specific questions…  
I would like to better understand what triggers there are besides manual (app or voice). For example timed triggers? Sensors, for example security faults coming from the STNP/Alarm system.

---

<div class="post-metadata">

**Author:** ![whoismoses](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@whoismoses](https://community.smartthings.com/u/whoismoses)\
**Post date:** [November 8, 2016, 2:38pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/2 "2016-11-08T14:38:26Z")

</div>

You will want to spend some time reading about [CoRE](https://community.smartthings.com/t/release-candidate-core-communitys-own-rule-engine/57972). It is a community developed app.

You can trigger off of…

time  
sunset / sunrise  
motion  
contact  
wet / dry  
lux  
…the list goes on…

---

<div class="post-metadata">

**Author:** ![penright](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/penright/32/41212_2.png) [@penright](https://community.smartthings.com/u/penright)\
**Post date:** [November 8, 2016, 3:32pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/3 "2016-11-08T15:32:25Z")

</div>

Yep, that is what I am talking about. So CoRE would run on the same machine as STNP in it’s own process? So, it’s “rules” will be evaluated even if internet is down? Cool! I did a quick scan of the thread and read the wiki. The first post said beta, I assume it is still beta? I love the fact that it is community supported.

---

<div class="post-metadata">

**Author:** ![whoismoses](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@whoismoses](https://community.smartthings.com/u/whoismoses)\
**Post date:** [November 8, 2016, 3:36pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/4 "2016-11-08T15:36:53Z")

</div>

If the internet is down, CoRE will not work. It doesn’t run locally. SmartLighting has some of these features and it runs locally but not at robust as CoRE.

---

<div class="post-metadata">

**Author:** ![JDRoberts](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jdroberts/32/56577_2.png) [@JDRoberts](https://community.smartthings.com/u/JDRoberts)\
**Post date:** [November 8, 2016, 4:56pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/5 "2016-11-08T16:56:42Z")

</div>

This should help as a starting place. ( this is a clickable link.)

> [@A Short Intro to Scheduling/Device Control/Rules in SmartThings Classic](https://community.smartthings.com/t/a-short-intro-to-scheduling-device-control-rules-in-smartthings/15501):
>
> (March 2018: All of the following applies only to the SmartThings Classic app. If you purchased your hub after March 1, 2018 and are using the new “SmartThings (Samsung Connect)” app, creating rules works differently.) You’ve got your hub. You’ve got some devices. Now how do you schedule what happens when? SmartThings doesn’t have a rules engine/scheduler, so there’s no one tutorial for how to do this. But it’s an open platform, and there are about 12 different ways to set up various kinds of schedules. Some require custom code, some don’t. A “scheduler” in this context is anything that causes a networked device to perform an action, even if it’s just to toggle on or off immediately. (Network engineering definition, forgive me. blush) (Note: as of April 2017, the original author of …

And as others have said, right now core gives you the most options, particularly stacked conditionals:

> [@FAQ: What is WebCoRE? (And what was CoRE?)](https://community.smartthings.com/t/faq-what-is-core/59981):
>
> CoRE (now WebCore) is a very powerful community – created rules engine for SmartThings. It allows you to set up stacked conditionals like “If A then B but only while C and not if D.” Setting it up can be quite complex, but there are many community members who will be glad to help you. For example, here is a piston that one member created to notify him if the dog had already been fed twice that day and he picked up the dog bowl for a third time. He needed this because he has a large family and people didn’t always remember whose turn it was to feed the dog. dogblush [image] The original version of CoRE Has now been replaced by a new version, WebCoRE, which moves the data entry to a web interface. This allows for flexibility and an architecture that requires more memory than is av…

So as long as we are talking about Z wave, zigbee home automation, Devices with IFTTT services/channels, or cloud services with open APIs, there is very little that SmartThings _can’t_ do in terms of accessing the features of those devices.

However, most of the SmartThings architecture is cloud-based, and it doesn’t run particularly reliably.

The company is very aware of the reliability issue and has made improving that a top priority, they just aren’t there yet.

But for flexibility and versatility, it is certainly a leader among low-cost systems. And that includes the available triggers and rule sets.

---

<div class="post-metadata">

**Author:** ![penright](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/penright/32/41212_2.png) [@penright](https://community.smartthings.com/u/penright)\
**Post date:** [November 10, 2016, 1:00pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/6 "2016-11-10T13:00:41Z")

</div>

Thanks @whoismoses and @JDRoberts. I am getting a better picture of ST. I was thinking of it as a controler kind of like Tuxedo, but other than SmartLighting, it is more of a bridge. I equated more to a bridge than a hub since there is some translation to the device. If I am understanding it right, Smartapps run in the cloud and I am thinking of it as a scripting language. Since CoRE is a “Smartapp” hence the cloud. This is more of a question for STNP [Link to my STNP thread question.](https://community.smartthings.com/t/release-honeywell-ademco-vista-20p-integration/41227/149?u=penright), I wonder if a STNP plugin could be written in such a way as to publish a “virtual switch”, let it do some If/Then logic, turn on/off the “virtual switch” then let SmartLighting control the devices. Not saying it is worth the effort, just if there was some sort of mission critical operations. Just thinking out loud. 🙂

---

<div class="post-metadata">

**Author:** ![JDRoberts](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jdroberts/32/56577_2.png) [@JDRoberts](https://community.smartthings.com/u/JDRoberts)\
**Post date:** [November 10, 2016, 4:05pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/7 "2016-11-10T16:05:02Z")

</div>

From a network engineering standpoint, for technical reasons the SmartThings hub is definitely a hub and not just a bridge. (You will find discussions elsewhere in the forum about the difference between a hub and a bridge in this context.)

However, from a customer point of view it is a black box hub because customers are not allowed to load _any_ code onto the hub. At all.

( this is where many people who have a technical background get confused, because they think they are buying a customer – accessible CPU with server capabilities. Sort of like a preloaded raspberry pi with a home automation stack. But they’re not. They’re buying a black box hub which is part of a cloud-based architecture.)

Smartthings itself is not the hub. It is a cloud-based platform. Customers are allowed to load code into their cloud account. This can be code that they wrote themselves or that they copied from other community members or that is available to load from the “published” library that you can see in the marketplace section of the SmartThings mobile app.

Once the code is loaded into the customers cloud account, it runs in the cloud, and some of the _output_ of what runs may be sent to the hub device at the customer’s home. But it’s entirely possible to run a smartapp which never send output to the hub at all.

Meanwhile, the hub and the cloud talk to each other regularly and exchange information, independent of anything that any smart app is doing. Colloquially, we would call this housekeeping. It’s what keeps the status of devices in sync, let’s the cloud know if the hub is off-line, and some other stuff. But none of that is accessible to customers, it just happens as long as the hub is signed into the cloud account.

**The SmartLighting Exeception: Local Execution**

SmartLighting is an official feature which is unusual in that it specifically has been loaded into the firmware of every hub device and consequently can “run locally.” However, the hub is still a black box device. The customer cannot access it locally or make changes to smartlighting locally.

Instead, the customer makes changes to smartlighting in the usual way, in the cloud, and then that gets sent by the cloud to the hub for local storage. If the cloud is not available, for example, there is no way to change an existing smart lighting automation. It will just keep running with the old parameters.

So “run locally” in this case literally means “execute locally,” there’s still a required cloud component to set up a rule in the first place or make changes to it.

There some discussion of the SmartThings architecture in the developer docs and it’s worth taking a look at. But the Main thing to remember is that code that you write is going to run in the cloud. It’s the outputs that may get sent to the hub to act on if local device control is needed.

---

<div class="post-metadata">

**Author:** ![JDRoberts](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jdroberts/32/56577_2.png) [@JDRoberts](https://community.smartthings.com/u/JDRoberts)\
**Post date:** [November 10, 2016, 4:12pm UTC](https://community.smartthings.com/t/smartthings-rules-triggers-conditions/62475/8 "2016-11-10T16:12:02Z")

</div>

I’m not following the other thread (I rely on text to speech these days, so I can’t read code), so I’m not quite sure what your question about virtual switches means, or if it’s something specific to a particular integration.

For others who might Find this thread in the future since it has a general topic title, I’ll just mention that one of the most powerful features of smart things in terms of integration is that it does have the ability to very easily create virtual devices, including several different kinds of switches. Community members often use these for integration with IFTTT or Echo or Google Home. Virtual switches can also be used to create virtual timers.

I have a feeling that what you’re asking is something much more technical, but just as a general comment, it’s easy to create virtual switches _through the cloud platform_ which are then treated like any other device on your account. Here’s the FAQ for that.

> [@FAQ: Creating a virtual Groovy Device \[OBSOLETE\]](https://community.smartthings.com/t/faq-creating-a-virtual-device/11282):
>
> Need a FAQ for the simplest version of this: a virtual on/off switch. Maybe even two FAQs, one for why you would want one with use case examples and one step by step how to for creating one in ST. Thanks! 2023 Update Since groovy will be going away soon, so will groovy virtual switches. See the new FAQ for on the replacements: [FAQ: Creating Virtual Devices Without the IDE](https://community.smartthings.com/t/faq-creating-virtual-devices-without-the-ide/256073/)

And here’s a common example, where a virtual switch is used to allow echo to change the mode or run a routine.

> [@\[DEPRECATED\] 2015 Voice Assistant Run Routine FAQ--see 2017 FAQ instead](https://community.smartthings.com/t/faq-using-echo-to-change-a-mode-or-run-a-routine/21123):
>
> On October 1, 2016, Amazon added the ability to turn on a " routine" from Alexa. If you want to use that method, see the official support article. [https://support.smartthings.com/hc/en-us/articles/210204906-Amazon-Alexa-SmartThings-Routines](https://support.smartthings.com/hc/en-us/articles/210204906-Amazon-Alexa-SmartThings-Routines) Note that the official method will not allow you to use echo to run any routine that includes a lock or a Smart Home Monitor armed state change or another device class that Alexa does not know. The method described below in this FAQ will, but it does require that you create a virtual switch. Although at present echo can only request that smartthings turn devices on, off or dim, by using a virtual switch, you can tell echo to turn that switch on or off, and then have all kinds of things happen in smartthings. For example, if you want to have echo tu…

And since I brought it up, here’s the how to article in the community – created wiki on creating a virtual timer:

[http://thingsthataresmart.wiki/index.php?title=How\_to\_create\_a\_virtual\_timer\_for\_a\_light](http://thingsthataresmart.wiki/index.php?title=How_to_create_a_virtual_timer_for_a_light)

However, all of these examples are creating virtual switches in the cloud which will be accessed through the cloud.

As I said, I have a feeling that you were asking about something which could be created without the cloud, and that’s a whole different concept.
