maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

No longer working (Pi 2) #3

Closed TotallyInformation closed 8 years ago

TotallyInformation commented 8 years ago

Hi Max, something has happened. I've just installed a new installation of Node-Red (v0.11.2) on a Pi2 using Node v0.10.40

I've installed NR using the recommended -g and created a new flow. I installed this module and it no longer works without also installing the node.js rfxcom module. I think this is due to the change of NPM up to v3 which now flattens the installation of node modules.

Even after installing the rfxcom module, although I can now start NR, when I try to add any of the rfx listening nodes and connect them to /dev/ttyUSB0 which is definitely where the rfxcom is attached (confirmed by dmesg), I only get an error:

3 Oct 22:19:17 - [error] [rfx-sensor:fd644eb6.029bb] TypeError: Cannot read property 'length' of undefined

So I can no longer run any flows including the rfx.

TotallyInformation commented 8 years ago

OK, also odd. Just tried running rfxcom directly from a simple node app.js and it works fine on /dev/ttyUSB0

maxwellhadley commented 8 years ago

I hit what may be a the same problem, upgrading to node-RED 0.11.1 & node.js 0.12.7 on a new system I'm putting together (Ubuntu 14.04 on an Intel Atom embedded thingy). That got me npm 2.11.3, but then the rfxcom nodes were not found at all. I discovered that the new version of npm had changed the 'global' prefix from /usr/local to /usr, so things were in a bit of a mess. I changed the prefix back, then uninstalled & reinstalled node-red:

npm config set prefix '/usr/local'
sudo npm uninstall -g node-red
sudo npm install -g node-red

That still left rfxcom unable to access the serial port, although I don't think I was getting the same error you saw. I fixed it by locally uninstalling & reinstalling rfxcom's dependency on serialport from the original installation directory:

cd /usr/local/lib/node_modules/node-red-contrib-rfxcom/node_modules/rfxcom
sudo npm uninstall serialport
sudo npm install serialport

I think the uninstall is essential, but I'm not 100% sure. I had to do a similar process when updating node-red-contrib-openzwave's dependency on openzwave-shared. It looks like only the top-level dependencies are being correctly updated, although npm may well have installed the correct dependency somewhere else entirely. Annoying.

TotallyInformation commented 8 years ago

Hmm, I don't generally use the -g install of NR as this kind of goes against the grain of Node development so I'm not using /usr or /user/local (or at least I don't think I am) which might explain some differences.

Clearly one thing that changed was that I had to manually install rfxcom. That somewhat fits in with your discovery. I did try manually installing serialport but I haven't tried uninstalling the dependent version I must admit.

I have even bigger problems now in that I can no longer load the UI [syntax error in vendor.js (4,21331)]! I think I've spotted some errors in the HTML. Taking dependencies out of NR appears to be fairly painful too, I was trying to remove nodes to see if one particular one was causing problems. But when you do, NR refuses to load, it just waits for the node to be loaded which is weird. It should just fail to load that node.

I'll try to uninstall some dependent modules from within the rfx module folder to see if that helps. However, I needed to do a quick workaround yesterday - I hadn't realised just how dependent the house has become on NR! I've moved the RFX send/receive functions out to their own "microservice" using raw Node.JS with rfxcom and mqtt modules. It was pretty easy and it actually responds to commands rather quicker now!

I can see that everything is going to be rather a mess in the move to npm v3 and Node v4 - lets hope things calm down after that.

maxwellhadley commented 8 years ago

I hope to have time to look at rfxcom again soon, as I have a few things to fix like the PT2262 nodes, a few additions like doorbells, and I want to remove the git dependency on my own version of node-rfxcom since I can't get my PR accepted. So far I have only updated the Ubuntu installation: still got OS X (now 10.11), Windows 7, and Debian Linux to do! I'll leave the issue open until that's all done.

TotallyInformation commented 8 years ago

No /usr/local/lib/node_modules on my Pi2.

Ah! I think I spotted the problem. Not tried yet but I forgot that this uses a modified version of rfxcom - so I installed the standard version rather than yours.

maxwellhadley commented 8 years ago

That would be it - I've had a pull request sitting on the original since 2014-08-14 or something, so I'm planning to publish my own fork with a different name, and switch over the node-red-contrib-rfxcom dependency from github to the new module on npm. I'm surprised I haven't had any issues yet with users who don't have git installed. But rather a lot has been changing recently & I want to wait until the dust settles a bit...

TotallyInformation commented 8 years ago

Yup, that fixed it!

So, you do have to do a manual install of the dependency, you can do it at the app level though (don't need to install from within your modules folder.

You might want to update your install docs warning people until, as you say, the dust settles and things can be worked out.

maxwellhadley commented 8 years ago

Is that the dependency of node-red-contrib-rfxcom on rfxcom, or the dependency of rfxcom on serialport that you manually installed?

TotallyInformation commented 8 years ago

The dependency on node-rfxcomm (your version). If you install node-red-contrib-rfxcom it complains about the missing rfxcomm but of course not about the fact that it needs your version. So I installed the standard version without thinking.

Not really sure why the install of node-red-contrib-rfxcom isn't properly installing node-rfxcomm - I wonder if that is an npm bug due to the use of the git+https archive rather than the npm archive?

TotallyInformation commented 8 years ago

Just to let you know that I was having problems updating your node with the current version of Node-Red. However, doing an npm rm on it then installing from scratch seems to have done the trick.

I'm leaving my old NR instance (v0.11.1) well alone until I can migrate everything into the new v0.12.x instance. When I've done that, I'll also be able to upgrade to a newer version of node.js

I'll close this now because I think we are beyond the problems raised.