In the driver I'm learning from (ported ST dimmer switch) there is a function I can't quite grasp.
I understand the "def installed()" is called when a device is discovered and installed.
I believe the sendEvent( name: ...........) is trying to create an event (that will run in the executive program) to generate a periodic action that will ping the installed device.
I don't understand:
-
How the driver can use "sendEvent" instead of "createEvent" unless "sendEvent" defaults to "create" if there sent event does not exist.
-
The function of the last line "response(commands)"
Any help will be appreciated.
Thanks
John
def installed() {
// Device-Watch simply pings if no device events received for 32 min(checkInterval)
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
def commands = refresh()
if (zwaveInfo?.mfr?.equals("001A")) {
commands << "delay 100"
//for Eaton dimmers parameter 7 is ramp time. We set it to 1s for devices to work correctly with local execution
commands << zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 7, size: 1).format()
} // deleted: else if (isHoneywellDimmer())
response(commands)
}