I apologize in advance for probably asking stupid questions. I'm an experienced OS developer but this is my first foray into Groovy and Hubitat drivers.
I'm trying to create a simple virtual driver for a Notification Device. The goal is to get text notifications to go out the Maker-API and eventually into Node-Red for further processing.
Thanks to @bertabcd1234 for pointing me in the right direction to get started, I have the following skeleton driver:
metadata {
definition (name: "Virtual Notification Device", namespace: "BKJ", author: "Bruce Jones") {
capability "Notification"
}
preferences {
input(name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true)
input(name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true)
}
}
void installed() {
log.debug "installed()"
initialize()
}
void updated() {
log.debug "updated()"
initialize()
}
void initialize() {
log.debug "initialize()"
Integer disableTime = 1800
if (logEnable) {
log.debug "Debug logging will be automatically disabled in ${disableTime} seconds"
runIn(disableTime, "debugOff")
}
}
void debugOff() {
log.warn "Disabling debug logging"
device.updateSetting("logEnable", [value:"false", type:"bool"])
}
void deviceNotification(notificationText) {
if (logEnable) log.debug "deviceNotification(notificationText = ${notificationText})"
sendEvent(name: "deviceNotification", value: notificationText, isStateChange: true)
}
But when I include a virtual device using this driver as a device exposed by the Maker API, Maker API doesn't see any events from this device.
What needs to be done in a driver for the Maker API to process the device's events? sendEvent() alone doesn't seem to be enough.