Virtual Switch that follows the state of Physical Switch

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.

This is one of the built-in problems with an asynchronous design. Interestingly, in some cases turning something on that you think is already on is harmless. In other cases not so good. So with ST if the state of a device is lost for a moment, things depending on that state being correct will fail.

It is possible to work around some of this with custom apps, but not all of it. Some of this behavior is intrinsic to the architecture of ST even when it is working properly. Toss in some ST server / comms issue, and it’s gonna fail.

1 Like

This is my idea.

when it runs set a state.

state.running for instance and give that a value of true

At the same time have a method that only has state.clear() as an action and call that method a minute later.

Then only run any of the switch actions if
state.running != true

Essentiality only allowing one action per minute

This may help you with the app you were trying to build beofre @baldeagle072

Guys if you do improve upon the code do let us know, For now the code is working. I have incorporated in Binder for dual relay and virtual switches and the relay (1 & 2) are able to stay in sync.
Just one problem though. I am not able to catch the event for physical throw of switch, I do not know if the switch is generating it, it should. Noting in

def parse(String description) {
 log.debug "Parsing desc => '${description}'"

def result = null
def cmd = zwave.parse(description, [0x60:3, 0x25:1, 0x32:1, 0x70:1])
log.debug cmd
if (cmd) {
    result = createEvent(zwaveEvent(cmd))
}
log.debug "Parsing result => '${result}'"
return result

}

I just installed a Linear WS15Z wall switch and a Linear WT00Z accessory switch.

I was planning to use Big Switch so the WT00Z controlled the WS15Z via ST per JDRoberts’ suggestion.

However, Big Switch is no longer on the list of Officially Published Apps. Can someone tell me where to find it? Or it is no longer working? If so, is there a replacement with similar functionality.

I didn’t want to use the minimote to associate the switches since JDRoberts said that ST will not know the status of the switches if they talk directly to each other.

Would appreciate any help, suggestions!

You can use Rule Machine to do this, and much more…

Thanks Bruce, I installed Rule Machine and plan to use it in the future.

But for now, I found that the Smart Lighting app will let my WT00Z accessory switch control the master WS15Z switch.

The WT00Z is basically a one button scene controller!

Looks like this only sync on/off on switches, which works really well. Is it possible to add dimming level sync as well on dimming lights?

It worked very well for months. But last weekend all of a sudden the 2 switches ping pong each other indefinitely so I had to remove it, any idea what may have caused it?

This has happened to me off and on. I guess it is due to occasional
network delays. I either reboot the hub or throw the breake on the device
to reset it. Hope it helps.

Yes, I rebooted the hub to get them out of the infinite loop too.

I put the smartappp back and ya it’s working fine now again. Thanks.

Would be nice to have a mechanism to prevent it from happening. My wife (who triggered this) was not pleased :sweat_smile:

Hi, I also had the two switches “ping pong” yesterday. And I checked the code of @tslagle13 and found out that the code does not help prevent loop, it worked because of how smartthing works as @JDRoberts explained. So if something goes wrong, it may loop.
(the “if” lines were useless 'cause it check the status of the active device it self)
So I did change the code and it still works and I believe it will not cause any looping.
I still leave the credit to @tslagle13 in the code. Cheers.


Btw, I think this code can be done simplier with WebCoRe, but I still use this code to work with my multi-switches device after some modification.

1 Like