Command Class SwitchMultiLevel Help

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
Leaving Hope
Posts: 4
Joined: 28 Apr 2014 08:17

Command Class SwitchMultiLevel Help

Post by Leaving Hope »

I'm having a bit of trouble with the SwitchMultiLevel command class and would appreciate some help. I'm using a GE Lamp Module and a GE/Jasco in-wall dimmer switch, and in both cases I find that the level is not accurately set in data.level after being Set unless I issue the Set command twice.

For example, if I run the following:

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].Set(50)
At this point, the light does turn on from 0% to 50%. The room goes from dark to partially illuminated.

I then check the level of the device, expecting it to be 50:

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].data.level

{"name":"level","type":"int","value":4,"updateTime":1398662459,"invalidateTime":1398662458}
I then run the Set command a second time.

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].Set(50)
And then check the value. This time, it's correct.

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].data.level

{"name":"level","type":"int","value":50,"updateTime":1398662558,"invalidateTime":1398662557}
I can reproduce this time and time again. It always takes two issues of the Set command before I can get the value. Any advice?
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Command Class SwitchMultiLevel Help

Post by pofs »

You're not passing duration to Set() call, so it uses some device-specific factory value. My guess is, the moment you're checking the value for the first time device is still in transition and hasn't yet reported the final level value.
Try calling, for example, .Set(50, 0) to set value instantly, or .Set(50, 1) to set it during one second, and then check data.level.

If the problem still exists, please provide some logs.
Leaving Hope
Posts: 4
Joined: 28 Apr 2014 08:17

Re: Command Class SwitchMultiLevel Help

Post by Leaving Hope »

I thought that might be an issue, and have tried setting the second Set duration parameter to 0 and also waiting up to a minute before checking data.level. Unfortunately, neither work.

From an off state, running the following should result in data.level being set to 99 after 0 seconds.

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].Set(99,0)
Instead of data.level being 99, as expected, it is 4.

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].data.level
{"name":"level","type":"int","value":4,"updateTime":1398743949,"invalidateTime":1398743948}
I then run Set a second time:

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].Set(99,0)
And the value is now 99, as expected

Code: Select all

/ZWaveAPI/Run/devices[9].instances[0].commandClasses[0x26].data.level

{"name":"level","type":"int","value":99,"updateTime":1398744013,"invalidateTime":1398744012}
Logs follow:
[2014-04-29 04:21:32.510] Executing script: zway.devices[9].instances[0].commandClasses[0x26].Set(99,0)
[2014-04-29 04:21:32.512] Adding job: SwitchMultilevel Set
[2014-04-29 04:21:32.513] Adding job: SwitchMultilevel Get
[2014-04-29 04:21:32.522] SENDING (cb 0x01): ( 01 0A 00 13 09 03 26 01 63 25 01 8C )
[2014-04-29 04:21:32.533] RECEIVED ACK
[2014-04-29 04:21:32.543] RECEIVED: ( 01 04 01 13 01 E8 )
[2014-04-29 04:21:32.544] SENT ACK
[2014-04-29 04:21:32.544] Delivered to Z-Wave stack
[2014-04-29 04:21:32.554] RECEIVED: ( 01 05 00 13 01 00 E8 )
[2014-04-29 04:21:32.554] SENT ACK
[2014-04-29 04:21:32.555] Job 0x13 (SwitchMultilevel Set): Delivered
[2014-04-29 04:21:32.555] SETDATA devices.9.data.lastPacketInfo.delivered = True
[2014-04-29 04:21:32.555] SETDATA devices.9.data.lastPacketInfo.packetLength = 6 (0x00000006)
[2014-04-29 04:21:32.555] SETDATA devices.9.data.lastPacketInfo.deliveryTime = 11 (0x0000000b)
[2014-04-29 04:21:32.555] SETDATA devices.9.data.lastPacketInfo = **********
[2014-04-29 04:21:32.556] SendData Response with callback 0x01 received: received by recipient
[2014-04-29 04:21:32.556] SETDATA devices.9.data.lastSend = 9103 (0x0000238f)
[2014-04-29 04:21:32.556] Job 0x13 (SwitchMultilevel Set): success
[2014-04-29 04:21:32.556] Removing job: SwitchMultilevel Set
[2014-04-29 04:21:32.624] SENDING (cb 0x02): ( 01 09 00 13 09 02 26 02 25 02 ED )
[2014-04-29 04:21:32.635] RECEIVED ACK
[2014-04-29 04:21:32.645] RECEIVED: ( 01 04 01 13 01 E8 )
[2014-04-29 04:21:32.645] SENT ACK
[2014-04-29 04:21:32.646] Delivered to Z-Wave stack
[2014-04-29 04:21:32.656] RECEIVED: ( 01 05 00 13 02 00 EB )
[2014-04-29 04:21:32.656] SENT ACK
[2014-04-29 04:21:32.656] Job 0x13 (SwitchMultilevel Get): Delivered
[2014-04-29 04:21:32.657] SETDATA devices.9.data.lastPacketInfo.delivered = True
[2014-04-29 04:21:32.657] SETDATA devices.9.data.lastPacketInfo.packetLength = 5 (0x00000005)
[2014-04-29 04:21:32.657] SETDATA devices.9.data.lastPacketInfo.deliveryTime = 10 (0x0000000a)
[2014-04-29 04:21:32.657] SETDATA devices.9.data.lastPacketInfo = **********
[2014-04-29 04:21:32.657] SendData Response with callback 0x02 received: received by recipient
[2014-04-29 04:21:32.657] SETDATA devices.9.data.lastSend = 9112 (0x00002398)
[2014-04-29 04:21:32.658] Job 0x13 (SwitchMultilevel Get): success
[2014-04-29 04:21:32.658] Removing job: SwitchMultilevel Get
[2014-04-29 04:21:32.668] RECEIVED: ( 01 09 00 04 00 09 03 26 03 04 D9 )
[2014-04-29 04:21:32.668] SENT ACK
[2014-04-29 04:21:32.669] SETDATA devices.9.data.lastReceived = 0 (0x00000000)
[2014-04-29 04:21:32.669] SETDATA devices.9.instances.0.commandClasses.38.data.level = 4 (0x00000004)
[2014-04-29 04:21:36.673] Executing script: zway.devices[9].instances[0].commandClasses[0x26].data.level
[2014-04-29 04:21:43.909] Executing script: zway.devices[9].instances[0].commandClasses[0x26].Set(99,0)
[2014-04-29 04:21:43.911] Adding job: SwitchMultilevel Set
[2014-04-29 04:21:43.911] Adding job: SwitchMultilevel Get
[2014-04-29 04:21:43.912] SENDING (cb 0x03): ( 01 0A 00 13 09 03 26 01 63 25 03 8E )
[2014-04-29 04:21:43.922] RECEIVED ACK
[2014-04-29 04:21:43.933] RECEIVED: ( 01 04 01 13 01 E8 )
[2014-04-29 04:21:43.933] SENT ACK
[2014-04-29 04:21:43.933] Delivered to Z-Wave stack
[2014-04-29 04:21:43.944] RECEIVED: ( 01 05 00 13 03 00 EA )
[2014-04-29 04:21:43.944] SENT ACK
[2014-04-29 04:21:43.944] Job 0x13 (SwitchMultilevel Set): Delivered
[2014-04-29 04:21:43.944] SETDATA devices.9.data.lastPacketInfo.delivered = True
[2014-04-29 04:21:43.945] SETDATA devices.9.data.lastPacketInfo.packetLength = 6 (0x00000006)
[2014-04-29 04:21:43.945] SETDATA devices.9.data.lastPacketInfo.deliveryTime = 10 (0x0000000a)
[2014-04-29 04:21:43.945] SETDATA devices.9.data.lastPacketInfo = **********
[2014-04-29 04:21:43.945] SendData Response with callback 0x03 received: received by recipient
[2014-04-29 04:21:43.945] SETDATA devices.9.data.lastSend = 10110 (0x0000277e)
[2014-04-29 04:21:43.945] Job 0x13 (SwitchMultilevel Set): success
[2014-04-29 04:21:43.945] Removing job: SwitchMultilevel Set
[2014-04-29 04:21:44.017] SENDING (cb 0x04): ( 01 09 00 13 09 02 26 02 25 04 EB )
[2014-04-29 04:21:44.028] RECEIVED ACK
[2014-04-29 04:21:44.038] RECEIVED: ( 01 04 01 13 01 E8 )
[2014-04-29 04:21:44.039] SENT ACK
[2014-04-29 04:21:44.039] Delivered to Z-Wave stack
[2014-04-29 04:21:44.049] RECEIVED: ( 01 05 00 13 04 00 ED )
[2014-04-29 04:21:44.050] SENT ACK
[2014-04-29 04:21:44.050] Job 0x13 (SwitchMultilevel Get): Delivered
[2014-04-29 04:21:44.050] SETDATA devices.9.data.lastPacketInfo.delivered = True
[2014-04-29 04:21:44.050] SETDATA devices.9.data.lastPacketInfo.packetLength = 5 (0x00000005)
[2014-04-29 04:21:44.050] SETDATA devices.9.data.lastPacketInfo.deliveryTime = 11 (0x0000000b)
[2014-04-29 04:21:44.050] SETDATA devices.9.data.lastPacketInfo = **********
[2014-04-29 04:21:44.051] SendData Response with callback 0x04 received: received by recipient
[2014-04-29 04:21:44.051] SETDATA devices.9.data.lastSend = 10119 (0x00002787)
[2014-04-29 04:21:44.051] Job 0x13 (SwitchMultilevel Get): success
[2014-04-29 04:21:44.051] Removing job: SwitchMultilevel Get
[2014-04-29 04:21:44.062] RECEIVED: ( 01 09 00 04 00 09 03 26 03 63 BE )
[2014-04-29 04:21:44.062] SENT ACK
[2014-04-29 04:21:44.062] SETDATA devices.9.data.lastReceived = 0 (0x00000000)
[2014-04-29 04:21:44.062] SETDATA devices.9.instances.0.commandClasses.38.data.level = 99 (0x00000063)
[2014-04-29 04:21:47.505] Executing script: zway.devices[9].instances[0].commandClasses[0x26].data.level
[2014-04-29 04:21:51.638] Job 0x13: deleted from queue
[2014-04-29 04:21:51.706] Job 0x13: deleted from queue
ollfa
Posts: 31
Joined: 12 Jul 2013 11:36

Re: Command Class SwitchMultiLevel Help

Post by ollfa »

I have the same problem, I also have to update manually. Another post in another thread, same problem: viewtopic.php?f=3422&t=20293&p=50235#p50235
User avatar
PoltoS
Posts: 7601
Joined: 26 Jan 2011 19:36

Re: Command Class SwitchMultiLevel Help

Post by PoltoS »

This is a known problem - not in Z-Way, but in most of Z-Wave devices.

Then you send a Set(), a Get() is issued immediatelly (you can see it in the log). But in most cases at the moment this Get() reaches the device, it is only on the way to dim from 0 to 99 (for example at level 4 in your case). So, the report will contain 4. Since you never know the time it will take to dim (it may take even hours if you specify such a duration time - usefull for children going sleep), we can not issue a next Get() after the device ends dimmig.

But good news: some good devide have an association group for reports, where they report their status after it was changed. For example, all our Z-Wave.Me devices, Finaro devices and it will even be mandatory in new Z-Wave Plus.
Leaving Hope
Posts: 4
Joined: 28 Apr 2014 08:17

Re: Command Class SwitchMultiLevel Help

Post by Leaving Hope »

Thanks for confirming, PoltoS. I look forward to the Z-Wave Plus implementation.

Until then, I was able to code around this behavior by issuing the Set command multiple times and disabling the UI controls until the Set operation is complete. For those who are interested, here are the details. Please note the UI is a major work in progress, and the solution is not pretty.
razberry-dimmer1.png
razberry-dimmer1.png (2.8 KiB) Viewed 7546 times
For the dimmer UI controls I opted not to use the HTML5 ranged input type because not all browsers interpret its events consistently. I was running into issues where the mouseup and change events worked differently on my desktop and on my iPad tablet.

Instead, I utilized the jQuery UI Slider with jQuery UI Touch Punch.

I first listen on the jQuery UI Slider Stop event. When slider stop event fires, I set a "slider-inuse" attribute on the slider element with the value of true. I then disable the slider UI element and Off and Full buttons with javascript, and set the Switch Multi Level value with the ZWay API to the value of the jQuery UI Slider. To address the weird behavior noted in this thread, I set the Switch Multi Level value three more times, one second apart, using setTimeout(). During the final set timeout, I set the "slider-inuse" value to false and reenable the buttons.
razberry-dimmer2.png
razberry-dimmer2.png (3.88 KiB) Viewed 7546 times
I also use $.triggerPath to listen for updates to devices[nodeId].instances[instanceId].commandClasses[COMMAND_CLASS_SWITCH_MULTI_LEVEL].data.level. When an update is heard, it runs an updateSlider method. When the update Slider method runs, it checks to see if the slider-inuse=true. If so, it does nothing. It not, which should be the case on the final setTimeout, it updates the jQuery Slider to the value of the multi level switch.

From PoltoS' response, it's clear that I should change the Set operations to Gets, which should accomplish the same thing. As he mentioned, a Get is immediately fired after a Set, which is why my solution works. But the extra Sets aren't necessary if you do the Gets.
Post Reply