I am writing a device handler and storing some data in preferences under metadata. However, when I try to read them I just get null returned. I think it is something very simple but not sure. Here is the code I am using and just testing it in the simulator.
I am writing a device handler and storing some data in preferences under metadata. However, when I try to read them I just get null returned. I think it is something very simple but not sure. Here is the code I am using and just testing it in the simulator.
metadata {
definition (name: "Switch", namespace: "harrydn", author: "Harry Dodd-Noble") {
capability "Switch"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
}
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel"
}
}
}
preferences {
input name: "email", type: "email", title: "Email", description: "Enter Email Address", required: true, displayDuringSetup: true
input name: "text", type: "text", title: "Text", description: "Enter Text", required: true
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
// TODO: handle 'switch' attribute
}
// handle commands
def on() {
log.debug "Executing 'on'"
log.debug "email: $email"
log.debug "text: $text"
// TODO: handle 'on' command
}
def off() {
log.debug "Executing 'off'"
// TODO: handle 'off' command
}