/* Child Central Scene Switch This was created because the Generic Component device from Hubitat always gets reported to voice control systems as a light instead of a switch NOTICE: This file has been modified by *Jeff Page* from the original work of *Mike Maxwell (Hubitat)*. Copyright 2021-2023 Jeff Page Copyright 2016 -> 2020 Hubitat Inc. All Rights Reserved Changelog: ## [2.0.0] - 2023-12-03 (@jtp10181) - Enabled doubleTapped capability ## [1.0.1] - 2022-07-13 (@jtp10181) ### Changed - Info Text Logging default to true ## [1.0.0] - 2021-04-21 (@jtp10181) - Initial release */ import groovy.transform.Field @Field static final String VERSION = "2.0.0" metadata { definition( //If name is changed must also be changed in parent driver addChildDevice name: "Child Central Scene Switch", namespace: "jtp10181", author: "Jeff Page", importUrl: "https://raw.githubusercontent.com/jtp10181/hubitat/master/Drivers/generic/child-central-scene-switch.groovy", component: true ) { capability "Switch" capability "Refresh" capability "PushableButton" capability "HoldableButton" capability "ReleasableButton" capability "DoubleTapableButton" } preferences { //Logging options similar to other Hubitat drivers input name: "txtEnable", type: "bool", title: "Enable Description Text Logging?", defaultValue: true } } void push(buttonId) { sendBasicButtonEvent(buttonId, "pushed") } void hold(buttonId) { sendBasicButtonEvent(buttonId, "held") } void release(buttonId) { sendBasicButtonEvent(buttonId, "released") } void doubleTap(buttonId) { sendBasicButtonEvent(buttonId, "doubleTapped") } void sendBasicButtonEvent(BigDecimal buttonId, String name) { Map event = [name: name, value: buttonId, type:"digital", isStateChange:true] event.descriptionText="button ${buttonId} ${name}" logTxt "${event.descriptionText} (${event.type})" sendEvent(event) } void updated() { log.info "Updated..." log.warn "Description logging is: ${txtEnable == true}" } void installed() { log.info "Installed..." refresh() } void parse(String description) { log.warn "parse(String) is not implemented" } void parse(List description) { description.each { logTxt "${it.descriptionText}" sendEvent(it) } } void on() { parent?.componentOn(this.device) } void off() { parent?.componentOff(this.device) } void refresh() { parent?.componentRefresh(this.device) } void logTxt(String msg) { if (txtEnable) log.info "${device.displayName}: ${msg}" }