Question on how the scheduler works


1) Give a description of the problem
No problem works as expected but have some questions about how the scheduler works

2) What is the expected behavior?
If its greater than 74 degrees outside AND the sun is out then close the curtain and turn on the ceiling fans. If its closing the curtains because of heat flash some lights red/white a few times to let the user know. Also open curtains at sunrise and sunset.

3) What is happening/not happening?
Everything works as expected

**4) Post a Green Snapshot of the piston!

So I assume there is a main loop with smartthings that goes through local events and services them.

What I am curious about is for example in my example at the start there is a if temperature sensor >74 and dimmer 2 is not off then do something (lets forget about the time event for the moment)

Is it constantly polling the temperature sensor and dimmer at the rate of the main loop execution? Or does it do nothing and wait for an event on temperature and dimmer to change so it would occur at the rate of the main loop executing the event and sending that event change. Hope that makes sense.

Also have different question about how many resources are getting used. This Piston for example says memory used 10%. Is that 10% of smartthings memory? So in theory we could run out of memory on smartthings with use of these pistons?


WebCoRE is event driven. It does not actively poll devices.

If your statement was a trigger, (IE: IF Sensor’s temp changes), then each time the device reports a change in temp to the hub, then your piston will run top to bottom, and execute anything not blocked by conditions.

Now in your case, you don’t have any triggers, so all of your conditions should be treated as triggers. (although I don’t know why you don’t have any trigger's in the left margin)

Specifically, if your piston subscribed to those devices as triggers, then these events should execute the piston, (each time they happen) and run thru the entire code:

  • Sensor 1’s temperature changes to anything
  • Dimmer 2’s switch changes to on
  • Dimmer 2’s switch changes to off
  • RGB 1’s switch changes to on
  • RGB 1’s switch changes to off
  • RGB 2’s switch changes to on
  • RGB 2’s switch changes to off
  • RGB 3’s switch changes to on
  • RGB 3’s switch changes to off

Also note that if Dimmer 2 is acting as a trigger (line 26), then every time line 60, 73 or 81 executes, your piston will start all over at the top.

Here is a great thread showcasing the difference between triggers and conditions.
(which should be required reading material for all of us, LOL)


Thank you for the explanation.

Dimmer 2 = curtain
I’m checking to see if it’s open or closed on=open off=closed

I “think” I suspected it to work the correct way which is why I put the temperature sensor first. That is the one I want to be evaluated before the others. If that one doesnt change then the others do not matter. I’ll read the link you provided.


For the record, I usually recommend avoiding this logic:

IF Dimmer2 changes  (line 26)
    Change Dimmer2  (line 60)

Technically, there is a 6 second space between events, so you may be able to get away with it. Just be aware that each time lines 60, 73 or 81 executes, your piston will start all over at the top.


line 26 is there to prevent the lights from flashing if the curtain is already closed and the other 2 events occur.

Line 60,73 should only occur once each
open the curtain at the start of the day and end of the day
This is a good point now you made me think. There could be a scenario where at sunset it is still >74 degrees so the if statement could activate and close the curtain again. I’ll have to think about how to fix that. Maybe add a time delay for the is between and also the at sunset event?


This is always my goal. :sunglasses:

One observation though:
Due to the temp trigger, line 60 might execute hundreds of times a day.


Line 60 shouldn’t execute a bunch of times because there is the check if the curtain is already closed (if not off)

So once line 60 turns it off then the if should fail.


Honestly, I do not think it is right to take credit for the solution2 on this one, since I have answered your questions, and everything I have said is spot on.

Perhaps my time is better spent helping others?


@xokia Are you serious? You can’t award yourself a solution like this!! :rofl: Apart from the fact it makes no sense, you’re stopping other new users who join the community 16 hours ago from receiving genuine help from experts if they are only going to abuse the system and award themselves solutions where its not merited. You need to untick the solution box on your comment and put it on @WCmore’s. Credit where credit is due.


Hey sorry that wasn’t the intent I did not realize I was assigning credit. Your help was very helpful in finding the repeat loop through the If statement. I just clicked solution to end the thread (i.e. the solution was in the thread). It wasn’t intended to slight anyone. Let me see if I can change it. This was my first post on this forum so please excuse my ignorance of what we are supposed to click where and why.


No problem @xokia, have a look also on the ST forums please, the same applies there, 24 days a member (edit - 24 days visited) and you’ve given yourself 2 solutions already, which is miraculous! Now you know :+1:


I’ll take a look I have been a member on ST forum for a few years but under a different username. Although I never actually paid attention to the Solution box much nor was I very active on ST forum


No problem at all. Thank you for the adjustment.

I actually program SmartHomes for a living, but I like to help people here as well.

Without money being passed, the only real “currency” here is acknowledging others contributions.