Best way to activate a piston from another piston?


#1

Hi. I’ve got a piston that turns on some lights when a button is pressed, and I would like it to also open the blinds sequentially. I have another piston that does that, because I have a separate button for that only. What is the best way to activate the “open all blinds” piston from the “turn on the lights” piston? I can think of a global variable, but I’d like to know if there’s another best way to manage this.

Thanks,
Rodrigo


#2

Did my logic for your “blinds” piston work or was it flawed? Just curious.

You can use Execute PIston. You can look HERE for suggestions.


#3

Same way as you would set a variable. In Location, there is an Execute Piston option. You could also create a virtual switch in the Smartthings IDE, and flip this switch from one piston, while using it as a trigger on the second piston. I tend to go this route often so I can have a virtual switch to flip in the iphone app and not only rely on physical buttons.


#4

I have some virtual switches too with that purpose but I don’t need to control this piston from the phone, so I’ll go with Excecute Piston.

Thanks!


#5

Is it OK to have actions for two different buttons in the same piston like this?

If so: Is there any way to use Execute Piston to run only one of those actions? (i.e. the action that works with Button 3 in line 45).

Thanks!


#6

It should be fine as long as at least 31 seconds pass between the time you press #2 and #3

Note:
Line 54 is still a global. You might want to delete the @ so it executes properly.


Yes, but it really complexifies the code on both the sending and receiving pistons.

You can add:
?open=true
or
?open=false
to the end of the URL in the sending piston, but then you also have to add another IF check back in the receiving piston. IF {$args.open} is true

Personally, I would split them if you want that capabilities, and simply use two different URLs.

If you decide to keep them both in the same piston, you might want to change the variables in the second half to ns2 so there is no conflict between button presses.


#7

What could be the problem if I press the button before the 30 seconds? It’s working fine as I expect it to work:
I press Up or Down, motor starts moving, then if I press Up or Down less than 30 seconds after, it stops moving. If I press it after 30 seconds, it starts moving again (because it stopped at 30 seconds).

R.


#8

If you followed my advice to use ns2 for the bottom half, you can ignore my warning, LOL.

Otherwise, the first button will set the variable to true when opening, which means that you will not be able to close the blinds until 30 seconds have passed, and the variable is back to false.

This is also true in reverse. If you close your blinds, you will be unable to open them until 30 seconds have passed.

Keeping ns1 up top, and using ns2 for the bottom half resolves this occasional issue


#9

But if I press the button again within 30 seconds, the motor stops and the variable is set to false. Or at least that’s how I thought it would work and also how it seems to be working.

I just played with it pushing one of the buttons every 6 seconds and all of them either started the motor on the way I pushed or stopped the motor if it was running, and that’s exactly what I want it to do :smiley:


#10

Oh right. If you stop it first, the variable changes to false, and then you can reverse it if you want. Maybe that way is better for the motor anyways instead of going straight from opening to closing.

Please disregard my last two posts, LOL