Skip to content

Commit

Permalink
ICP-13231- removed cause of duplicated events (#32782)
Browse files Browse the repository at this point in the history
* ICP-13231 removed cause of duplicated events

* moved adding child devices to configure function

* Moved creating child events to after adding a child
  • Loading branch information
MWierzbinskaS authored Jun 9, 2020
1 parent 77b1e43 commit 5498246
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,12 @@ def updated() {


def initialize() {
def numberOfButtons = prodNumberOfButtons[zwaveInfo.prod]
sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false)
if(isUntrackedAeotec() || isUntrackedFibaro()) {
sendEvent(name: "DeviceWatch-Enroll", value: JsonOutput.toJson([protocol: "zwave", scheme:"untracked"]), displayed: false)
} else {
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 10 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
}
if(!childDevices) {
addChildButtons(numberOfButtons)
}
if(childDevices) {
def event
for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) {
event = createEvent(name: "button", value: "pushed", isStateChange: true)
sendEventToChild(endpoint, event)
}
}

response([
secure(zwave.batteryV1.batteryGet()),
"delay 2000",
Expand All @@ -97,9 +86,23 @@ def configure() {
//Makes Fibaro KeyFob buttons send all kind of supported events
}
}
setupChildDevices()
cmds
}

def setupChildDevices(){
def numberOfButtons = prodNumberOfButtons[zwaveInfo.prod]
sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false)
if(!childDevices) {
addChildButtons(numberOfButtons)

for(def endpoint : 1..prodNumberOfButtons[zwaveInfo.prod]) {
def event = createEvent(name: "button", value: "pushed", isStateChange: true)
sendEventToChild(endpoint, event)
}
}
}

def parse(String description) {
def result = []
if (description.startsWith("Err")) {
Expand Down Expand Up @@ -137,9 +140,9 @@ def zwaveEvent(physicalgraph.zwave.commands.sceneactivationv1.SceneActivationSet
def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotification cmd) {
def value = eventsMap[(int) cmd.keyAttributes]
def description = "Button no. ${cmd.sceneNumber} was ${value}"
def event = createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true)
sendEventToChild(cmd.sceneNumber, event)
return event
def childEvent = createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true)
sendEventToChild(cmd.sceneNumber, childEvent)
return createEvent(name: "button", value: value, descriptionText: description, data: [buttonNumber: cmd.sceneNumber], isStateChange: true, displayed: false)
}

def sendEventToChild(buttonNumber, event) {
Expand Down

0 comments on commit 5498246

Please sign in to comment.