Alexa Skill - on/off command returns error for a switch device with leveling feature

On a "switch" device with on(), off() and setlevel() functions, Alexa skill returns "I am not quite sure what went wrong" for on and off commands.
However setlevel does not produce any errors.

Btw, all commands (including on & off) work fine.
Just the Alexa response for on & off is erroneous.

Here's the on() command and setlevel() function:

void on() {
	logDebug "on()"	
	sendToDevice(zwave.basicV1.basicSet(value: 0xFF))	
	sendOpeningClosingEvent(99)
	runIn(travelDuration, 'sendEvents', [data: [level: 99]]);
}


    private void setLevel(level) {
    	logDebug "setLevel(${level})."
    	if(level >= 99) { level = 99 } 
    	if(level < 0) { level = 0 }
    		sendToDevice(zwave.switchMultilevelV3.switchMultilevelSet(value: level.toInteger(), dimmingDuration: 1))
    	sendOpeningClosingEvent(level)
    	runIn(travelDuration, 'sendEvents', [data: [level: level]]);		
    }

Here is the capabilities of the device:

capability "Actuator"
capability "Switch"
capability "Window Shade"

As you see , the only major difference between on() and setlevel() is the zwave command.
But even if I replace the zwave command in on() with the one in setlevel() , I get the same response from Alexa.

So this is not about the device driver.
There is an issue with the process of the Alexa skill.
What might it be ?

You are not creating a switch event, on needs an event of "switch" "on", and off, "switch" "off"
Also window shade doesn't use level as an attribute...

you mean like this ?
sendEvent(name: "switch", value: "on");

well, I just added this but didn't make a difference.
besides, none of the devices that I find from community have this command under on() , yet they do not result in such awkward Alexa output.

Also window shade doesn't use level as an attribute...

what do you mean by this ? What am I missing ?

WindowShade

Device Selector

capability.windowShade

Driver Definition

capability "WindowShade"

Attributes

position - NUMBER, unit:%

windowShade - ENUM ["opening", "partially open", "closed", "open", "closing", "unknown"]

Commands

close()

open()

setPosition(position)

position required (NUMBER) - Shade position (0 to 100)

startPositionChange(direction)

direction required (ENUM) - Direction for position change request ["open", "close"]

stopPositionChange()

1 Like

ok. so you mean , I should remove the "switch" capability and do everything with open() , close() and setposition()

well, I can do that. if that's the correct way.

btw, this device is not written by me. I downloaded it using Hubitat Package manager.

on() and off() are valid for capability Switch, but setPosition() should be used instead of setLevel() for capbability WindowShade - although some people use both and map one command to the other.

1 Like

I see that the author of this device has used both and mapped the command to setlevel
Anyway, if I remove the "switch" capability and do not use "on" and "off" voice commands, problem goes away.
I still don't understand why on and off produce awkward response from Alexa even when the command result is working on zwave end...

Ok. we can assume the problem with window shades is solved. I will use "open" and "close" commands instead of "on" and "off"

Now I have a similar problem with an Air Purifier device.
it has these capabilities:

capability "Switch"						
capability "SwitchLevel"
		//capability "TemperatureMeasurement"
//capability "RelativeHumidityMeasurement"	
	//	capability "FilterStatus"
	//	capability "FanControl"
		capability "Refresh"

when I use a "set device [level]" voice command , Alexa triggers the "setlevel" command and it works. However, Alexa response is "device is not responding"
What may be the problem here ?

Do you have the Respond Immediately switch turned on?

yes

What does the device type look like from the Alexa app

PNG image

Alexa app shows it as a switch.

I’m temporarily out of ideas on this one. Could try making it look like a fan and see if that helps, but....

I don't understand. Now it is just like a simple switch witl level function. Like a bulb.
Why Alexa skill says "not responding"...

My guess is that it expects a rapid response from a switch, and the device isn’t responding quick enough. Could possibly elimanate the Alexa messsage by exposing a virtual dimmer to Alexa and then use a rule to use the virtual device to control the physical device. Not a great solution, but does eliminate the Alexa response....

ok. but if that's the case , why doesn't the " Respond Immediately switch" solve this ?

also since I have the device driver, I can edit it so that it responds quickly.
how can I make the result of on() or setlevel() command go back to Alexa skill without waiting for a response from device ?

problem solved

I added following to the setLevel() function

sendEvent(name: "level", value: level)

it does say "ok" now.
interesting. So I learned now Alexa skill is waiting for a "level" event for the setLevel command.

2 Likes

Hello, could you please send the entire final driver?
I have a similar problem and would like to make this change

This is my modification to the drive
https://raw.githubusercontent.com/jorgespneto/Hubitat-Jorge/main/Zemi%20Zigbee%20Blind%20Jorge%202%20Modifc

I am using the Somfy ZRTSI driver.
Just added one line of code as I wrote above.

Download the Hubitat app