There have been several threads on the problem of having a virtual switch stay in synch with a physical switch. But I haven’t quite solved the problem.
In my case, I have legacy push-button GE RR8 low-voltage relays all over my home. I have built a sensor (Thanks to st_anything!) that properly reports that status of the PHYSICAL switch. But now I want to be able to display the real physical switch status on the virtual switch icon (just on and off) whether or not the status was changed by the SmartThings/Arduino or by the wall switch.
The “obvious” approach is to detect the change and then do a sendevent()
. I don’t like this one so much. Here’s what happens.
-
Person pushes the wall switch
-
SmartApp is informed of the change in the relay status because it is subscribed to the arduino sensor’s device handler ON event.
-
That SmartApp It says, “wow, the status of the relay changed” and sends an on() command to the virtual switch device handler.
-
Of course, the Virtual Switch then says, well, I just got an on() command, so it send does a sendevent() to indicate that it is now on.
-
So the smartapp that is subscribed to listen to the Virtual switch says… oh the user wanted to turn off the light from his phone, so it sends a on() command to the arduino device handler which pulsed the relay a second time.
What I’d like to be able to do is to send a message to the Virtual Switch to say, "Change your state, but don’t fire off the “I changed my state” message.
I’ve tried setting an attribute value, but I’m having trouble accessing that attribute… mostly syntax errors, I think.
Anyone have an approach to this they have liked?
Paul