diff --git a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy index 1e0c505..8ddc5ce 100644 --- a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy +++ b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy @@ -105,6 +105,8 @@ def parse(String description) { } else { log.warn "TEMP REPORTING CONFIG FAILED- error code: ${descMap.data[0]}" } + } else if (descMap?.clusterInt == zigbee.IAS_ZONE_CLUSTER && descMap.attrInt == zigbee.ATTRIBUTE_IAS_ZONE_STATUS && descMap?.value) { + map = translateZoneStatus(new ZoneStatus(zigbee.convertToInt(descMap?.value))) } } } else if (map.name == "temperature") { @@ -129,6 +131,10 @@ def parse(String description) { private Map parseIasMessage(String description) { ZoneStatus zs = zigbee.parseZoneStatus(description) + translateZoneStatus(zs) +} + +private Map translateZoneStatus(ZoneStatus zs) { return zs.isAlarm1Set() ? getMoistureResult('wet') : getMoistureResult('dry') } @@ -197,7 +203,8 @@ def ping() { def refresh() { log.debug "Refreshing Temperature and Battery" def refreshCmds = zigbee.readAttribute(zigbee.TEMPERATURE_MEASUREMENT_CLUSTER, 0x0000) + - zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + + zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER, zigbee.ATTRIBUTE_IAS_ZONE_STATUS) return refreshCmds + zigbee.enrollResponse() } diff --git a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy index 3109335..336c31e 100644 --- a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy +++ b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy @@ -111,6 +111,8 @@ def parse(String description) { def value = descMap.value.endsWith("01") ? "active" : "inactive" log.debug "Doing a read attr motion event" map = getMotionResult(value) + } else if (descMap?.clusterInt == zigbee.IAS_ZONE_CLUSTER && descMap.attrInt == zigbee.ATTRIBUTE_IAS_ZONE_STATUS && descMap?.value) { + map = translateZoneStatus(new ZoneStatus(zigbee.convertToInt(descMap?.value))) } } } else if (map.name == "temperature") { @@ -135,6 +137,10 @@ def parse(String description) { private Map parseIasMessage(String description) { ZoneStatus zs = zigbee.parseZoneStatus(description) + translateZoneStatus(zs) +} + +private Map translateZoneStatus(ZoneStatus zs) { // Some sensor models that use this DTH use alarm1 and some use alarm2 to signify motion return (zs.isAlarm1Set() || zs.isAlarm2Set()) ? getMotionResult('active') : getMotionResult('inactive') } @@ -200,7 +206,8 @@ def refresh() { log.debug "refresh called" def refreshCmds = zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + - zigbee.readAttribute(zigbee.TEMPERATURE_MEASUREMENT_CLUSTER, 0x0000) + zigbee.readAttribute(zigbee.TEMPERATURE_MEASUREMENT_CLUSTER, 0x0000) + + zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER, zigbee.ATTRIBUTE_IAS_ZONE_STATUS) return refreshCmds + zigbee.enrollResponse() } diff --git a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy index a738427..e6978b8 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -134,8 +134,9 @@ def parse(String description) { } else { log.warn "TEMP REPORTING CONFIG FAILED- error code: ${descMap.data[0]}" } + } else if (descMap?.clusterInt == zigbee.IAS_ZONE_CLUSTER && descMap.attrInt == zigbee.ATTRIBUTE_IAS_ZONE_STATUS && descMap?.value) { + maps += translateZoneStatus(new ZoneStatus(zigbee.convertToInt(descMap?.value))) } else { - maps += handleAcceleration(descMap) } } @@ -229,6 +230,11 @@ private List parseAxis(List attrData) { private List parseIasMessage(String description) { ZoneStatus zs = zigbee.parseZoneStatus(description) + + translateZoneStatus(zs) +} + +private List translateZoneStatus(ZoneStatus zs) { List results = [] if (garageSensor != "Yes") { @@ -313,7 +319,7 @@ def refresh() { def refreshCmds = zigbee.readAttribute(zigbee.TEMPERATURE_MEASUREMENT_CLUSTER, 0x0000) + zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + zigbee.readAttribute(0xFC02, 0x0010, [mfgCode: manufacturerCode]) + - zigbee.enrollResponse() + zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER, zigbee.ATTRIBUTE_IAS_ZONE_STATUS) + zigbee.enrollResponse() return refreshCmds } diff --git a/smartapps/smartthings/button-controller.src/button-controller.groovy b/smartapps/smartthings/button-controller.src/button-controller.groovy index 283a4e3..52e3e79 100644 --- a/smartapps/smartthings/button-controller.src/button-controller.groovy +++ b/smartapps/smartthings/button-controller.src/button-controller.groovy @@ -27,10 +27,9 @@ definition( preferences { page(name: "selectButton") - page(name: "configureButton1") - page(name: "configureButton2") - page(name: "configureButton3") - page(name: "configureButton4") + for (def i=1; i<=8; i++) { + page(name: "configureButton$i") + } page(name: "timeIntervalInput", title: "Only during a certain time") { section { @@ -60,22 +59,45 @@ def selectButton() { } } +def createPage(pageNum) { + if ((state.numButton == pageNum) || (pageNum == 8)) + state.installCondition = true + dynamicPage(name: "configureButton$pageNum", title: "Set up button $pageNum here", + nextPage: "configureButton${pageNum+1}", install: state.installCondition, uninstall: configured(), getButtonSections(pageNum)) +} + def configureButton1() { - dynamicPage(name: "configureButton1", title: "Now let's decide how to use the first button", - nextPage: "configureButton2", uninstall: configured(), getButtonSections(1)) + state.numButton = buttonDevice.currentState("numberOfButtons")?.longValue ?: 4 + log.debug "state variable numButton: ${state.numButton}" + state.installCondition = false + createPage(1) } def configureButton2() { - dynamicPage(name: "configureButton2", title: "If you have a second button, set it up here", - nextPage: "configureButton3", uninstall: configured(), getButtonSections(2)) + createPage(2) } def configureButton3() { - dynamicPage(name: "configureButton3", title: "If you have a third button, you can do even more here", - nextPage: "configureButton4", uninstall: configured(), getButtonSections(3)) + createPage(3) } + def configureButton4() { - dynamicPage(name: "configureButton4", title: "If you have a fourth button, you rule, and can set it up here", - install: true, uninstall: true, getButtonSections(4)) + createPage(4) +} + +def configureButton5() { + createPage(5) +} + +def configureButton6() { + createPage(6) +} + +def configureButton7() { + createPage(7) +} + +def configureButton8() { + createPage(8) } def getButtonSections(buttonNumber) {