Trying to write my own handler for a Z-Wave Immersion heater controller. The unit uses normal Binary Switching but has an option to set a timer for x number of minutes up to 1440 using the Schedule (0x53) Class.
I am struggling for some reason to get my head round creating a tile to display the current schedule. Maybe I should start with sending a schedule but I assume once on there has to be a schedule able to be recalled.
I created a zwaveevent to use the commandschedulereport to display a value. I have no ide what it is returning and I can’t get debugging working or the simulator to help work the issue out.
Any help would be appreciated. the code I have so far is below.
metadata {
definition (name: “Secure SIR321”, namespace: “smartthings”, author: “Antony Pugh”) {
capability “Actuator”
capability “Switch”
capability “Polling”
capability “Refresh”
capability “Sensor”
fingerprint deviceId:"0x1000", inClusters: "0x72 0x86 0x25 0x20 0x85 0x53 0x70"
}
// simulator metadata
simulator {
status “on”: “command: 2003, payload: FF”
status “off”: “command: 2003, payload: 00”
// reply messages reply "2001FF,delay 100,2502": "command: 2503, payload: FF" reply "200100,delay 100,2502": "command: 2503, payload: 00"
}
// tile definitions
tiles(scale: 2) {
multiAttributeTile(name:“switch”, type: “Immersion”, width: 6, height: 4, canChangeIcon: true){
tileAttribute (“device.switch”, key: “PRIMARY_CONTROL”) {
attributeState “on”, label: ‘Heating’, action: “switch.off”, icon: “st.switches.switch.on”, backgroundColor: “#79b821”
attributeState “off”, label: ‘${name}’, action: “switch.on”, icon: “st.switches.switch.off”, backgroundColor: “#ffffff”
}
}valueTile("timer", "device.timer", width: 2, height: 2) { state "timer", label:'${currentValue}°',unit:"" }
standardTile("refresh", "device.switch", width: 2, height: 2, inactiveLabel: false, decoration: "flat") { state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh" }
main "switch" details(["switch","refresh","timer"])
}
}
//def parse(String description) {
// def result = null
// def cmd = zwave.parse(description, [0x20: 1, 0x70: 1, 0x53: 1])
// if (cmd) {
// result = createEvent(zwaveEvent(cmd))
// log.debug “Parsed ${cmd} to ${result.inspect()}”
// }
// if (result?.name == ‘hail’ && hubFirmwareLessThan(“000.011.00602”)) {
// result = [result, response(zwave.basicV1.basicGet())]
// log.debug “Was hailed: requesting state update”
// } else {
// log.debug “Parse returned ${result?.descriptionText}”
// }
// return result
//}
def parse(String description) {
def result = null
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1, 0x53: 1])
if (cmd) {
result = zwaveEvent(cmd)
log.debug “Parsed ${cmd} to ${result.inspect()}”
} else {
log.debug “Non-parsed event: ${description}”
}
return result
}
def zwaveEvent(physicalgraph.zwave.commands.schedulev1.CommandScheduleReport cmd) {
createEvent(name: “timer”, value = cmd.durationByte ? unit:“mins”)
log.debug “Parsed ${cmd} to ${result.inspect()}”
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
[name: “switch”, value: cmd.value ? “on” : “off”, type: “physical”]
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
[name: “switch”, value: cmd.value ? “on” : “off”, type: “digital”]
}
def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
[name: “hail”, value: “hail”, descriptionText: “Switch button was pressed”, displayed: false]
}
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
if (state.manufacturer != cmd.manufacturerName) {
updateDataValue(“manufacturer”, cmd.manufacturerName)
}
}
def zwaveEvent(physicalgraph.zwave.Command cmd) {
// Handles all Z-Wave commands we aren’t interested in
[:]
}
def on() {
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
])
}
def off() {
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
])
}
def poll() {
delayBetween([
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
])
}
def refresh() {
delayBetween([
zwave.switchBinaryV1.switchBinaryGet().format(),
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
])
}