velocityzen / homebridge-platform-zwave

Homebridge Platform for Z-Wave nodes. Deprecated! Use node-red instead.
MIT License
13 stars 6 forks source link

Update switchMultiLevel to Better Support Dimmers #5

Closed shnhrrsn closed 4 years ago

shnhrrsn commented 4 years ago

My dimmer switches (GE 12724) weren’t quite working right. Turning off worked, but turning on didn’t — unless I explicitly set the brightness level.

Since I’m migrating from SmartThings, I dug into how they did it, and found this:

Many Z-Wave commands use 8-bit integers to represent device state. Generally 0 means “off” or “inactive”, 1-99 are used as percentage values for a variable level attribute, and 0xFF or 255 (the highest value) means “on” or “detected”.

I tried it, and sure enough, 0xFF works as a special “on” signal to the dimmer where it turns back on the prior level.

Since SmartThings makes device handlers public, I also took a look at how exactly they’re turning dimmers on and off in their generic dimmer device handler: https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/dimmer-switch.src/dimmer-switch.groovy#L206-L211

I wasn’t able to leverage getNodeValue because it reads from cache, so I added refreshNodeValue throughout and I have it firing 5s after an on/off even like SmartThings does.