mylylyl / homebridge-soma-shades

Homebridge plugin for SOMA Shades
8 stars 2 forks source link

Plug-in not running #6

Closed psdc-create closed 3 years ago

psdc-create commented 3 years ago

I can't get the plug-in to do anything. I believe the error is related to this message I get when I restart home bridge:

"noble warning: adapter state unauthorized, please run as root or with sudo or see README for information on running without root/sudo: https://github.com/sandeepmistry/noble#running-on-linux [5/10/2021, 5:16:21 AM] [SOMAShades] noble is not running. waiting for it to power on..."

I'm out of ideas!

Environment:

mylylyl commented 3 years ago

Have you tried to add necessary permissions described in that link?

psdc-create commented 3 years ago

If you mean this section of the linked file:

Make sure node is on your PATH. If it's not, some options:

Symlink nodejs to node: sudo ln -s /usr/bin/nodejs /usr/bin/node Install Node.js using the NodeSource package

I've tried the first option with no luck (symlink Command not found). Oddly enough "man symlink" returns an entry. Sorry - I'm new to the pi and these soma shades are doing my head in. I've been trying to link them to HomeKit for days.

mylylyl commented 3 years ago

what system you're running? I've not heard of any linux system not having ln anyway you should checking this section https://github.com/abandonware/noble#running-without-rootsudo-linux-specific

psdc-create commented 3 years ago

Thanks so much for your replies. I appreciate your time.

The link takes me to:

sudo setcap cap_net_raw+eip $(eval readlink -f which node) What I don't follow is this part of the command "$(eval readlink -f which node)”

I’ve tried a few options but no change.

I do wonder if my problems are because I’m running homebridge in a docker container?

Otherwise I’ve updated node to the most recent version and the same with noble. I think my rasperian installation is a new install (only reinstalled 3 days ago).

If it’s a container problem then it’s not really a bug…

Thanks again.

On 10 May 2021, at 4:59 pm, fishery @.***> wrote:

what system you're running? I've not heard of any linux system not having ln anyway you should checking this section https://github.com/abandonware/noble#running-without-rootsudo-linux-specific https://github.com/abandonware/noble#running-without-rootsudo-linux-specific — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fisherwise/homebridge-soma-shades/issues/6#issuecomment-836265241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT4FSCPG2UXIFDKSX6FOCDDTM575PANCNFSM44QJ4GZA.

mylylyl commented 3 years ago

not sure what you mean by $(eval readlink -f `which node`). it should return you the path of node executable (in this case /usr/bin/node) I haven't tried running homebridge in a docker container so I can't offer much help here. I would assume you need extra steps to pass bluetooth device into container

psdc-create commented 3 years ago

This is where things might be going astray - 'which node’ returns /home/pi/n/bin/node

Would this be the reason I cant get the plug-in to run.

On 10 May 2021, at 5:56 pm, fishery @.***> wrote:

not sure what you mean by $(eval readlink -f which node). it should return you the path of node executable (in this case /usr/bin/node) I haven't tried running homebridge in a docker container so I can't offer much help here. I would assume you need extra steps to pass bluetooth device into container

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fisherwise/homebridge-soma-shades/issues/6#issuecomment-836324677, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT4FSCKSB2AKHDOGUCIPRLLTM6GTBANCNFSM44QJ4GZA.

mylylyl commented 3 years ago

are you installing nodejs this way? still i would guess there are extra steps to "pass" bluetooth device into a docker container. Maybe try this command and see if you have bluetooth device: hcitool dev

psdc-create commented 3 years ago

Solved!

There are many discussions on the web about how to access bluetooth from within a docker container. Most are complex and largely unsuccessful it seems. It turns out that it is very easy in the case of your plug-in. It just requires changing the privileges to the node file (as described) but the commands need to be executed from within the homebridge container.

FYI. The steps are:

  1. Determine the path to the running node from within the homebridge container:

    docker exec -it my_hombridge_container which node

for me this returns: /usr/local/bin/node

(this is different to the path returned by “which node” when executed outside a container!)

  1. Set privileges for the returned file (might require sudo depending on user)

    docker exec -it my_hombridge_container setcap cap_net_raw+eip /usr/local/bin/node

  2. Reboot

Error message is gone and shades show instantly in the Home app.

It’s likely that the same thing could be achieved by setting up the appropriate privileges when the container is created but I don't want to go through setting up all my accessories again just to test this. The whole point of using containers is security, so the method above would seem the best option as it does not require giving unneeded privileges to the whole container.

Sorry to bug you with a false report.

On 13 May 2021, at 6:58 am, fishery @.***> wrote:

are you installing nodejs this way https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Raspbian#step-1-install-nodejs? still i would guess there are extra steps to "pass" bluetooth device into a docker container. Maybe try this command and see if you have bluetooth device: hcitool dev

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fisherwise/homebridge-soma-shades/issues/6#issuecomment-840092139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT4FSCM5RLKH4M2QEX45NXTTNLTX5ANCNFSM44QJ4GZA.

mylylyl commented 3 years ago

Glad you find a solution! I think it's very good as some other users may find it useful.