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

Sorry for the delay. I was using the device handler. Thank you for your efforts.

I got this working for one device (Aeon SmartStrip). However, adding a 2nd of the same device and things seem to go haywire. Anyone run into this before and have any advice?

I’ve been using several instances of this SmartApp with a lot of devices for some time. Haven’t had any issues. What kind of stuff are you seeing?

I removed and re-added the second one a few times, and it finally started working. Not sure what the root issue was. Thanks!

@erocm1231 I’ve installed the Virtual Device app and device handlers to manage my Aeon Power Strip. In general it works great but I’ve also noticed some strange behavior. Sometimes when I switch on or off a couple of the virtual switches, the status on the other virtual switch and the strip itself will also change. For example, if I start with everything on then switch virtual switch 2 & 4 to off, the status for the strip and virtual switches 1 & 3 change to off but are physically still on. if I tap the strip or virtual 1 or 3 the status changes to the correct state, in this case on, nothing happens physically. If I tap the strip or virtual 1 or 3 again it will switch to off as expected. Have you see this behavior before, any ideas on how to fix? Thanks!

1 Like

I’ve seen this and it almost seems like an app bug. Are you using iOS or Android?

I’m using Android

Hello,
This feature is for switch and dimmer but what i need is to creat

a virtual temp sensor (Fibaro FGK-101 with a thermal sensor)

a virtual door sensor (Fibaro FGBS-001 with a temp sensor and a contact sensor)

If it is easy to custom one of the DH, can you tell me please

Thank you

I have Vitrum multichannel switches (i.e., 3 switches on 1 device).

Adding them without a special device handler, it shows up as a single device on the ‘main’ screen on the app, and then when I click on the device, it shows the 3 endpoints. In the IDE, it also shows that there are three endpoints.

I then attach the ‘switch’ device handler above to the Vitrum device in the IDE. Then when I run the smartapp, it doesn’t find any endpoints from which to create additional devices.

What am I doing wrong?

Many thanks,
Jonathan

@jreiner I’m experiencing the exact behaviour. To make matters worse, I have “notify me when” setup for the virtual switches and they get triggered when the status falsely changes. @erocm1231 Do you have any suggestions? How can we debug this

Has anyone came across a sync for a virtual lock? I have an on/off switch that controls a piston on a door lock. I use it on my sliding glass door. I want the virtual door lock to be locked if the switch is on, unlocked if it is off. I have been looking and this smart app is the closest, but I am not smart enough to make it work with a virtual lock.

Im managed to get it working. However I’m facing one small issue. My switch on/off position is upside down. Previously when I press on top, it will turn on the light. Now after using the Enerwave RSM2 Dual Relay Switch device handle for my tkbhome dual relay switch, it become off button. How do I toggle the position back?

I managed to solve it by copied some value from z-wave switch. Technically I need to enable the ledindicator.

Alot of tkbhome zwave switch will invert using custom device handler.

1 Like

Hi there

I get these errors when I try to turn on simulated switch 1 and only 1, the 2nd simulated switch works perfectly fine.

0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:55 pm: error java.lang.IllegalArgumentException: Command ‘off1’ is not supported by device a27047ec-f921-4e66-9d81-98db5225c387 of type ‘ZigBee Gang 2 Switch’. Supported commands: [on, off, configure, refresh, on0, off0, on, off, on2, off2] @line 236 (doCall)
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:55 pm: debug getChildDevices(false), children=2
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:55 pm: debug virtualHandler called with event: deviceId a6685f54-3a9e-4595-9a6d-82a212061a53 name:null source:COMMAND value:off isStateChange: true isPhysical: false isDigital: false data: null device: Kitchen/Dining - 1
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:53 pm: error java.lang.IllegalArgumentException: Command ‘on1’ is not supported by device a27047ec-f921-4e66-9d81-98db5225c387 of type ‘ZigBee Gang 2 Switch’. Supported commands: [on, off, configure, refresh, on0, off0, on, off, on2, off2] @line 236 (doCall)
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:53 pm: debug getChildDevices(false), children=2
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:53 pm: debug virtualHandler called with event: deviceId a6685f54-3a9e-4595-9a6d-82a212061a53 name:null source:COMMAND value:on isStateChange: true isPhysical: false isDigital: false data: null device: Kitchen/Dining - 1
0622a9dc-4ea2-4428-b505-f5490c6b0597 8:52:51 pm: error java.lang.IllegalArgumentException: Com

Any help would be greatly appreciated

Thanks

Oops, just replied to your post in the other thread:

“It looks like the device handler wasn’t designed to work with this app. Which handler is it?”

ZigBee Gang 2 Switch

metadata {
definition (name: “ZigBee Gang 2 Switch”, namespace: “smartthings”, author: “smartthings”) {
capability “Actuator”
capability “Configuration”
capability “Refresh”
capability “Switch”

    capability "Temperature Measurement"
    
    attribute "lastCheckin", "string"
    attribute "switch", "string"
    attribute "switch1", "string"
	attribute "switch2", "string"
    command "on0"
command "off0"
command "on"
command "off"
command "on2"
command "off2"
}

// simulator metadata
simulator {
    // status messages
    status "on": "on/off: 1"
    status "off": "on/off: 0"

    // reply messages
    reply "zcl on-off on": "on/off: 1"
    reply "zcl on-off off": "on/off: 0"
    
   
}

tiles(scale: 2) {
 multiAttributeTile(name:"switch", type: "device.switch", width: 6, height: 4, canChangeIcon: true){
        tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 
            attributeState "on", label:'switch', action:"off0", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "off", label:'switch', action:"on0", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
            attributeState "turningOn", label:'switch', action:"off0", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "turningOff", label:'switch', action:"on0", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
        }
       	tileAttribute("device.lastCheckin", key: "SECONDARY_CONTROL") {
			attributeState("default", label:'Last Update: ${currentValue}',icon: "st.Health & Wellness.health9")
	   	}
    }
    multiAttributeTile(name:"switch1", type: "device.switch", width: 6, height: 4, canChangeIcon: true){
        tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 
            attributeState "on", label:'switch1', action:"off", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "off", label:'switch1', action:"on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
            attributeState "turningOn", label:'switch1', action:"off", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "turningOff", label:'switch1', action:"on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
        }
       	tileAttribute("device.lastCheckin", key: "SECONDARY_CONTROL") {
			attributeState("default", label:'Last Update: ${currentValue}',icon: "st.Health & Wellness.health9")
	   	}
    }
    
   
    multiAttributeTile(name:"switch2", type: "device.switch", width: 6, height: 4, canChangeIcon: true){
        tileAttribute ("device.switch2", key: "PRIMARY_CONTROL") { 
            attributeState "on", label:'switch2', action:"off2", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "off", label:'switch2', action:"on2", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
            attributeState "turningOn", label:'switch2', action:"off2", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
            attributeState "turningOff", label:'switch2', action:"on2", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
        }
       	tileAttribute("device.lastCheckin", key: "SECONDARY_CONTROL") {
			attributeState("default", label:'Last Update: ${currentValue}',icon: "st.Health & Wellness.health9")
	   	}
    }
   


    standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
        }
   main(["switch"])
    details(["switch1","switch2", "refresh"])
}

}

// Parse incoming device messages to generate events

def parse(String description) {
log.debug “Parsing ‘${description}’”

def value = zigbee.parse(description)?.text
log.debug “Parse: $value”
Map map = [:]

if (description?.startsWith(‘catchall:’)) {
map = parseCatchAllMessage(description)
}
else if (description?.startsWith(‘read attr -’)) {
map = parseReportAttributeMessage(description)
}
else if (description?.startsWith('on/off: ')){
log.debug “onoff”
def refreshCmds = zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: 0x10]) +
zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: 0x11])

return refreshCmds.collect { new physicalgraph.device.HubAction(it) }
//def resultMap = zigbee.getKnownDescription(description)
//log.debug “${resultMap}”

    //map = parseCustomMessage(description) 
}

log.debug "Parse returned $map"
//  send event for heartbeat    
def now = new Date()

sendEvent(name: "lastCheckin", value: now)

def results = map ? createEvent(map) : null
return results;

}

private Map parseCatchAllMessage(String description) {
Map resultMap = [:]
def cluster = zigbee.parse(description)
log.debug cluster

if (cluster.clusterId == 0x0006 && cluster.command == 0x01){
	if (cluster.sourceEndpoint == 0x10)
    {
    log.debug "Its Switch one"
	def onoff = cluster.data[-1]
    if (onoff == 1)
    	resultMap = createEvent(name: "switch1", value: "on")
    else if (onoff == 0)
        resultMap = createEvent(name: "switch1", value: "off")
        }
        else if (cluster.sourceEndpoint == 0x11)
        {
        log.debug "Its Switch two"
	def onoff = cluster.data[-1]
    if (onoff == 1)
    	resultMap = createEvent(name: "switch2", value: "on")
    else if (onoff == 0)
        resultMap = createEvent(name: "switch2", value: "off")
        }
}

return resultMap

}

private Map parseReportAttributeMessage(String description) {
Map descMap = (description - “read attr - “).split(”,”).inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
//log.debug “Desc Map: $descMap”

Map resultMap = [:]

if (descMap.cluster == "0001" && descMap.attrId == "0020") {
	resultMap = getBatteryResult(convertHexToInt(descMap.value / 2))
}

else if (descMap.cluster == "0008" && descMap.attrId == "0000") {
	resultMap = createEvent(name: "switch", value: "off")
} 
return resultMap

}

def off() {
log.debug “off()”
sendEvent(name: “switch1”, value: “off”)
“st cmd 0x${device.deviceNetworkId} 0x10 0x0006 0x0 {}”
}

def on() {
log.debug “on()”
sendEvent(name: “switch1”, value: “on”)
“st cmd 0x${device.deviceNetworkId} 0x10 0x0006 0x1 {}”
}
def off2() {
log.debug “off2()”
sendEvent(name: “switch2”, value: “off”)
“st cmd 0x${device.deviceNetworkId} 0x11 0x0006 0x0 {}”
}

def on2() {
log.debug “on2()”
sendEvent(name: “switch2”, value: “on”)
“st cmd 0x${device.deviceNetworkId} 0x11 0x0006 0x1 {}”
}

def off0() {
log.debug “off0()”
sendEvent(name: “switch”, value: “off”)
“st cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x0 {}”
// “st cmd 0x${device.deviceNetworkId} 0x11 0x0006 0x0 {}”
}

def on0() {
log.debug “on0()”
sendEvent(name: “switch”, value: “on”)
“st cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x1 {}”
// “st cmd 0x${device.deviceNetworkId} 0x11 0x0006 0x1 {}”
}
def refresh() {
log.debug “refreshing”
[
“st rattr 0x${device.deviceNetworkId} 0x10 0x0006 0x0”, “delay 1000”,
// “st rattr 0x${device.deviceNetworkId} 0x10 0x0006 0x0”, “delay 250”,

//   "st rattr 0x${device.deviceNetworkId} 0x10 0x0001 0x0", "delay 250",
//    "st rattr 0x${device.deviceNetworkId} 0x10 0x0000 0x0",
    "st rattr 0x${device.deviceNetworkId} 0x11 0x0006 0x0", "delay 1000",

// “st rattr 0x${device.deviceNetworkId} 0x11 0x0006 0x0”, “delay 250”,

//    "st rattr 0x${device.deviceNetworkId} 0x11 0x0001 0x0", "delay 250",
//    "st rattr 0x${device.deviceNetworkId} 0x11 0x0000 0x0",
]

}

private Map parseCustomMessage(String description) {
def result
if (description?.startsWith('on/off: ')) {
if (description == ‘on/off: 0’)
result = createEvent(name: “switch”, value: “off”)
else if (description == ‘on/off: 1’)
result = createEvent(name: “switch”, value: “on”)
}

return result

}

private Integer convertHexToInt(hex) {
Integer.parseInt(hex,16)
}

def off1() {
log.debug “off()”
sendEvent(name: “switch2”, value: “off”)

"st cmd 0x${device.deviceNetworkId} 0x10 0x0006 0x0 {}" 

}

def on1() {
log.debug “on()”
sendEvent(name: “switch2”, value: “on”)

"st cmd 0x${device.deviceNetworkId} 0x10 0x0006 0x1 {}" 

}

What Handler should I should for this to work?

It is hard to see the handler since it is not in a code block. The App uses the on/off1 and on2/off2 commands, but your handler has on/off0. You can try changing those commands and the corresponding code in the handler to on1 & off1 to see if that makes it work.

You can look up any of the handlers posted in the first post for reference.

OK I’m confused. I have an RSM2 I’ve been having trouble with for awhile and I’m determined to fix it. I’m confused about which device handler and smartapps to install. I found a groovy from 2016 and another from 2017. I have a ZWN-RSM2.

It is kind of a tricky issue. There are at least a couple different versions of that relay out there. I would try the 2017 version which does not require a SmartApp to be installed. Just the parent and child device handler and then hit the gear icon in the SmartThings app and hit “save”. That should create two child devices that represent the 1st and 2nd channel.

Hopefully that will get things working.

Hey

I’ve installed the smartapp and 3 device handler … no problem there, when I use the smartapp with a fibaro double switch 2 it doesn’t detect any endpoints and thus stops me dead in my tracks … any ideas why ???