Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added toggle logging to some of the drivers #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
23 changes: 11 additions & 12 deletions drivers/konnected-co-sensor.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Konnected CO Sensor
* Konnected Contact Sensor
*
* Copyright 2018 Konnected Inc (https://konnected.io)
*
Expand All @@ -14,33 +14,32 @@
*
*/
metadata {
definition (name: "Konnected CO Sensor", namespace: "konnected-io", author: "konnected.io", mnmn: "SmartThings", vid: "generic-carbon-monoxide") {
capability "Smoke Detector"
capability "Carbon Monoxide Detector"
definition (name: "Konnected Contact Sensor", namespace: "konnected-io", author: "konnected.io", mnmn: "SmartThings", vid: "generic-contact") {
capability "Contact Sensor"
capability "Sensor"
}

preferences {
input name: "normalState", type: "enum", title: "Normal State",
options: ["Normally Closed", "Normally Open"],
defaultValue: "Normally Closed",
description: "By default, the alarm state is triggered when the sensor circuit is open (NC). Select Normally Open (NO) when a closed circuit indicates an alarm."
options: ["Normally Closed", "Normally Open"],
defaultValue: "Normally Open",
description: "Most door & window sensors are Normally Open (NO), meaning that the circuit closes when the door/window is closed. To reverse this logic, select Normally Closed (NC)."
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
}

}

def isClosed() {
normalState == "Normally Open" ? "detected" : "clear"
normalState == "Normally Closed" ? "open" : "closed"
}

def isOpen() {
normalState == "Normally Open" ? "clear" : "detected"
normalState == "Normally Closed" ? "closed" : "open"
}

// Update state sent from parent app
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "carbonMonoxide", value: stateValue)
log.info "$device.label is $stateValue"
sendEvent(name: "contact", value: stateValue)
if (txtEnable) log.info "$device.label is $stateValue"
}

4 changes: 3 additions & 1 deletion drivers/konnected-motion-sensor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ metadata {
options: ["Normally Closed", "Normally Open"],
defaultValue: "Normally Closed",
description: "Most motion sensors are Normally Closed (NC), meaning that the circuit opens when motion is detected. To reverse this logic, select Normally Open (NO)."
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true

}

}
Expand All @@ -40,5 +42,5 @@ def isOpen() {
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "motion", value: stateValue)
log.info "$device.label is $stateValue"
if (txtEnable) log.info "$device.label is $stateValue"
}
3 changes: 2 additions & 1 deletion drivers/konnected-panic-button.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ metadata {
options: ["Normally Closed", "Normally Open"],
defaultValue: "Normally Closed",
description: "By default, the alarm state is triggered when the sensor circuit is open (NC). Select Normally Open (NO) when a closed circuit indicates an alarm."
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
}

}
Expand All @@ -40,5 +41,5 @@ def isOpen() {
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "contact", value: stateValue)
log.info "$device.label is $stateValue"
if (txtEnable) log.info "$device.label is $stateValue"
}
5 changes: 4 additions & 1 deletion drivers/konnected-temperature-probe-ds18b20.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ metadata {
definition (name: "Konnected Temperature Probe (DS18B20)", namespace: "konnected-io", author: "konnected.io", mnmn: "SmartThings", vid: "generic-humidity") {
capability "Temperature Measurement"
}
preferences {
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
}

}

Expand All @@ -32,5 +35,5 @@ def updateStates(states) {
temperature = temperature * 9 / 5 + 32
}
sendEvent(name: "temperature", value: temperature.setScale(1, BigDecimal.ROUND_HALF_UP), unit: location.getTemperatureScale())
log.info "Temperature: $temperature"
if (txtEnable) log.info "Temperature: $temperature"
}