I’ve been doing a lot of work with the REST API and trying to get some URLs setup so that I can use them in Tasker. I am now at a point though that my Z-Wave dimmer switch will not change its level until it is turned off then back on. So my update level function looks like this:
private void updateLvl(devices) {
log.debug "update, request: params: ${params}, devices: $devices.id, levl: ${params.param4}"
//def command = request.JSON?.command
def command = params.command
def lvel = params.lvl
log.debug "level: ${params.lvl}"
//let's create a toggle option here
if (command)
{
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
if(command == "toggle")
{
if(device.currentValue('switch') == "on"){
device.setLevel(lvel)
device.off()
}
else{
device.setLevel(lvel)
device.off()
device.on();
}
}
else
{
device.setLevel(lvel)
device.off()
device."$command"()
}
}
}
}
Special thanks to @NickW for the hint about doing this and @korban_hadley for the idea! And of course, thanks to @csader for the tasker>ST tutorial that @Ben reposted.
After I get this working, I will be publishing an extended version of the original SmartApp and PHP file that will hopefully help some of those that needed info like myself. SmartApp REST API for Tasker(I was wanting to get Tasker to grab the current status of stuff and interact with it based on other criteria, like leaving a geoFence around the end of my work shift, popping up and asking me if I’m headed home. If so, send a remote command to tasker on my HA tablet then do things like set the Nest thermostat. Once I scan the NFC badge in my car as I enter my subdivision, my garage will open, the garage door will unlock and if it’s near or after dark, the side lights will come on. Once it detects that I’ve entered into my house, it’ll ask if I want to watch today’s news and will turn the TV on and change to the channel if I reply yes.) Anyways, dreams to be… I want this dang dimmer to work first. Any help is appreciated!