SHARD-159: Wemo (Connect) updated() fails in certain IP change scenarios

This commit is contained in:
Luke Bredeson
2016-04-20 16:07:11 -05:00
parent 8b465b03b4
commit 84de336a1a

View File

@@ -236,23 +236,22 @@ def addSwitches() {
d = getChildDevices()?.find { d = getChildDevices()?.find {
it.deviceNetworkId == selectedSwitch.value.mac || it.device.getDataValue("mac") == selectedSwitch.value.mac it.deviceNetworkId == selectedSwitch.value.mac || it.device.getDataValue("mac") == selectedSwitch.value.mac
} }
} if (!d) {
log.debug "Creating WeMo Switch with dni: ${selectedSwitch.value.mac}"
if (!d) { d = addChildDevice("smartthings", "Wemo Switch", selectedSwitch.value.mac, selectedSwitch?.value.hub, [
log.debug "Creating WeMo Switch with dni: ${selectedSwitch.value.mac}" "label": selectedSwitch?.value?.name ?: "Wemo Switch",
d = addChildDevice("smartthings", "Wemo Switch", selectedSwitch.value.mac, selectedSwitch?.value.hub, [ "data": [
"label": selectedSwitch?.value?.name ?: "Wemo Switch", "mac": selectedSwitch.value.mac,
"data": [ "ip": selectedSwitch.value.ip,
"mac": selectedSwitch.value.mac, "port": selectedSwitch.value.port
"ip": selectedSwitch.value.ip, ]
"port": selectedSwitch.value.port ])
] def ipvalue = convertHexToIP(selectedSwitch.value.ip)
]) d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
def ipvalue = convertHexToIP(selectedSwitch.value.ip) log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}") } else {
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}" log.debug "found ${d.displayName} with id $dni already exists"
} else { }
log.debug "found ${d.displayName} with id $dni already exists"
} }
} }
} }
@@ -267,23 +266,22 @@ def addMotions() {
d = getChildDevices()?.find { d = getChildDevices()?.find {
it.deviceNetworkId == selectedMotion.value.mac || it.device.getDataValue("mac") == selectedMotion.value.mac it.deviceNetworkId == selectedMotion.value.mac || it.device.getDataValue("mac") == selectedMotion.value.mac
} }
} if (!d) {
log.debug "Creating WeMo Motion with dni: ${selectedMotion.value.mac}"
if (!d) { d = addChildDevice("smartthings", "Wemo Motion", selectedMotion.value.mac, selectedMotion?.value.hub, [
log.debug "Creating WeMo Motion with dni: ${selectedMotion.value.mac}" "label": selectedMotion?.value?.name ?: "Wemo Motion",
d = addChildDevice("smartthings", "Wemo Motion", selectedMotion.value.mac, selectedMotion?.value.hub, [ "data": [
"label": selectedMotion?.value?.name ?: "Wemo Motion", "mac": selectedMotion.value.mac,
"data": [ "ip": selectedMotion.value.ip,
"mac": selectedMotion.value.mac, "port": selectedMotion.value.port
"ip": selectedMotion.value.ip, ]
"port": selectedMotion.value.port ])
] def ipvalue = convertHexToIP(selectedMotion.value.ip)
]) d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
def ipvalue = convertHexToIP(selectedMotion.value.ip) log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}") } else {
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}" log.debug "found ${d.displayName} with id $dni already exists"
} else { }
log.debug "found ${d.displayName} with id $dni already exists"
} }
} }
} }
@@ -298,23 +296,22 @@ def addLightSwitches() {
d = getChildDevices()?.find { d = getChildDevices()?.find {
it.deviceNetworkId == selectedLightSwitch.value.mac || it.device.getDataValue("mac") == selectedLightSwitch.value.mac it.deviceNetworkId == selectedLightSwitch.value.mac || it.device.getDataValue("mac") == selectedLightSwitch.value.mac
} }
} if (!d) {
log.debug "Creating WeMo Light Switch with dni: ${selectedLightSwitch.value.mac}"
if (!d) { d = addChildDevice("smartthings", "Wemo Light Switch", selectedLightSwitch.value.mac, selectedLightSwitch?.value.hub, [
log.debug "Creating WeMo Light Switch with dni: ${selectedLightSwitch.value.mac}" "label": selectedLightSwitch?.value?.name ?: "Wemo Light Switch",
d = addChildDevice("smartthings", "Wemo Light Switch", selectedLightSwitch.value.mac, selectedLightSwitch?.value.hub, [ "data": [
"label": selectedLightSwitch?.value?.name ?: "Wemo Light Switch", "mac": selectedLightSwitch.value.mac,
"data": [ "ip": selectedLightSwitch.value.ip,
"mac": selectedLightSwitch.value.mac, "port": selectedLightSwitch.value.port
"ip": selectedLightSwitch.value.ip, ]
"port": selectedLightSwitch.value.port ])
] def ipvalue = convertHexToIP(selectedLightSwitch.value.ip)
]) d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
def ipvalue = convertHexToIP(selectedLightSwitch.value.ip) log.debug "created ${d.displayName} with id $dni"
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}") } else {
log.debug "created ${d.displayName} with id $dni" log.debug "found ${d.displayName} with id $dni already exists"
} else { }
log.debug "found ${d.displayName} with id $dni already exists"
} }
} }
} }