In SmartThings, I have a virtual on/off switch which I control using my Amazon Echo. I also have a CoRE piston setup with the following logic:
IF virtual switch CHANGES TO on
---- Turn on several lights to 100%
IF virtual switch CHANGES TO off
---- Turn off the same lights
Since I often control the same lights without using the virtual switch, I sometimes tell my Amazon Echo to turn the virtual switch ON when it’s already ON, or OFF when it’s already OFF. Fortunately, CoRE still evaluates CHANGES TO as true and the piston executes the actions exactly as intended.
In webCoRE, it appears that virtual switches are not evaluated the same way. I setup a webCoRE piston and if I tell my Amazon Echo to turn the virtual switch ON and the virtual switch is already ON, nothing happens (and vice versa). I’d love to see webCoRE updated to handle virtual switches the same as CoRE, but I’m not sure how much work that would be for the developers.
Does anyone have any suggestions how I can accomplish the same thing in a webCoRE piston using this virtual on/off switch?
My piston does a little more than I mentioned earlier, so not only did I have to make the change you suggested, I also had to break my one piston into two separate pistons and change the Subscription method on some of the conditions to Always subscribe, but now it works like my CoRE piston did.
Can someone please post a few examples of “show when/true actions” advanced options? I’d like to understand how to use them, and particular when it is prudent to do so compared to just adding more IF blocks. Thanks!
I’m trying to make a physical push button on the wall act as a light toggle. The rule is simple:
IF any of light 1, light 2, light 3 are Switch On then
IF any of light 1/2/3 level is > 0 then
call LIFX scene that turns all bulbs OFF
call LIFX scene that turns all bulbs on
I’m running into a problem tho because there is a delay from the time the last LIFX scene finishes until the time that the SmartThings Switch and Level attributes for the bulbs get updated.
For instance when the bulbs are on and the LIFX scene is called to turn off all lights (either triggered from the LIFX app or from Active LIFX Scene command), even tho the lights go out right away, it takes a few minutes before the Switch and Level attributes go to Off and 0.
So what’s happening is bulbs are on for a while, I press the toggle button, all lights go off. However if within a few minutes I press the button again to turn the lights back on (since they are now all off), the bulbs don’t turn on again because ST still see’s the stale attributes, until it refreshes minutes later.
Maybe there is some sort of command I can call that forces ST to update the attributes quicker?
Also please note that I cannot simply keep track of the on/off state myself and flip it each time the button is pushed. That is because there are other ways the bulbs can be turned on/off besides the push button, such as with the LIFX app directly or the Harmony remote.
Instead of using the Scenes for this, I could technically set all bulbs to Off and 0 and all bulbs to On and 100 for on/off. However I have many more bulbs than this (I limited my example to 3) and it looks messy with the bulbs turning on or off because they do not happen all at once when done programmatically - unlike with the scenes where they all go on or off at one time as one big group.
Created this piston to automate a curtain motor. My curtain motor has no discrete open or close, it just goes in the opposite direction each time it is triggered. The basic open at 9:00AM and close 30 mins before sunset works fine. The button press also works fine. What I wanted to do is add a latch so you could open or close when you want and it would reset the latch instead of triggering again when it gets to the next prescribed time. I think the following code will work, but my question is whether there is abetter more efficient way?
Thanks! I just took a very quick glance at group of groups DH. Looks great and I’ll definitely check it out. It says in the first post that it helps keep the attributes in sync (aka when you turn it off the Level will go to 0 ASAP instead of a few minutes later). Do you think using this DH will totally solve the challenge I have? Or will it just make it better but not 100%?
IOW I need to be able to hit the button and have it turn off all the lights (when any are on). And then just a second when I realize I need to put the lights back on I want to press it again and have it come back on.
I may also look into the other approach you mentioned, which is using a timer to refresh the bulbs. I know how to use timers, but what command(s) or approach within webCoRE needs to be done to perform the actual refresh?
Thanks. I played around with the refresh. It takes 5-7 seconds to refresh 10 bulbs. Yikes. My idea was to do a refresh() once the toggle button was pressed before checking on/off. But since that added this large delay I decided to put the refresh AFTER the lifx scene. This way the scene activation happens right away, but also means that if you have to wait at least 5-7 seconds after pressing the toggle button before you can do it again. I’d really like this to be closer to 1-2 seconds.
One idea is to do a mix of this plus my own state tracking. You see, I can’t do my own state tracking within webCoRE because another app like LIFX app may change the bulb state. But perhaps I can do a hybrid and track state of the button press. Because the main condition I care about is when someone presses the button.
Also do you know why a single button press is causing this code to run twice? Press the button once and the top IF’s GETS PUSHED is true which is good. But then 1 second later this routine executes again (according to the trace) exactly like the button was pressed a second time.
Okay, this is a fairly straight forward piston - if any of 3 light switches changes to on, then turn all 3 on. If any change to off, turn all 3 off. But I’m getting the dreaded “Piston waited at a semaphore for…” errors - why?
I thought about using IS, but I think that would be a problem because as they are turning on or off some will always be in other state which should reverse the piston - repeatedly, no?