WebThingsIO / zwave-adapter

Z-Wave adapter add-on for WebThings Gateway
Mozilla Public License 2.0
15 stars 20 forks source link

Adding support for the Fortrezz Mimolite #108

Closed jsteinberg closed 4 years ago

jsteinberg commented 4 years ago

I was attempting to follow along with the Adding a new device guide and I ran into a few issues. I was hoping for a little clarity so I could add support for this device.

Mimolite User Manual MIMOlite Technical Appendix

Issue 1: How do I test my changes to the adapter code? When I make changes and attempt to run the gateway, I get the following error message:

Failed to load add-on zwave-adapter: Error: SHA256SUMS file missing for add-on zwave-adapter                                                                      
    at loadManifestJson (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-utils.js:390:1)                                                                                                     
    at Object.loadManifest (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-utils.js:472:1)                                                                                                  
    at AddonManager.loadAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:621:1)                                                                                             
    at fs.readdir (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:794:1)                                                                                                         
    at FSReqWrap.oncomplete (fs.js:135:15) 

I'm pretty sure I could change the SHA256SUMS file where necessary, but that seems like a lot of work since I'm not super confident in my changes.

Issue 2: This device classifies with generic type of Binary Switch. The issue I'm having is it is also has a Binary Sensor

Here is some of the logging output.

zwave: node6 valueAdded: 6-37-1-0:Switch = false                                                                                                                  
zwave: node6 valueAdded: 6-48-1-0:Sensor = true                                                                                                                   
zwave: node6 valueAdded: 6-49-1-2:General Purpose = 2142                                                                                                          
zwave: node6 valueAdded: 6-53-1-0:Count = 1
zwave: node6 valueAdded: 6-113-1-512:Alarm Type = 0
zwave: node6 valueAdded: 6-113-1-513:Alarm Level = 0
zwave: node6: Named FortrezZ MIMOlite
zwave: node6: name="zwave-d1c4d603-6-Switch", type="Binary Switch", location=""                                                                                  
zwave: node6 valueChanged: 6-37-1-0:Switch = false (no property found)                                                                                           
zwave: node6 valueChanged: 6-48-1-0:Sensor = true (no property found)                                                                                            
zwave: node6 valueChanged: 6-49-1-2:General Purpose = 2143 (no property found)                                                                                   
zwave: node6 valueChanged: 6-53-1-0:Count = 1 (no property found) 

classify debugging output:

zwave: classifyInternal: manufacturerId: 0x0084 productId: 0x0111                                                                                                
zwave: classify: called for node zwave-d1c4d603-6, genericType = Switch Binary (0x10)                                                                            
zwave: classify:   colorCapabilitiesValueId = undefined
zwave: classify:   binarySwitchValueId = 6-37-1-0
zwave: classify:   doorLockValueId     = undefined
zwave: classify:   levelValueId        = undefined
zwave: classify:   binarySensorValueId = 6-48-1-0
zwave: classify:   centralSceneValueId = undefined
zwave: classify:   alarmValueId        = undefined
zwave: classify:   temperatureValueId  = undefined
zwave: classify:   luminanceValueId    = undefined
zwave: classify:   humidityValueId     = undefined
zwave: classify:   wakeUpIntervalValueId    = undefined
zwave: classify:   minWakeUpIntervalValueId = undefined
zwave: classify:   maxWakeUpIntervalValueId = undefined
zwave: classify:   carbonMonoxideValueId  = undefined
zwave: classify:   quirk.isLight       = undefined
zwave: binarySwitchValueId = 6-37-1-0 levelValueId = undefined suffix =                                                                                          
zwave: classify: zwave-d1c4d603-6 added property: on valueId: 6-37-1-0 value: false                                                                              
zwave: classify: zwave-d1c4d603-6 named zwave-d1c4d603-6-Switch defaultName: zwave-d1c4d603-6-Switch types: [ 'OnOffSwitch' ]

Because of the genericType switch statement, it setups the Binary Switch correctly, but does not setup the Binary Sensor. Additionally, there are a several configuration properties, but I only care about configuration property 11. The switch can be setup in Momentary mode where it automatically turns off after X seconds. This configuration property lets me increase the value from 100ms.

So, in summary, my question really is how should I tackle adding support for this device? It seems like it would take a very custom classify handler to deal with all the non generic behavior the device contains(being a switch and a sensor, having lots of configuration properties). There doesn't seem to be too much custom device handling outside of the Quirks.

Also, is there any value in having a way that automatically presents all of the configuration properties to the user(so other future generic-ish devices can be configured without adding custom behavior? Based off of the info provided from the device from the cli, it doesn't seem like it would be too terrible to ingest the configuration properties automatically.

Attached is the info result from the cli.

forezz-mimolite.json.zip

Thank you

mrstegeman commented 4 years ago

Issue 1: if you create a .git directory within the zwave-adapter directory, the checksums will be skipped.

Issue 2: there are several cases where we special-case devices. For instance, search for FIRST_ALERT, ECOLINK, or AEOTEC in zwave-classifier.js. Sometimes, the generic classifier just doesn't work well.

Issue 3 (presenting configuration properties): for the most part, the user doesn't need to be concerned with these. Again, though, there are certainly special cases. For example, we add a wake-up interval property for battery-operated devices.

jsteinberg commented 4 years ago

Thank you for the response.

Issue 1: if you create a .git directory within the zwave-adapter directory, the checksums will be skipped.

Worked perfectly.

Issue 2: there are several cases where we special-case devices. For instance, search for FIRST_ALERT, ECOLINK, or AEOTEC in zwave-classifier.js. Sometimes, the generic classifier just doesn't work well.

Sorry, I wasn't very clear. I saw those other examples but as this is a multi function device, I wasn't sure it fit with the patterns that I saw. I will come up with something along the lines of what the other devices are doing to try to make the impact of my changes minimal.

Issue 3: (presenting configuration properties)...

That makes sense. This is my first time working with any of this and this is the only device I currently have. I suppose if the front end was smart enough to allow a user to ignore certain properties, then it might make sense to handle them more generically. But the effort involved in that might not be worth it.

Since I am unblocked I think it is okay to close this issue. I can always re-open if I think necessary.

I likely won't have a lot of time during the week to play with this.