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 Option to Enable/Disable Driver Logging #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 18 additions & 2 deletions drivers/konnected-contact-sensor.groovy
Original file line number Diff line number Diff line change
@@ -20,14 +20,29 @@ metadata {
}

preferences {
input name: "normalState", type: "enum", title: "Normal State",
input (
name: "normalState", type: "enum", title: "Normal State",
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 (
type: "bool",
name: "txtEnable",
title: "Enable descriptionText logging",
required: false,
defaultValue: false
)
}

}

def logInfo(msg) {
if (txtEnable) {
log.info msg
}
}

def isClosed() {
normalState == "Normally Closed" ? "open" : "closed"
}
@@ -40,5 +55,6 @@ def isOpen() {
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "contact", value: stateValue)
log.info "$device.label is $stateValue"
def descriptionText = "$device.label is $stateValue"
logInfo descriptionText
}
22 changes: 19 additions & 3 deletions drivers/konnected-siren-strobe.groovy
Original file line number Diff line number Diff line change
@@ -21,12 +21,27 @@ metadata {
}

preferences {
input name: "invertTrigger", type: "bool", title: "Low Level Trigger",
description: "Select if the attached relay uses a low-level trigger. Default is high-level trigger"
input (
name: "invertTrigger", type: "bool", title: "Low Level Trigger",
description: "Select if the attached relay uses a low-level trigger. Default is high-level trigger"
)
input (
type: "bool",
name: "txtEnable",
title: "Enable descriptionText logging",
required: false,
defaultValue: false
)
}

}

def logInfo(msg) {
if (txtEnable) {
log.info msg
}
}

def updated() {
parent.updateSettingsOnDevice()
}
@@ -38,7 +53,8 @@ def updatePinState(Integer state) {
} else {
val = invertTrigger ? "off" : "on"
}
log.info "$device is $val"
def descriptionText = "$device is $val"
logInfo descriptionText
sendEvent(name: "switch", value: val, displayed: false)
if (val == "on") { val = "both" }
sendEvent(name: "alarm", value: val)
26 changes: 21 additions & 5 deletions drivers/konnected-smoke-sensor.groovy
Original file line number Diff line number Diff line change
@@ -20,14 +20,29 @@ metadata {
}

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."
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."
)
input (
type: "bool",
name: "txtEnable",
title: "Enable descriptionText logging",
required: false,
defaultValue: false
)
}

}

def logInfo(msg) {
if (txtEnable) {
log.info msg
}
}

def isClosed() {
normalState == "Normally Open" ? "detected" : "clear"
}
@@ -40,5 +55,6 @@ def isOpen() {
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "smoke", value: stateValue)
log.info "$device.label is $stateValue"
def descriptionText = "$device.label is $stateValue"
logInfo descriptionText
}
42 changes: 30 additions & 12 deletions drivers/konnected-switch.groovy
Original file line number Diff line number Diff line change
@@ -20,13 +20,36 @@ metadata {
}

preferences {
input name: "invertTrigger", type: "bool", title: "Low Level Trigger",
description: "Select if the attached relay uses a low-level trigger. Default is high-level trigger"
input name: "debugOutput", type: "bool", title: "Enable debug logging?", defaultValue: false
input (
name: "invertTrigger", type: "bool", title: "Low Level Trigger",
description: "Select if the attached relay uses a low-level trigger. Default is high-level trigger"
)
input (
name: "debugOutput", type: "bool", title: "Enable debug logging?", defaultValue: false
)
input (
type: "bool",
name: "txtEnable",
title: "Enable descriptionText logging",
required: false,
defaultValue: false
)
}

}

def logInfo(msg) {
if (txtEnable) {
log.info msg
}
}

private logDebug(msg) {
if (settings?.debugOutput || settings?.debugOutput == null) {
log.debug "$msg"
}
}

def updated() {
parent.updateSettingsOnDevice()
}
@@ -44,13 +67,15 @@ def updatePinState(Integer state) {

def off() {
def val = invertTrigger ? 1 : 0
logDebug "Turning off $device.label (state = $val)"
def descriptionText = "Turning off $device.label (state = $val)"
logInfo descriptionText
parent.deviceUpdateDeviceState(device.deviceNetworkId, val)
}

def on() {
def val = invertTrigger ? 0 : 1
logDebug "Turning on $device.label (state = $val)"
def descriptionText = "Turning on $device.label (state = $val)"
logInfo descriptionText
parent.deviceUpdateDeviceState(device.deviceNetworkId, val)
}

@@ -70,10 +95,3 @@ def logsOff(){
log.warn "debug logging disabled..."
device.updateSetting("debugOutput",[value:"false",type:"bool"])
}

private logDebug(msg) {
if (settings?.debugOutput || settings?.debugOutput == null) {
log.debug "$msg"
}
}

21 changes: 18 additions & 3 deletions drivers/konnected-temperature-humidity-sensor-dht.groovy
Original file line number Diff line number Diff line change
@@ -21,13 +21,28 @@ metadata {
}

preferences {
input name: "pollInterval", type: "number", title: "Polling Interval (minutes)",
input (
name: "pollInterval", type: "number", title: "Polling Interval (minutes)",
defaultValue: defaultPollInterval(),
description: "Frequency of sensor updates"
)
input (
type: "bool",
name: "txtEnable",
title: "Enable descriptionText logging",
required: false,
defaultValue: false
)
}

}

def logInfo(msg) {
if (txtEnable) {
log.info msg
}
}

def updated() {
parent.updateSettingsOnDevice()
}
@@ -45,8 +60,8 @@ def updateStates(states) {
humidity = new BigDecimal(states.humi)
sendEvent(name: "humidity", value: humidity.setScale(0, BigDecimal.ROUND_HALF_UP), unit: '%')
}

log.info "Temperature: $temperature, Humidity: $humidity"
def descriptionText = "Temperature: $temperature, Humidity: $humidity"
logInfo descriptionText
}

def pollInterval() {