Need help from a dth guru.
I have a device handler that I am trying to get working.
You can set alarm time from the device in the settings and webcore will read it as one of the attributes. However I would like to be able to set the alarm time from webcore and the dth change the alarm time in the device. I just can’t figure out how to pass information to the dth and have the dth apply what it gets.
I know I would need the use of a custom command and a custom parameter. But not sure how to handle that info.
Here is what I am working with so far
/**
-
This is copied directly from the Z-wave switch with power metering from SmartThings, i added a Image Capture
-
capability just to be able to send a string to webcore, the string is the departure time which represent
-
when you are leaving your home so the switch turns on a couple of hours before if you have plugged in
-
your engine heater cable. All rules are set in webcore though. This just provides an easy way of setting
-
a departure time.
*/metadata { definition (name: "Alarm On/Off Button Tile", namespace: "Alarm", author: "adapted from 949BFN") { capability "Actuator" capability "Switch" capability "Sensor" capability "Image Capture" attribute "alarm","string" command "changeAlarmTime" } preferences { input name: "timer", type: "time", title: "Alarm Time", description: "Enter Time", required: false } // simulator metadata simulator { } // UI tile definitions tiles { standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) { state "off", label: 'OFF', action: "switch.off", icon: "st.Health & Wellness.health7", backgroundColor: "#ffffff",nextState:"on" state "on", label: 'On', action: "switch.off", icon: "st.Health & Wellness.health7", backgroundColor: "#00A0DC",nextState:"off" } valueTile("alarm", "device.alarm") { state "default", label:'Alarm: ${currentValue}',backgroundColor: "#00A0DC" } main(["button","alarm"]) details(["button","alarm"]) } } def parse() { } def updated() { def time = timer.substring(11,16) def tz = location.timeZone def schedTime = timeToday(timer, tz) //def ntime = schedTime.format("H",tz) //def min = schedTime.format("m",tz) //def newtime = schedTime.format('HH:mm:ss', tz).toString() if(timer) { log.debug "Alarm time set to: $timer" sendEvent("name":"image", "value":schedTime) sendEvent("name":"alarm", "value":time) } else { log.debug "No departure time is set" } } def on(){ sendEvent(name:"switch",value:"on") } def off(){ sendEvent(name:"switch",value:"off") }