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 (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 (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.