Open armacali opened 7 years ago
Hi, I'm getting the same error, ran manually it's something to do with the pre-compiled bluetooth binding (could this be a 64bit vs 32bit problem, I'm using Ubuntu 17.04 64bit). Here's the full error message:
module.js:598
return process.dlopen(module, path._makeLong(filename));
^
Error: /var/opt/node/smartthings-smartbulbs/node_modules/bluetooth-hci-socket/build/Release/binding.node: wrong ELF class: ELFCLASS32
at Object.Module._extensions..node (module.js:598:18)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/opt/node/smartthings-smartbulbs/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
Edited 5 March 2018: Just had to reinstall this again on a new server and ran into the same problem and realised I'd missed off a few steps, sorry here's the new version: Okay, think I've got it solved. The problem is that the node_modules directory is not supposed to be included, and should be generated on each individual machine. Only takes a few extra steps:
First install node-gyp which lets us compile native bindings/device drivers for the OS+machine you're using. We will install it as a 'global' package so any node app can use it (the -g option).
sudo git clone https://github.com/nodejs/node-gyp.git
cd node-gyp
sudo npm install -g node-gyp
If you don't want to clone it first:
sudo npm install git://github.com/nodejs/node-gyp.git
or
sudo npm install github nodejs/node-gyp
may also work.
Then we need to install all the prerequisites for smartthings-smartbulbs. Don't make these global, just available to smartthings-smartbulbs. So first change to that directory:
cd /var/opt/node/smartthings-smartbulbs
Delete the current node_modules directory:
sudo rm -rf node_modules
I then got a strange problem where even though I was using sudo, the modules where installing with my usual users permissions (alex in my case), which meant I was getting lots of 'Permission Denied' errors when compiling things, especially the bluetooth-hci-socket module. This was solved by doing this slightly altered work-around:
Create the node_modules directory as your normal user:
mkdir node_modules
If this doesn't work, so may need to use sudo, but after that chown it to your normal user
Then install the prerequisites, from what I could guess these are:
-- Development headers/packages for bluetooth support in ubuntu
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
-- Required Nodejs packages (this should pull in all the other required ones, at least it did on mine):
npm install bluetooth-hci-socket
If you run into access denied errors, check that /home/sudo chown -R <your user>:<your user> /home/<your user>/.npm
obviously changing
Then to test, run:
./smartbulbserver.js
If it runs, fab, press ctrl+c
to exit, if it complains that it can't find a module, install it using npm install
, as above.
There maybe a better way to do all this (I've not used nodejs knowingly before), but this way seems to work.
Also, if you are running into a problem where it can;t find pws.json this is caused because the 'FindMyIphone' functionality added into the software requires this as a file that contains your appleid and password in json format (no idea why smartbulb software needs this really). My best solution is to comment out the few lines in smartbulbserver.js that use this. The lines are 175-178:
} else if (tmpTypeDetails.agent == "FindIphone") {
agents[tmpTypeDetails.agent] = new
require("./FindIphone").FindIphone(handleAgentEvents);
console.log("smartbulbserver: " + "Working for "
+ type + " agent started " + tmpTypeDetails.agent );
agents[tmpTypeDetails.agent].discoverDevices();
becomes:
// } else if (tmpTypeDetails.agent == "FindIphone") {
// agents[tmpTypeDetails.agent] = new
require("./FindIphone").FindIphone(handleAgentEvents);
// console.log("smartbulbserver: " + "Working for "
+ type + " agent started " + tmpTypeDetails.agent );
// agents[tmpTypeDetails.agent].discoverDevices();
and that should get rid of that problem.
If you also run into it needing the rfxcom module, which is a great little module for communicating to anything on the 433MHz range, such as X10, Lightwave, etc. The smartbulbs DO NOT use this frequency, so you can either safely remove the references to it in lines 179-182 in the same way as you did for FindIphone above, or install the rfxcom module using npm install rfxcom
Hope this all helps. Alex
I installed the server on RPi 3 and can confirm the error and fix provided by @ajw107 above.
It seems the modules in node_modules directory cloned via github are mismatch with the version of node.js binary on each installation (I installed node.js following this instruction https://raspberrypi.stackexchange.com/a/48313 using updated node.js package.).
You have to compile the modules yourself for it to work.
@davidcreager Could you exclude the node_modules from master branch as it seems to cause problem?
having real issues installing this lol.
cloned the git, deleted the nodes_modules dir, ran the above npm installs..
so far i've had to install... sudo npm install node-milight-promise sudo npm install request sudo npm install tough-cookie
im stuck on the '../pws.json' module though. Can't seem to figure out how to install it or what it is!
any help would be appreciated.
Aha Sorry...I am such a GitHub newbie.....you really need to use tag v1. the rest of the branches are under development........
yeah im a github newbie too.. even using it make my brain hurt :)
i've cloned the v2 branch but i cant even get past the setup instructions lol...
yeelight-smartthings.service isnt in the directory...i assume it might be called smartbulbserver.service now? config.json .. it's hiding somewhere im sure :)
thanks for your help..
ignore me..i cloned v2...i thought i read i could use v2 also.. i will start again :)
I am beginning to get the hang of it.....and will be sorting this total mess out in a few weeks. (sorry all!) I think the way to go at the moment is git clone https://github.com/davidcreager/smartthings-smartbulbs.git git checkout tags/v1.0
Tag v2.0 might work....I cant remember.....
much appreciated.. i might wait until the housekeeping is done :)
I just can't believe that smartthings refuses to support these out of the box tbh. Im really grateful to you in taking your time to write this. While i'm new to smartthings i've been dabbling with automation for a little bit using homeassistant, in which, the yeelights also work because of guys like you.
fyi, the latest version of node (10.7) and the current version of bluetooth-hci-socket are currently incompatible and it won't compile. bit of a pain, really - you'll have to use an older version for the moment until the library is fixed.
osmc@osmcstar:/var/opt/node/smartthings-smartbulbs$ sudo systemctl status smartbulbserver
Aug 03 22:39:53 osmcstar smartbulbserver.js[1591]: at Object.Module._extensions..js (module.js:580:10) Aug 03 22:39:53 osmcstar smartbulbserver.js[1591]: at Module.load (module.js:503:32) Aug 03 22:39:53 osmcstar systemd[1]: smartbulbserver.service: main process exited, code=exited, status=1/FAILURE Aug 03 22:39:53 osmcstar systemd[1]: Unit smartbulbserver.service entered failed state. Aug 03 22:39:53 osmcstar systemd[1]: smartbulbserver.service holdoff time over, scheduling restart. Aug 03 22:39:53 osmcstar systemd[1]: Stopping node.js server to manage yeelight and miPow bulbs... Aug 03 22:39:53 osmcstar systemd[1]: Starting node.js server to manage yeelight and miPow bulbs... Aug 03 22:39:53 osmcstar systemd[1]: smartbulbserver.service start request repeated too quickly, refusing to start. Aug 03 22:39:53 osmcstar systemd[1]: Failed to start node.js server to manage yeelight and miPow bulbs. Aug 03 22:39:53 osmcstar systemd[1]: Unit smartbulbserver.service entered failed state.