[OBSOLETE] Russound Multi-Zone Controller Integration

running “npm install”, I get stuck at this indefinitely:

extract:nconf: verb gentlyRm don't care about contents; nuking /home/smartthings-nodeproxy/node_modules/.staging/nconf-ce692741/node_modules

EDIT: never mind, looks like Raspberry Pi 1 just takes like 2.5 hours to run that command, lol.

Did you run as root or use sudo?

Ok,

$ install npm
$ npm install express --build-from-source

both done. Rebooted to clear out another process that had had access to the serial port.

$ cd /home/smartthings-nodeproxy
$ node server.js

[2016-12-03T05:28:35.153Z] [stnp] SmartThings Node Proxy listening at http://:::7778
module.js:471
    throw err;
    ^

Error: Cannot find module './plugins/'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /home/smartthings-nodeproxy/server.js:88:35
    at Array.forEach (native)
    at /home/smartthings-nodeproxy/server.js:86:6
    at FSReqWrap.oncomplete (fs.js:123:15)

I have the folder “plugins/” containing “rnet.js” located inside the “smartthings-nodeproxy/” folder that I’m launching server.js from. Any ideas on this latest dilemma?

BTW, thank you so much for you help!

Check to ensure that the user that node is run by, which should be the user ‘nobody’, has permissions to read the entire path up to and including the plugin file. You can use the command ‘namei -mo /full/path/to/plugin’ to check the path permissions.

looks like ‘/smartthings-nodeproxy/’ and all in it are owned by ‘root’. I’m running as user ‘pi’

I get the same result if I run “node server.js” or “sudo node server.js”

pi@homeassistant:/home/smartthings-nodeproxy/plugins $ namei -mo /home/smartthings-    nodeproxy/plugins
f: /home/smartthings-nodeproxy/plugins
 drwxr-xr-x root root /
 drwxr-xr-x root root home
 drwxrwxrwx root root smartthings-nodeproxy
 drwxrwxrwx root root plugins

Same result if I “sudo su” to change to root user. HMMM?

Is it the case that I should have been ‘root’ user when I ran ‘npm install’ and ‘npm install express’?
I ran those from ‘pi’ user

Yes. Try reinstalling everything as root. Do the following while logged in as user pi. This will ensure that everything is installed globally.

sudo -i
cd /home/smartthings-nodeproxy/
npm install express -g --unsafe-perm --build-from-source
npm install -g --unsafe-perm

I was able to fix the baudRate error by adding “baudRate”: 9600, to the serial port section of the config.json file. It must be required for the new version of serial that you updated to.

I have a couple of questions/comments.

  1. Even though I cloned your updated git hub repo, and updated my SmartApp and Device Handler on ST IDE, I do not have your updated interface with “Party mode” within my ST iOS app. Is there something else that I need to do? I’m using the monoprice plugin, not the russound.

  2. Git hub integration for your repo will not work for me. I integrated my ST IDE with my git hub account, and followed your instructions to add your repo. When I click on “Update from Repo” from the IDE Smart Apps, or Device Handlers screen, I am presented with the screen with the three columns, but nothing is listed under the Obsolete column. Your apps are listed under the “New” column though. I initially added the smart app and device handler through copying and pasting your code into the IDE. In order to update through git hub, I figured that I needed to delete the existing smart app and device handler, and add them back through the git hub integration by clicking on the checkbox next to the app “devicetypes/redloro-smartthings/mpr6z-zone.src/mpr6z-zone.groovy” under the “New column”, checking publish, and clicking execute update. When I do that, I get an error that states, “Updated 0 devices and created 0 new devices, 0 published (1 skipped due to errors)”. I have not found any way to troubleshoot, or even find out what the error is!? I also received the same error before deleting the existing Smart App and Device Handler and trying to update via git hub with them present. It seems as though the IDE doesn’t acknowledge that the apps are present within your repo; even though I manually edited the app and selected that it was from your repo. Any ideas?

  3. Finally, just a recommendation, but I noticed that the “off” icon on the bottom right side of the zone control within the ST app turns off all zones. That’s a great function, but it would be nice if the icon was labeled as “All off”, or something similar. “Off” just seems like it would only apply to the selected zone.

Thanks.

Thanks for your continued help Jason! I am just now getting back to work on this. Before I try to reinstall as root, should I do anything to remove the old install? Would I just delete the smartthings-nodeproxy folder or something more involved?

No that shouldn’t be necessary. Just run the commands to reinstall over the current installation.

Ok, I did everything as you instructed above. I’m still getting the same error when I run “node server.js” as either ‘pi’ or ‘root’:

Error: Cannot find module './plugins/'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/smartthings-nodeproxy/server.js:88:35
at Array.forEach (native)
at /home/smartthings-nodeproxy/server.js:86:6
at FSReqWrap.oncomplete (fs.js:123:15)

Clearly the folder is there.

I also got this error during the “npm install -g --unsafe-perm” process:

> serialport@4.0.6 install /usr/local/lib/node_modules/SmartThingsNodeProxy/node_modules/serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.6/serialport-v4.0.6-node-v48-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.6 and node@6.9.1 (node-v48 ABI) (falling back to source compile with node-gyp)

The node-pre-gyp error is normal. It built it from source, which is fine.

The ./plugins error seems like a permissions issue with reading the plugins folder and/or files. Have you searched the forum for other users that have run into that error? I received that error at first too, but I’m not sure how I fixed it. I changed the permissions of the plugins folder and files to 775 and set everything to executable and rebooted the rPi; then everything just worked. I don’t know how that would have fixed it, but it did. If you want to give it a try, cd to your smart things node proxy folder and run:

sudo chmod -R 775 plugins
sudo chmod -R +x plugins
sudo reboot

@partytime-excellent just walked through installing all of this on a new RPi Zero and not sure where things started to go wrong, but you’re clearly dealing with a lot… wanted to see if you had followed the steps here to get the latest Node v6.x installed: https://oshlab.com/install-latest-node-js-raspberry-pi-3/

And at the top there is reference to clearing out all the old NodeJS stuff that comes with Raspbian.

I’m posting the video of the complete walk-through tonight so hopefully that helps too.

@redloro Mucho gracias for taking the time to make a Pi install video! I’m currently running Node 6.9.1. I feel so close to getting this going, I’m sure the video will put me over the top. Cheers!

Here you go… hope this helps… https://www.youtube.com/watch?v=XC2X8Qiyxqs

Thanks a lot for posting the video! I redid the whole installation and was able to get NodeProxy up and running. I must have had some permission issues going on. I also installed and published the SmartApp and DeviceHandler successfully. The two systems appear to be working and communicating, however, I’m still not seeing the zones show up on the SmartThings App.

Here the readout when I launch server.js:

pi@homeassistant:~/smartthings-nodeproxy $ node server.js
[2016-12-06T19:33:17.692Z] [stnp] SmartThings Node Proxy listening at http://:::7778
[2016-12-06T19:33:17.872Z] [evl3] ** NOTICE ** Envisalink settings not set in config file!
[2016-12-06T19:33:17.900Z] [stnp] Loaded plugin: envisalink
[2016-12-06T19:33:17.925Z] [gnrc] Doing something interesting during init...
[2016-12-06T19:33:17.931Z] [stnp] Loaded plugin: generic
[2016-12-06T19:33:18.476Z] [stnp] Loaded plugin: rnet
[2016-12-06T19:33:18.643Z] [rnet] Connected to RNET: /dev/ttyUSB0
[2016-12-06T19:33:19.427Z] [rnet] Detected serial ports: ["/dev/ttyACM0","/dev/ttyAMA0","/dev/ttyUSB0"]
[2016-12-06T19:33:49.704Z] [stnp] ::ffff:192.168.1.239 GET /subscribe/192.168.1.239:39500
[2016-12-06T19:33:54.938Z] [stnp] ::ffff:192.168.1.239 GET /plugins/rnet/discover
[2016-12-06T19:33:55.186Z] [rnet] {"type":"discover","zones":[{"zone":0,"name":"Living Room"},{"zone":1,"name":"Kitchen"},{"zone":2,"name":"Bedroom"},{"zone":3,"name":"Silas Room"},{"zone":4,"name":"Garage"},{"zone":5,"name":"Patio"}]}
[2016-12-06T19:33:55.188Z] [rnet] Completed controller discovery

I’ve re-entered the SmartApp several times and clicked ‘done’ to see if it would refresh, no luck. Any idea what’s hanging me up now? Thanks

@partytime-excellent great to hear… let’s do the following. Before we start, have you pulled down on the Things screen to force a refresh in the ST mobile app?

  • Delete the envisalink.js and generic.js files in the plugins folder so that we’re only looking at the rnet.js plugin.
  • With the NodeProxy service up and running, go to the Developer Console -> My Smart Apps and edit the code for the Russound RNET Smart App…
  • Remove the // on line 133
  • Save and publish
  • Go to the Developer Console -> Live Logging… leave this window open
  • Using the SmartThings app, launch the Russound SmartApp, verify your settings and hit “Done”
  • Report back what you see in the Node Proxy logs and the SmartThings Live Logging console

When I restart server.js, I get this in the ST log:

 error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.String#<init>.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class [B]
[class [C]
[class java.lang.String] @ line 170

Error on line 170

I deleted the active instance of the SmartApp and created a new one. Doing so causes this to pop up in console:

pi@homeassistant:~/smartthings-nodeproxy $ node server.js
[2016-12-06T21:09:32.462Z] [stnp] SmartThings Node Proxy listening at http://:::7778
[2016-12-06T21:09:33.293Z] [stnp] Loaded plugin: rnet
[2016-12-06T21:09:33.438Z] [rnet] Connected to RNET: /dev/ttyUSB0
[2016-12-06T21:09:34.165Z] [rnet] Detected serial ports: ["/dev/ttyACM0","/dev/ttyAMA0","/dev/ttyUSB0"]
[2016-12-06T21:12:27.953Z] [stnp] ::ffff:192.168.1.239 GET /subscribe/192.168.1.239:39500
[2016-12-06T21:12:33.530Z] [stnp] ::ffff:192.168.1.239 GET /plugins/rnet/discover
[2016-12-06T21:12:33.964Z] [rnet] {"type":"discover","zones":[{"zone":0,"name":"Living Room"},{"zone":1,"name":"Kitchen"},{"zone":2,"name":"Bedroom"},{"zone":3,"name":"Silas Room"},{"zone":4,"name":"Garage"},{"zone":5,"name":"Patio"}]}
[2016-12-06T21:12:33.966Z] [rnet] Completed controller discovery

And this in the ST logs:

1e79ab88-a896-467b-b6a3-739d884a038c  1:15:34 PM: debug Received device event from bridge: [type:discover, zones:[[name:Living Room, zone:0], [name:Kitchen, zone:1], [name:Bedroom, zone:2], [name:Silas Room, zone:3], [name:Garage, zone:4], [name:Patio, zone:5]]]
d9c80855-93df-4886-901a-066cf48e849b  1:15:34 PM: debug Parsing 'index:03, mac:XXXXXX, headers:Tk9USUZZIC9ub3RpZnkgSFRUUC8xLjENCkNPTlRFTlQtVFlQRTogYXBwbGljYXRpb24vanNvbg0KQ09OVEVOVC1MRU5HVEg6IDIwMQ0Kc3RucC1wbHVnaW46IHJuZXQNCkhvc3Q6IDE5Mi4xNjguMS4yMzk6Mzk1MDANCkNvbm5lY3Rpb246IGNsb3Nl, body:eyJ0eXBlIjoiZGlzY292ZXIiLCJ6b25lcyI6W3siem9uZSI6MCwibmFtZSI6IkxpdmluZyBSb29tIn0seyJ6b25lIjoxLCJuYW1lIjoiS2l0Y2hlbiJ9LHsiem9uZSI6MiwibmFtZSI6IkJlZHJvb20ifSx7InpvbmUiOjMsIm5hbWUiOiJTaWxhcyBSb29tIn0seyJ6b25lIjo0LCJuYW1lIjoiR2FyYWdlIn0seyJ6b25lIjo1LCJuYW1lIjoiUGF0aW8ifV19'
d9c80855-93df-4886-901a-066cf48e849b  1:15:34 PM: debug Parsing 'index:17, mac:XXXXXX, ip:C0A8016F, port:1E62, requestId:0d4b7062-2e45-4bc8-8b5e-c3eddfc807c1, headers:SFRUUC8xLjEgMjAwIE9LDQpYLVBvd2VyZWQtQnk6IEV4cHJlc3MNCkRhdGU6IFR1ZSwgMDYgRGVjIDIwMTYgMjE6MTU6MzQgR01UDQpDb25uZWN0aW9uOiBrZWVwLWFsaXZlDQpDb250ZW50LUxlbmd0aDogMA==, body:'
1e79ab88-a896-467b-b6a3-739d884a038c  1:15:29 PM: error groovy.json.JsonException: A JSON payload should start with an openning curly brace '{' or an openning square bracket '['.
Instead, 'null' was found on line: 1, column: 1 @ line 509
d9c80855-93df-4886-901a-066cf48e849b  1:15:29 PM: debug Parsing 'index:17, mac:XXXXXX, ip:C0A8016F, port:1E62, requestId:70f90ecd-6d9f-4f6b-b49e-5f7c69dbca0a, headers:SFRUUC8xLjEgMjAwIE9LDQpYLVBvd2VyZWQtQnk6IEV4cHJlc3MNCkRhdGU6IFR1ZSwgMDYgRGVjIDIwMTYgMjE6MTU6MjkgR01UDQpDb25uZWN0aW9uOiBrZWVwLWFsaXZlDQpDb250ZW50LUxlbmd0aDogMA==, body:'

Some JSON error on line 509

What smartapp/device do these ids correspond to??

1e79ab88-a896-467b-b6a3-739d884a038c
d9c80855-93df-4886-901a-066cf48e849b

Those are both part of "smartthings-MQTT-bridge"


It’s talking to a Mosquitto MQTT broker on port 1883, on the same Pi that’s running NodeProxy.
It’s also listening on port 8080, I assume that these two are listening on the same port, eh? lol

Is it easy to adjust the port for your app?