[RELEASE] Virtual Device Sync - Create Virtual Devices and Keep Them In Sync With a Physical Device

Hi Eric,

Great stuff. First and foremost - THANK YOU! I’m fairly computer and electronics literate but not a programmer and the entire ST platform is so buggy and non intuitive - If it weren’t for people like you I would have thrown the Hub in the toilet some time ago. :slight_smile:

Went through the above process for loading the SmartApp and Virtual Switches for my Aeon DSC17103 and all works well. My switch numbers 1&2 are backwards, however. Not sure if this is only me but might want to check that out on your side. Not a big deal but still could be confusing when wiring it all up…

Reason for my writing to you is that for one of my case uses, I require my virtual switches to be momentary in nature, not binary. I need them to trigger on the Aeon switches for about 1 sec and then shut off. This momentary voltage will then trigger a timed relay for switch 1 that will run a 24v DC power supply that will lower my window blinds and a timed relay for switch 2 to reverse the polarity of the 24VDC power supply and raise the blinds.

I am wondering if you could give me your insight into how to make the virtual switches your SmartApp automatically created for me into a momentary switch instead. Maybe just some simple code to switch out? (no pun intended)

Or if I should make anther set of virtual ‘momentary’ switches to run the virtual switches your app made I guess that would work too but would start getting kind of unwieldy. Not that Smartthings is not unwieldly to begin with :slight_smile:

Thanks in advance for your help.

Marc

Looks like that is the logs for the switch. Can you post the logs for the SmartApp?

@Levahj I agree, the community is definitely what makes the platform. As for the switch reversal do you mean that the switches on your wall don’t match up with switch 1 & 2 in the handler?

As for the momentary switch, I’ll have to give it some thought. I put together something I thought might work, but because of a race condition it is giving me issues. I am going to rethink my approach.

Eric,

Yes, the switches on the wall (the Aeon DSC17103 outputs to be specific) dont match up with 1 & 2 in the handler. No big deal because I just renamed the names myself but thought it was interesting no one else had mentioned it to you before.

Much appreciated if you can figure out the coding on making it a momentary switch. I’m getting all the other relays and things required to run the blinds correctly going but without a momentary switch in ST to run this Aeon DSC17103 I am kind of screwed!

Hi again,

Just found this in a separate thread. Dont know if this may help you with the code?


To make it momentary, use code like:

switch.on()
switch.off(delay: 500)
Which would give you a half-second (500ms) momentary pulse.


Thx,

Marc

I am having the same problem with Enerwave Dual Relay. I added the new Smart App and Device Handlers. I changed the device type to Simulated Switch. In the ST app it shows 0 endpoints.
Thanks for your help!

Thanks, I have been able to create the momentary switch, the problem has been keeping the virtual and physical in sync.

@BolognaBiscuit You need to assign the Enerwave handler to the Enerwave switch. You can use the one posted here:

Ok. If there is anything I can do to help you de-bug the sync let me know. I would like to help if I can!

Just reporting back. I decided to install a downrod on the fan as it was too high up, and in doing so rewired the whole thing including the zwn-rsm2. I found a hot wire up in the ceiling, so I have hot, neutral and the wire from the switch. I wired it up the right way and everything works perfectly! I have both aux connecting to the switch wire so turning the switch on and off turn on both loads and your app keeps it all perfectly in sync with smartthings. It updates status in a second or less of a physical flip of the switch and in realtime when done in app.

Thanks again for all your work!

Eric,

Thank you so much for helping. This switch is awesome now.

Thanks again,

Jason

2 Likes

Enerwave RSM2 Dual Relay Switch - Instructions for a quick install and setup

Written to be able to copy and save to a file you can use in the future if the need arises.
No way to link a pdf document so here’s an external link http://rollesolutions.com/EnerwaveInst.pdf
All code was graciously written for the Samsung community by Eric Maycock, Profile - erocm1231 - SmartThings Community

Extra time saver - Open two side-by-side browser windows.
In one window, log in to your Samsung Smart Things account https://graph-na02-useast1.api.smartthings.com/
In the other, open the links below. Then you can copy and paste into samsung without having to jump back and forth in one window.

Go here to copy raw code for the Enerwave RSM2 Dual Relay Switch (Device Handler)
https://raw.githubusercontent.com/erocm123/SmartThingsPublic/master/devicetypes/erocm123/enerwave-rsm2-dual-relay-switch.src/enerwave-rsm2-dual-relay-switch.groovy
Ctrl+A then ctrl+C or select all and copy the code
Log in to your Samsung account
Click “My Device Handlers” from the top menu.
Click “+Create New Device Handler”
Click “From Code” on the next screen
Ctrl+V or Paste the code you copied into the code window
Click “Create”
Click “Publish”

Go here to copy raw code for the Simulated Dimmer (Device Handler)
https://raw.githubusercontent.com/erocm123/SmartThingsPublic/master/devicetypes/erocm123/simulated-dimmer.src/simulated-dimmer.groovy
Follow process from above to publish

Go here to copy raw code for the Simulated Switch (Device Handler)
https://raw.githubusercontent.com/erocm123/SmartThingsPublic/master/devicetypes/erocm123/simulated-switch.src/simulated-switch.groovy
Follow process from above to publish

Go here to copy raw code for the Simulated Energy Switch (Device Handler)
https://raw.githubusercontent.com/erocm123/SmartThingsPublic/master/devicetypes/erocm123/simulated-energy-switch.src/simulated-energy-switch.groovy
Follow process from above to publish

Go here to copy raw code for the Virtual Device Sync (SmartApp)
https://raw.githubusercontent.com/erocm123/SmartThingsPublic/master/smartapps/erocm123/virtual-device-sync.src/virtual-device-sync.groovy
Ctrl+A then ctrl+C or select all and copy the code.
Log in to your Samsung account if needed.
Click “My SmartApps” from the top menu.
Click “+New SmartApp”.
Click “From Code” on the next screen.
Ctrl+V or Paste the code you copied.
Click “Create”.
Click “Publish”.

Click “My Device Handlers”
Confirm that you see the following in the list, if not repeat the process for any missing items.
Enerwave RSM2 Dual Relay Switch
erocm123 : Simulated Dimmer
erocm123 : Simulated Energy Switch
erocm123 : Simulated Switch

Click “My SmartApps”
Confirm that you see the following in the list, if not repeat the process for the missing item.
erocm123 : Virtual Device Sync

Connect your Enerwave ZWN-RSM2 switch to temporary or actual house wiring.
Temporary makes it easy to ensure the device is working well before pulling all your switches out of the wall and wiring them up.
Ensure good connections and power it up.
Have a toothpick, or other small object, you can use to activate the small pushbutton switch on the Enerwave device (to enter learning mode).
Open your Smart Things app, select “+” (top right) then “Add a Thing”.
Select “Start looking for Things”.
With your toothpick, press the push-button switch once on the Enerwave device.
When the device is recognized, click next, give it a name, then keep clicking next without adding any smart apps until your device has been added.
Close the App so it is not running in the background.

Go back to your Smart Things account.
Log in if necessary.
Click “My Devices” from the top menu.
Scroll to your newly added Enerwave device.
Click on it’s link (under display name).
Click “Edit” at the bottom of the screen.
Click the “Type” dropdown and select Enerwave RSM2 Dual Relay Switch.
Click “Update”.
You can log out of your Samsung account now.

Open the app on your phone or tablet
Select “Marketplace”
Select “SmartApps”
Scroll down to and select “My Apps”
Select “Virtual Device Sync”
Tap to select your new switch under “Which Physical Switch”
Click “Create Virtual Devices”
Click “Done” to finish.

You will now be able to control your Enerwave ZWN-RSM2 accurately. You will have three switches in your list of “Things”.
The first should turn both relays on or off.
The next two will control each relay independently.

Below are links to the community discussion and the author of the app as well as the relevant pages on the Samsung community site.

I have two RSM2 devices, one can control both relays at the same time from the main device (the real one, not the virtual devices) in SmartThings, while the other cannot.

I installed one in the living room. Initially it would control both switches at the same time from the main button in SmartThings. At some point in the process, the main control quit working: It appears to function, but no response from the switches. There were other issues with the device so I replaced it, but the result is the same – it worked for a few minutes. This is true before configuration with erocm123 device type and app. After configuring, the main device still doesn’t work.

I have another that I installed in the master bedroom. Both switches could be controlled by the main device control in SmartThings, before and after setup with the erocm123 device type and app.

Both switches on both devices function fine independently using the erocm123 device type and app, just the living room switch main device control is non-responsive.

Here is the info from the log. I see there are differences in isStateChange and Displayed:
Living Room:
34e03816-f68e-454b-b7a5-b61028e377be 10:13:03 PM: debug Parsed MultiChannelCmdEncap(bitAddress: false, command: 3, commandClass: 37, destinationEndPoint: 0, parameter: [0], sourceEndPoint: 2) to [[‘name’:switch2, ‘value’:‘off’, ‘isStateChange’:false, ‘displayed’:false, ‘linkText’:‘All Living Room Lights’, ‘descriptionText’:All Living Room Lights switch2 is off], [‘name’:‘switch’, ‘value’:‘off’, ‘isStateChange’:false, ‘displayed’:false, ‘linkText’:‘All Living Room Lights’, ‘descriptionText’:All Living Room Lights switch is off]]
34e03816-f68e-454b-b7a5-b61028e377be 10:13:02 PM: debug Parsed MultiChannelCmdEncap(bitAddress: false, command: 3, commandClass: 37, destinationEndPoint: 0, parameter: [0], sourceEndPoint: 1) to [[‘name’:switch1, ‘value’:‘off’, ‘isStateChange’:false, ‘displayed’:false, ‘linkText’:‘All Living Room Lights’, ‘descriptionText’:All Living Room Lights switch1 is off], [‘name’:‘switch’, ‘value’:‘off’, ‘isStateChange’:false, ‘displayed’:false, ‘linkText’:‘All Living Room Lights’, ‘descriptionText’:All Living Room Lights switch is off]]
Master:
fe5ff0a8-8b7d-44f7-b083-1937db6eeb87 10:12:56 PM: debug physicalHandler called with event: name:switch2 source:DEVICE value:on isStateChange: true isPhysical: false isDigital: false data: {“microDeviceTile”:{“type”:“standard”,“icon”:“st.switches.switch.on”,“backgroundColor”:"#79b821"}} device: All Master Lights
0b38ae46-b8e8-4946-8a00-9f9214d887c9 10:12:56 PM: debug Parsed MultiChannelCmdEncap(bitAddress: false, command: 3, commandClass: 37, destinationEndPoint: 0, parameter: [255], sourceEndPoint: 2) to [[‘name’:switch2, ‘value’:‘on’, ‘isStateChange’:true, ‘displayed’:true, ‘linkText’:‘All Master Lights’, ‘descriptionText’:All Master Lights switch2 is on], [‘name’:‘switch’, ‘value’:‘on’, ‘isStateChange’:false, ‘displayed’:false, ‘linkText’:‘All Master Lights’, ‘descriptionText’:All Master Lights switch is on]]
fe5ff0a8-8b7d-44f7-b083-1937db6eeb87 10:12:56 PM: debug physicalHandler called with event: name:switch1 source:DEVICE value:on isStateChange: true isPhysical: false isDigital: false data: {“microDeviceTile”:{“type”:“standard”,“icon”:“st.switches.switch.on”,“backgroundColor”:"#79b821"}} device: All Master Lights
0b38ae46-b8e8-4946-8a00-9f9214d887c9 10:12:55 PM: debug Parsed MultiChannelCmdEncap(bitAddress: false, command: 3, commandClass: 37, destinationEndPoint: 0, parameter: [255], sourceEndPoint: 1) to [[‘name’:switch1, ‘value’:‘on’, ‘isStateChange’:true, ‘displayed’:true, ‘linkText’:‘All Master Lights’, ‘descriptionText’:All Master Lights switch1 is on], [‘name’:‘switch’, ‘value’:‘on’, ‘isStateChange’:true, ‘displayed’:true, ‘linkText’:‘All Master Lights’, ‘descriptionText’:All Master Lights switch is on]]

Unrelated: Will this app work with an RSM1 single-relay switch to sync the real switch status? So far no-go for me.

Any input is appreciated.

@erocm1231

Very nice work! I installed via the GitHub repository method with no issues. Do you know if the zooZ powerstrip does power metering?

Thanks!

Bob,

I’m not sure about the Zooz, however I learned the hard way that power metering alone may not suffice. Some devices report in total accumulated kWh, while others may tally this along with real-time Watts (Watts is what is needed). An Aeotec Z-Wave Smart Switch 6, Gen5 works, while an Aeotec Z-Wave Micro Smart Energy Switch, 2nd Edition does not. Even with the functioning switch, the polling rate is not sufficient to stop a battery charge where I want. :frowning:

Eric, getting following error. “Error when creating the virtual devices. Make sure that you have all of the Simulated device handlers installed”. What do I need to do?

Oceans, install the Device Type Handlers needed. The simulated DTHs are listed at the top of the thread. I have added links below for convenience.

simulated-dimmer.groovy
simulated-switch.groovy
simulated-energy-switch.groovy

:slight_smile:

Thanks Bob. I am a newbee, but having fun! Here is my silly question. I installed the Device Handler for the zooZ Power Strip and it works. Do I replace that Device Handler or is the DTH installed in addition to the Device Handler? If so where do I install the DHT?

1 Like

Ok, I read that DH and DHT are the same thing. Some how I got this to work it to work. I hate to admit it, but I am not certain how. I seem to have the 5 virtual and controllable plugs for the zooZ Power Strip and have it as originally configured (as one power strip without individual controls. Sometime you get lucky:grinning:

Hi @erocm1231. Could you please add capability “Actuator” to your virtual DHs ?
This is needed for some smartapps (like SmartTiles/ActionTiles) to be able to locate/authorize the Device.
Thanks.

Rudi, unless you are syncing the code directly from GitHub you can add it your self very easily. In the metadata section at the top of the DTH code just add:

    capability "Sensor"
    capability "Actuator"

its as easy as pie! :slight_smile:

good luck!

Hi Bob, I’ve already done that to my local copy (I’m syncing with Eric’s github but you can change your local copy).
I was just sending a suggestion, but thanks for your reply.