Virtual Switch that follows the state of Physical Switch

Apologies if this has been answered before:
I Physical Switches for which I would like to use Virtual Switches. I would like help with code to allow Virtual Switch to remain in same state as the physical switch. For example, if a switch is turned on physically, it would be ideal to see the Virtual switch change state.

If someone has a working code, it would be a great help.

Thanx

You can do this with the smartapp “the Big Switch.” It doesn’t care whether a switch is virtual or physical, it just assigns one to follow the other.

1 Like

Thans for the tip @JDRoberts will look into the code now.

It’s in the MORE section of Smart Setup, #16 under Convenience:

Thanks @JDRoberts … Tried it in IDE but did not work, will try on mobile too. But Big Switch I see is One-to-Many, Not sure if it can transfer state to say On/Off Tile?

You would install the Big Switch smartapp from the mobile app, not the IDE. It works just fine with one master and one slave, it can be one to many but doesn’t have to be.

As long as the On/Off tile is a virtual Switch that has a device ID and is recognized in your network, it should work.

However, you have to first create the virtual device so that both the physical switch and the virtual switch are known to SmartThings. Then you can slave it to the other switch using the Big Switch smartapp.

See:

I must be missing something… I have one on/off Button Tile as master linked to one Physical Zwave switch. When I switch the virtual tile on/off, things work fine. but when I change the state on the physical switch (physically) or on the app, virtual tile does not change state. I am using the Big Switch app as a binder.

What’s the exact model of the physical switch?

And if you have two switches, A and B, ( physical or virtual), you would need one installation of the Big Switch to tell B to follow A.

It sounds like you ALSO want A to follow B.

@tslagle13 or @tgauchat would know more about two way associations. That might need a different smartapp.

Put this together in like 5 minutes soooooo it could be horribly wrong… but I think this is what you are looking for.

1 Like

@jjhambc @tslagle13, how about looking at this code for a SmartApp you can create:

https://raw.githubusercontent.com/constjs/jcdevhandlers/master/smartapps/jscgs350/master-and-child-switches.src/master-and-child-switches.groovy

I personally haven’t tried it with a virtual device, but it should still work.

If I understand what the OP wants, he wants the two switches to synch up, no matter which one triggers first. So:

A is the master, B is the slave

AND

B is the master, A is the slave.

Sometimes this is easy, sometimes it sets up an endless loop. Not sure what ST code is needed, if any, to avoid a loop.

@bravenel might know.

1 Like

Mine should not loop :smile:

Each switch is both the slave and the master.

3 Likes

Got it, needed to keep up with this discussion.

1 Like

Yes @JDRoberts I want Virtual tile to remain in sync wit the physical switch.
I have two types of Dual relay inserts, TZ04 from TLBHOME and Vision ZL7432. I use them with a device driver patched up from Aeon Strip. Virtual tiles make it easier to use. I just need a way by which the virtual tile some how reflects current on of status of the physical relays. I will be using two virtual tiles per device.

@johnconstantelo Going to try your code now. Thanks in advance.

@tslagle13 TIM this looks perfect, works too Many Thanks :smile:

2 Likes

I understand that it does not loop, but I’m wondering why. What syntax is stopping a loop?

1 Like

Honestly I may need to add some checks into this. It shouldnt loop in MOST cases but I see where it can. I was gonna add the checks tomorrow. :smile:

I only asked because I tried to do something like this before and ran into a looping problem with everything I tried.

There’s something in SmartThings, but I’m not sure exactly what or when, that causes a command to not be sent if ST thinks the device is already in the state being requested. That would stop a loop.

Turn A on.
ST turns A on.
app subscribing to A then tells requests B to turn on.
ST turns B on.
App subscribing to B then requests A to turn on. ST believes A is already on, so ignores the request.

You can see this on the Hello,Home screen: “X was already set as you requested.”

This is actually a problem for me with the lock sometimes, if the tile is out of synch with the lock we have to do a manual unlock.

I also have this problem with Hue lights. Once ST thinks a bulb is on, it won’t send an on request.

But I don’t know exactly when this happens.