Try this:
metadata {
definition (name: "Fan Setpoints", namespace: "RobinWinbourne", author: "RobinWinbourne", vid: "generic-switch") {
capability "Switch"
capability "Actuator"
attribute "upperSetpointLevel", "string"
attribute "lowerSetpointLevel", "string"
command "setUpperSetpoint"
command "setLowerSetpoint"
}
tiles(scale: 2) {
standardTile("Title1", "device.Title1", inactiveLabel: false, width: 3, height: 1, decoration: "flat", wordWrap: false) {
state "default", label:'Lower Setpoint'
}
standardTile("Title2", "device.Title2", inactiveLabel: false, width: 3, height: 1, decoration: "flat", wordWrap: false) {
state "default", label:'Upper Setpoint'
}
standardTile("switch", "device.switch", inactiveLabel: false, width: 6, height: 3, decoration: "flat", canChangeIcon: false) {
state "off", label: '${name}', action: "switch.on", icon: "https://cdn.rawgit.com/RobinWinbourne/devicetypes/master/fan3.png", backgroundColor: "#ffffff", nextState:"turningOn"
state "on", label: '${name}', action: "switch.off", icon: "https://cdn.rawgit.com/RobinWinbourne/devicetypes/master/fan3.png", backgroundColor: "#ff9900", nextState:"turningOff"
state "turningOn", label:'${name}', action:"switch.off", icon:"https://cdn.rawgit.com/RobinWinbourne/devicetypes/master/fan3.png", backgroundColor:"#ff9900", nextState:"turningOff"
state "turningOff", label:'${name}', action:"switch.on", icon:"https://cdn.rawgit.com/RobinWinbourne/devicetypes/master/fan3.png", backgroundColor:"#ffffff", nextState:"turningOn"
}
controlTile("lowerSetpointLevel", "device.lowerSetpointLevel", "slider", height: 2, width: 3, range: "(0..100)", inactiveLabel: false) {
state "default", action:"setLowerSetpoint", backgroundColor:"#AF1586"
}
controlTile("upperSetpointLevel", "device.upperSetpointLevel", "slider", height: 2, width: 3, range: "(0..100)", inactiveLabel: false) {
state "default", action:"setUpperSetpoint", backgroundColor:"#AF1586"
}
main(["switch"])
details(["switch","Title1","Title2","lowerSetpointLevel","upperSetpointLevel"])
}
}
def installed() {
log.debug "installed()"
configure()
}
def updated() {
log.debug "updated()"
}
def on() {
sendEvent(name: "switch", value: "on", isStateChange: true, displayed: false)
}
def off() {
sendEvent(name: "switch", value: "off", isStateChange: true, displayed: false)
}
def setLowerSetpoint(value) {
log.trace "Setting Lower Setpoint to $value"
Map levelEventMap = buildSetLevelEvent(value)
sendEvent(levelEventMap)
}
def setUpperSetpoint(value) {
log.trace "Setting Upper Setpoint to $value"
Map levelEventMap = buildSetLevelEvent2(value)
sendEvent(levelEventMap)
}
private Map buildSetLevelEvent(value) {
def intValue = value as Integer
def newLevel = Math.max(Math.min(intValue, 100), 0)
Map eventMap = [name: "lowerSetpointLevel", value: newLevel]
return eventMap
}
private Map buildSetLevelEvent2(value) {
def intValue = value as Integer
def newLevel = Math.max(Math.min(intValue, 100), 0)
Map eventMap = [name: "upperSetpointLevel", value: newLevel]
return eventMap
}