New and Completely Stuck With This

So I’m very new to this, but I’ve played with code a bit before. What I’m trying to accomplish seems simple, but I’m stuck.

I have a virtual switch triggering an Alexa Routine. For example, to turn all my lights on. The problem is, I can’t get the button to recognize whether the device is already in a state. ie: An All Lights On switch that gets left “on” after using it, so I have to effectively turn it off (which does nothing) and then turn it back on for it to work.

I want the button to reset without triggering another function, or to turn on automatically if the lights are turned on through a voice command instead.

Even if I had 4 different “scene” switches, and when I clicked another one, the first turns off and the scene changes.

Is this possible?

1 Like

You can make a virtual momentary switch if I understand correctly. Or add in a rule that switches your virtual switch off after 2 seconds after it turns on.

As I understand it, every time you run the routine, the lights go on and then off, so above should work for that.
If you want the status for the lights, I used to do this by make any of all the lights a trigger, let it wait 2 seconds and if after the 2 seconds all the lights are ON, it would change a variable I could use to show all the lights being on.
Adding that variable tile to a dashboard and making the tap action a rule that triggers the virtual switch, you have a tile that shows the status and operates the scene.

You can also use that variable to check and use in a rule to turn it off when you change scene.

1 Like

Man… that’s exactly what I needed. I knew it seemed simple I just could not for the life of me make it work. I really hadn’t played with rules or variables yet. That’s definitely my problem :joy:

Thank you!

1 Like

Rules and variables are a bit of a rabbit hole. I’ve been replacing rules still after a few months, just because I came up with a more logical or easier way to make them.

Example, used to have the rule I mentioned above, now I made a group of lights in Smartthings and a virtual switch that controls the group. This switch also controls a variable to check if all the lights are on or off.
For my evening lights which turn on daily, I used to have 2 rules for them, now I just use an if condition to check on the time, so if it’s morning they turn off and evening on, eliminating a rule.

1 Like

Hi my friend, I am not sure if I am getting your goal, but I will try to share what I did for something like you are looking for.

Virtual Device: Garage Light Switch
Automation 1: IF: Garage Light Switch ON, THEN: Hue 1 ON, Hue 2 ON
Automation 2: IF: Garage Light Switch OFF, THEN: Hue 1 OFF, Hue 2 OFF
Automation 3: IF Hue 1 OFF and Hue 2 OFF, THEN: Garage Light Switch OFF
Automation 4: IF Hue 1 ON and Hue 2 ON, THEN: Garage Light Switch ON

Which hub are you using ?

Using a Smart Things hub. Love the feedback everyone I appreciate you!

I just saw that Sharptools now supports scenes in rules so now I’m rethinking everything.

Super excited to play with some things tonight!

1 Like

Hi Taylor, I think that scenes are not supported directly, you need to use a virtual switch that works as intermediate, am I wrong ?

Our next generation Samsung SmartThings connection supports Scenes directly. You can find more details about this here:

2 Likes

Yeah they only work in rules at the moment or with a virtual switch I just didn’t realize

Scenes are available in the dashboards and Rule Engine for the next-gen integration:

1 Like

A post was merged into an existing topic: [BETA] Samsung SmartThings Next-gen Integration