Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,20 @@ metadata {
}

def installed() {
createChildDevices()
updateDataValue("onOff", "catchall")
refresh()
createChildDevices()
updateDataValue("onOff", "catchall")
refresh()
}

def updated() {
log.debug "updated()"
updateDataValue("onOff", "catchall")
refresh()
log.debug "updated()"
updateDataValue("onOff", "catchall")
for (child in childDevices) {
if (!child.deviceNetworkId.startsWith(device.deviceNetworkId)) { //parent DNI has changed after rejoin
child.setDeviceNetworkId("${device.deviceNetworkId}:${getChildEndpoint(child.deviceNetworkId)}")
}
}
refresh()
}

def parse(String description) {
Expand Down Expand Up @@ -120,7 +125,7 @@ def parse(String description) {
private void createChildDevices() {
def x = getChildCount()
for (i in 2..x) {
addChildDevice("Child Switch Health", "${device.deviceNetworkId}:0${i}", device.hubId,
addChildDevice("Child Switch Health", "${device.deviceNetworkId}:${i}", device.hubId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the leading 0 was here because the endpoint is hex and so we wanted it to be fixed length, similar to how the DNI is hex and includes leading 0s. I'd leave it as is unless there is a strong reason to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's hex, the function that was parsing it back was treating it as decimal so there wasn't any consistency there so I did this for consistency's sake

[completedSetup: true, label: "${device.displayName[0..-2]}${i}", isComponent: false])
}
}
Expand Down Expand Up @@ -162,12 +167,12 @@ def refresh() {
if (isOrvibo()) {
zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: 0xFF])
} else {
def cmds = zigbee.onOffRefresh()
def x = getChildCount()
for (i in 2..x) {
cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i])
}
return cmds
def cmds = zigbee.onOffRefresh()
def x = getChildCount()
for (i in 2..x) {
cmds += zigbee.readAttribute(zigbee.ONOFF_CLUSTER, 0x0000, [destEndpoint: i])
}
return cmds
}
}

Expand Down Expand Up @@ -204,17 +209,17 @@ def configure() {
if (isOrvibo()) {
//the orvibo switch will send out device anounce message at ervery 2 mins as heart beat,setting 0x0099 to 1 will disable it.
def cmds = zigbee.writeAttribute(zigbee.BASIC_CLUSTER, 0x0099, 0x20, 0x01, [mfgCode: 0x0000])
cmds += refresh()
return cmds
cmds += refresh()
return cmds
} else {
//other devices supported by this DTH in the future
def cmds = zigbee.onOffConfig(0, 120)
def x = getChildCount()
for (i in 2..x) {
cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i])
}
cmds += refresh()
return cmds
def cmds = zigbee.onOffConfig(0, 120)
def x = getChildCount()
for (i in 2..x) {
cmds += zigbee.configureReporting(zigbee.ONOFF_CLUSTER, 0x0000, 0x10, 0, 120, null, [destEndpoint: i])
}
cmds += refresh()
return cmds
}
}

Expand Down