/**
* Candeo C-ZB-SR5BR Smart Scene Remote
* Reports button 1 - 4 pushed, double tapped, held & released events for buttons 1 - 4
* Reports button 5 pushed, double tapped, held & released events for center button
* Reports button 6 held events for starting & continuing clockwise rotation of the ring
* Reports button 6 released events for stopping clockwise rotation of the ring
* Reports button 7 held events for starting & continuing counter-clockwise rotation of the ring
* Reports button 7 released events for stopping counter-clockwise rotation of the ring
* Reports Battery Events
* Has Setting For Battery Reporting
*/
metadata {
definition(name: 'Candeo C-ZB-SR5BR Smart Scene Remote', namespace: 'Candeo', author: 'Candeo', importUrl: 'https://raw.githubusercontent.com/candeosmart/hubitat-zigbee/ea628d2e0590d782a611671c30b054feb8857be3/Candeo%20C-ZB-SR5BR%20Smart%20Scene%20Remote.groovy', singleThreaded: true) {
capability 'PushableButton'
capability 'DoubleTapableButton'
capability 'ReleasableButton'
capability 'HoldableButton'
capability 'Battery'
capability 'Sensor'
capability 'Configuration'
fingerprint profileId: '0104', endpointId: '01', inClusters: '0000,0001,0003,0B05,1000', outClusters: '0003,0004,0005,0006,0008,0019,1000', manufacturer: 'Candeo', model: 'C-ZB-SR5BR', deviceJoinName: 'Candeo C-ZB-SR5BR Smart Scene Remote'
}
preferences {
input name: 'deviceDriverOptions', type: 'hidden', title: 'Device Driver Options', description: 'The following options change the behaviour of the device driver, they take effect after hitting "Save Preferences below."'
input name: 'loggingOption', type: 'enum', title: 'Logging Option', description: 'Sets the logging level cumulatively, for example "Driver Trace Logging" will include all logging levels below it.
', options: PREFLOGGING, defaultValue: '5'
input name: 'deviceConfigurationOptions', type: 'hidden', title: 'Device Configuration Options', description: 'The following options change the behaviour of the device itself, they take effect after hitting "Save Preferences below", followed by "Configure" above.
For a battery powered device, you may also need to wake it up manually!'
input name: 'batteryPercentageReportTime', type: 'enum', title: 'Battery Percentage Time (hours)', description: 'Adjust the period that the battery percentage is reported to suit your requirements.
', options: PREFBATTERYREPORTTIME, defaultValue: '28800'
input name: 'platformOptions', type: 'hidden', title: 'Platform Options', description: 'The following options are relevant to the Hubitat platform and UI itself.'
}
}
import groovy.transform.Field
private @Field final String CANDEO = 'Candeo C-ZB-SR5BR Device Driver'
private @Field final Boolean DEBUG = false
private @Field final Integer LOGSOFF = 1800
private @Field final Integer ZIGBEEDELAY = 1000
private @Field final Map PREFFALSE = [value: 'false', type: 'bool']
private @Field final Map PREFTRUE = [value: 'true', type: 'bool']
private @Field final Map PREFBATTERYREPORTTIME = ['3600': '1h', '5400': '1.5h', '7200': '2h', '10800': '3h', '21600': '6h', '28800': '8h', '43200': '12h', '64800': '18h']
private @Field final Map PREFLOGGING = ['0': 'Device Event Logging', '1': 'Driver Informational Logging', '2': 'Driver Warning Logging', '3': 'Driver Error Logging', '4': 'Driver Debug Logging', '5': 'Driver Trace Logging' ]
void installed() {
logsOn()
logTrace('installed called')
device.updateSetting('batteryPercentageReportTime', [value: '28800', type: 'enum'])
logInfo("batteryPercentageReportTime setting is: ${PREFBATTERYREPORTTIME[batteryPercentageReportTime]}")
logInfo('logging level is: Driver Trace Logging')
logInfo("logging level will reduce to Driver Error Logging after ${LOGSOFF} seconds")
sendEvent(processEvent(name: 'numberOfButtons', value: 7, displayed: false))
for (Integer buttonNumber : 1..7) {
sendEvent(buttonAction('held', buttonNumber, 'digital'))
}
}
void uninstalled() {
logTrace('uninstalled called')
clearAll()
}
void updated() {
logTrace('updated called')
logTrace("settings: ${settings}")
logInfo("batteryPercentageReportTime setting is: ${PREFBATTERYREPORTTIME[batteryPercentageReportTime ?: '28800']}", true)
logInfo("logging level is: ${PREFLOGGING[loggingOption]}", true)
clearAll()
if (logMatch('debug')) {
logInfo("logging level will reduce to Driver Error Logging after ${LOGSOFF} seconds", true)
runIn(LOGSOFF, logsOff)
}
logInfo('if you have changed any Device Configuration Options, make sure that you hit Configure above!', true)
}
void logsOff() {
logTrace('logsOff called')
if (DEBUG) {
logDebug('DEBUG field variable is set, not disabling logging automatically!', true)
}
else {
logInfo('automatically reducing logging level to Driver Error Logging', true)
device.updateSetting('loggingOption', [value: '3', type: 'enum'])
}
}
List configure() {
logTrace('configure called')
logDebug('battery powered device requires manual wakeup to accept configuration commands')
logDebug("battery percentage time is: ${batteryPercentageReportTime ?: '28800'}")
Integer batteryTime = batteryPercentageReportTime ? batteryPercentageReportTime.toInteger() : 28800
List cmds = [
"zdo bind 0x${device.deviceNetworkId} 0x${device.endpointId} 0x01 0x0001 {${device.zigbeeId}} {}", "delay ${ZIGBEEDELAY}",
"he cr 0x${device.deviceNetworkId} 0x${device.endpointId} 0x0001 0x0021 ${DataType.UINT8} 3600 ${batteryTime} {${intTo16bitUnsignedHex(2)}}", "delay ${ZIGBEEDELAY}",
"he raw 0x${device.deviceNetworkId} 0x01 0x${device.endpointId} 0x0001 {10 00 08 00 2100}", "delay ${ZIGBEEDELAY}",
"he rattr 0x${device.deviceNetworkId} 0x${device.endpointId} 0x0001 0x0021 {}"
]
logDebug("sending ${cmds}")
return cmds
}
void push(BigDecimal button) {
logTrace('push called')
buttonCommand('pushed', button.intValue())
}
void doubleTap(BigDecimal button) {
logTrace('doubleTap called')
buttonCommand('doubleTapped', button.intValue())
}
void hold(BigDecimal button) {
logTrace('hold called')
buttonCommand('held', button.intValue())
}
void release(BigDecimal button) {
logTrace('release called')
buttonCommand('released', button.intValue())
}
List