First Rule - Completely Confused


#1

Please bear with me as I have no clue what I’m doing and this is my first experience with anything even remotely close to programming.

Is there a way to play with these and not have them execute until I think they are remotely close to being correct? Can I just use the /* thing to comment out every line?

Thanks for the help!

1) Give a description of the problem
I’m not even sure where to start.

2) What is the expected behaviour?
I have 8 lights I’d like to turn on at Sunset each day, but I want them to turn off at different times based on the day of the week.

Driveway, Basement Stairwell, Front Porch (dimmers) - On (100%) at Sunset and off at Sunrise
Family Room Lamp and Living Room Lamp (switches) - On at Sunset and off at 2am
Deck Lights (Switch) - On at Sunset and off at 11pm (M, T, W, Th, F) off at 2am (Sat, Su)
Shower Lights (Dimmer) - On at Sunset and off at 11:30pm
Under Cabinet (Dimmer) - On at Sunset (unless it’s already on and set to >45%) and off at 2am

3) What is happening/not happening?
I’m completely clueless so nothing is happening. :smiley:

**4) Post a Green Snapshot of the piston!
This is what I have so far, but I’m guessing it probably isn’t even close.

5) Attach logs after turning logging level to Full
No Logs quite yet.


#2

Very happy to help you. My first suggestion would be to put these in separate pistons. It would make them much easier to code and debug.
The first piston could look like this -

IF Time is sunrise
  THEN
    with Driveway, Basement Stairwell, Front Porch
      Do
        Set level to 100%
        Turn On
End IF
IF Time is sunset
  THEN
    with Driveway, Basement Stairwell, Front Porch
      DO
        Turn Off
End IF

I can help you further as you need it :slight_smile:


#3

Hi,
A piston executes when a trigger it is subscribed to is triggered. You can see the subscribed triggers in the piston listing, they have a lightening bolt next to them. When any trigger occurs, the whole piston runs from top to bottom.

In your example you have no triggers, the If is a condition. If you were to hit the test button, it would run, and if the time was within the range, the lights would turn on. If you replace the if with
image
it should run


#4


A yellow lightening bolt like above.


#5

Thanks so much for the help. I think it’s going to take some time for me to learn this stuff.

@Pantheon, I can’t seem to find the “IF Time is sunrise”. It only gives me options like is after, is any, is before, is between and is not between. I chose is after, but I’m not sure if that is correct? Sounds to me like by choosing is after sunrise, it’s going to keep turning the lights off when I turn them on manually?

Here is what I have so far. (Is there a way to copy and paste as text from the rule creator?)


#6


#7

That’s what I have, but got confused in your first post where it said:

IF Time is sunrise

Looks like I need to choose happens daily at


#8

Yes, sorry. Just pseudo-code in my first example. :slight_smile:


#9

No problem at all. I definitely appreciate the help.

Should these 5 pistons be staggered as far as timing? Is it going to cause some type of network congestion having 5 things execute at the exact same time? I was trying to put them all in one piston since I figured that would probably be more efficient?


#10

No need to worry about that right now. MANY programmers here use pre-set times (Sunrise, Sunset…). Your 5 pistons will run perfectly fine at those times. But you do get some internet latency sometimes and you may notice a slight variation.

At this point I would not worry to much about efficiency as much as correct logic and debugging. Once you get a better handle on these things, then you can smudge out the finer details.

I’m headed out for a little while…be back soon.


#11

How did I do with this one?

Do you need the “Turn On” portion after the “Set Level”, or does Set Level also turn on the device?

I wanted the under cabinet light to only turn on if the current value was <50%, but I couldn’t figure out how to do that, so I just went with the “if already off”.


#12

With most bulbs, Set level will also turn on the bulb…
(Unless the command is Set level to 0… Then it will turn off the bulb)


I often stagger pistons… Ideally so only one piston runs at any given moment. Technically, SmartThings can handle more than one, but as the complexity grows, too much commotion can loose commands occasionally. The stagger can be a few seconds, or a full minute.

IE:
At sunset +1 minute, Do stuff
At sunset +2 minutes, Do more stuff
etc


#13

Your piston looks good from here. I have not tested it.
I tend to use set level with my bulbs because I’m not always sure what the last level was and I don’t want to blind someone or walk into a dark room because of a previous setting. Your mileage may vary.