WebThingsIO / zwave-adapter

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

Support wallmote #52

Closed dhylands closed 5 years ago

dhylands commented 5 years ago

These changes also bundle the libopenzwave.so file with the zwave adapter.

Note: When changing a config item associated with the wallmote quad (i.e. sound/vibration/color) you need to press the button on the back of the remote (after making the change in the UI) in order to wake the remote up and have the change actually take effect.

For some reason the wallmote doesn't report the color change, so the color in the UI will revert to blue wven though the device was programmed with the correct color.

dhylands commented 5 years ago

OK - FInally got things working on Mac OSX, Linux, and RPi.

There was a really weird problem I ran into. On the gateway-0.7.0 image, the version of node that's included winds up setting LD_LIBRARY_PATH to the empty string. i.e. you could run:

LD_LIBRARY_PATH=foo node
> process.env.LD_LIBRARY_PATH

and it would show as undefined. If I removed and reinstalled node v8.15.0 then it would work fine. But the version included on the image we distributed wouldn't work properly.

So I wound up finding a utility called patchelf which allows the runpath to be set and modified the zwave-adapter package.sh to run patchelf on the openzwave-shared node library to point to libopenzwave and that works whether LD_LIBRARY_PATH is passed through or not.

I wound up updating the docker image that we use to build the RPi stuff to include patchelf.

So I'll get you to eyeball that last couple commits and then I'll release this thing finally.

mrstegeman commented 5 years ago

You need to add the color dependency to your package.json:

2019-03-22 13:20:22.806 ERROR  : zwave: { Error: Cannot find module 'color'
2019-03-22 13:20:22.807 ERROR  : zwave:     at Function.Module._resolveFilename (module.js:548:15)
2019-03-22 13:20:22.809 ERROR  : zwave:     at Function.Module._load (module.js:475:25)
2019-03-22 13:20:22.811 ERROR  : zwave:     at Module.require (module.js:597:17)
2019-03-22 13:20:22.812 ERROR  : zwave:     at require (internal/module.js:11:18)
2019-03-22 13:20:22.814 ERROR  : zwave:     at Object.<anonymous> (/home/pi/.mozilla-iot/addons/zwave-adapter/zwave-property.js:13:15)
2019-03-22 13:20:22.816 ERROR  : zwave:     at Module._compile (module.js:653:30)
2019-03-22 13:20:22.817 ERROR  : zwave:     at Object.Module._extensions..js (module.js:664:10)
2019-03-22 13:20:22.819 ERROR  : zwave:     at Module.load (module.js:566:32)
2019-03-22 13:20:22.820 ERROR  : zwave:     at tryModuleLoad (module.js:506:12)
2019-03-22 13:20:22.822 ERROR  : zwave:     at Function.Module._load (module.js:498:3) code: 'MODULE_NOT_FOUND' }
dhylands commented 5 years ago

Weird that it loaded fine on all 3 platforms without the color dependency.

mrstegeman commented 5 years ago

Can you trigger a build for this on Travis so I can try it again?

dhylands commented 5 years ago

Done.

I used:

trigger-build.sh --pr 52 zwave-adapter

https://travis-ci.org/mozilla-iot/addon-builder/builds/510020950 (once it finishes)

mrstegeman commented 5 years ago

Awesome. Tested on the RPi and macOS. Both work well.