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 customBeep function for use as a custom action #103

Open
wants to merge 1 commit 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
16 changes: 15 additions & 1 deletion hubitat/drivers/konnected-beep-blink.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ metadata {
capability "Actuator"
capability "Momentary"
capability "Tone"

command "customBeep", [
[name: "Duration*", type: "NUMBER", range: "10..*", description: "Each beep or blink duration"],
[name: "Pause*", type: "NUMBER", range: "10..*", description: "Pause between beeps/blinks in milliseconds"],
[name: "Repeat*", type: "NUMBER", range: "1..*", description: "Times to repeat the pulse"]
]
}

preferences {
Expand Down Expand Up @@ -71,6 +77,14 @@ def push() {
beep()
}

def customBeep(BigDecimal duration, BigDecimal pause, BigDecimal repeat) {
parent.deviceUpdateDeviceState(device.deviceNetworkId, triggerLevel(), [
momentary : duration ?: 250,
pause : pause ?: 150,
times : repeat ?: 3
])
}

def beep() {
parent.deviceUpdateDeviceState(device.deviceNetworkId, triggerLevel(), [
momentary : beepDuration ?: 250,
Expand All @@ -97,4 +111,4 @@ def triggerLevel() {

def currentBinaryValue() {
invertTrigger ? 1 : 0
}
}