vniehues / homebridge-linak

Apache License 2.0
18 stars 2 forks source link

ModuleNotFoundError: No module named 'idasen_controller' #3

Closed mvbeust closed 2 years ago

mvbeust commented 2 years ago

Describe The Bug:

When trying to connect to the desk, I receive the following error:

[Linak Platform] polling error: Error: Command failed: /home/pi/.local/bin/idasen-controller --mac-address C6:A4:04:A3:A3:FA --base-height undefined --movement-range undefined
Traceback (most recent call last):
  File "/home/pi/.local/bin/idasen-controller", line 6, in <module>
    from idasen_controller.main import init
ModuleNotFoundError: No module named 'idasen_controller'

    at ChildProcess.exithandler (node:child_process:397:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '/home/pi/.local/bin/idasen-controller --mac-address C6:A4:04:A3:A3:FA --base-height undefined --movement-range undefined'

Controlling the desk from the command line with idasen-controller works without any issues

To Reproduce: The error happens on startup of homebridge with an idasen desk configured

Expected behavior:

The controller should be able to connect to the desk

Logs:

[Linak Platform] polling error: Error: Command failed: /home/pi/.local/bin/idasen-controller --mac-address C6:A4:04:A3:A3:FA --base-height undefined --movement-range undefined
Traceback (most recent call last):
  File "/home/pi/.local/bin/idasen-controller", line 6, in <module>
    from idasen_controller.main import init
ModuleNotFoundError: No module named 'idasen_controller'

    at ChildProcess.exithandler (node:child_process:397:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Pipe.<anonymous> (node:net:687:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '/home/pi/.local/bin/idasen-controller --mac-address C6:A4:04:A3:A3:FA --base-height undefined --movement-range undefined'

Plugin Config:

       {
            "name": "Linak Platform",
            "pollingRate": 20,
            "idasenControllerPath": "/home/pi/.local/bin/idasen-controller",
            "desks": [
                {
                    "name": "Desk",
                    "macAddress": "C6:A4:04:A3:A3:FA"
                }
            ],
            "platform": "LinakController"
        }

Environment:

vniehues commented 2 years ago

Hi @mvbeust :) "ModuleNotFoundError" sounds like you didn't configure the correct path to the idasen-controller. You need to make sure that the path in the config actually points to the idasen-controller executable.

vniehues commented 2 years ago

You can easily find the path with the following steps:

Please report back if that fixed it

mvbeust commented 2 years ago

Thanks, indeed, package was installed and not accessible from homebridge. Works now, thanks! And the undefined values are also fixed since the latest update.

On Sat, Jan 22, 2022, 13:35 Vincent Niehues @.***> wrote:

You can easily find the path with the following steps:

  • log in with the user that can execute the script.
  • run the idasen-controller to confirm it works
  • enter this command: which idasen-controller
  • copy the path to your config file

ā€” Reply to this email directly, view it on GitHub https://github.com/vniehues/homebridge-linak/issues/3#issuecomment-1019236230, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCBKM3G4ESABFAK4BKZ7GTUXKQCVANCNFSM5MR4G3UA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

vniehues commented 2 years ago

Perfect! :) I'm going to close this. If you face any other problems please feel free to open another issue

Nepomucene commented 2 years ago

@mvbeust How did you fix that? The package is installed, at the specified location, and works when started from the command line. But I get the same error from homebridge! Thanks

Nepomucene commented 2 years ago

@vniehues Could you assist here? From the logs in Homebridge, I see:

[Linak Platform] polling error: Error: Command failed: /home/pi/.local/bin/idasen-controller --mac-address FF:11:18:9A:56:13 --base-height 626 --movement-range 650 Traceback (most recent call last): File "/home/pi/.local/bin/idasen-controller", line 6, in from idasen_controller.main import init ModuleNotFoundError: No module named 'idasen_controller' at ChildProcess.exithandler (child_process.js:383:12) at ChildProcess.emit (events.js:400:28) at maybeClose (internal/child_process.js:1058:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) { killed: false, code: 1, signal: null, cmd: '/home/pi/.local/bin/idasen-controller --mac-address FF:11:18:9A:56:13 --base-height 626 --movement-range 650'}

But if I copy/paste into the command line of my raspi over SSH:

pi@Pi-Hole:~ $ /home/pi/.local/bin/idasen-controller --mac-address FF:11:18:9A:56:13 --base-height 626 --movement-range 650 Connected FF:11:18:9A:56:13 Height: 780mm Disconnected

Homebridge and idasen-controller are obvioulsy on the same raspi, and idasen-controller works properly when launched from the command line...

vniehues commented 2 years ago

@Nepomucene I think the next troubleshooting step would be to run that command from the homebridge Terminal to check if homebridge is allowed to access the command.

To do that open the config ui in a browser and open the terminal from the menu in the top right corner.

Please report back your findings.

Nepomucene commented 2 years ago

@vniehues Bingo. That is the problem

homebridge@Pi-Hole:/var/lib/homebridge $ /home/pi/.local/bin/idasen-controller --mac-address FF:11:18:9A:56:13 --base-height 626 --movement-range 650 Traceback (most recent call last): File "/home/pi/.local/bin/idasen-controller", line 6, in from idasen_controller.main import init ModuleNotFoundError: No module named 'idasen_controller' homebridge@Pi-Hole:/var/lib/homebridge $

The question is how do I fix that? How do I allow user "homebridge" to run a script on my raspi? My linux days are 20-25 years ago :-(

vniehues commented 2 years ago

I'm not a linux guy either haha. I would try to google my way around that problem or install Idasen-Controller as the homebridge user.

But please report back if and how you fixed it. I would like to add some troubleshooting steps to the readme šŸ‘šŸ¼

Nepomucene commented 2 years ago

Problem solved!! Issue is indeed that idasen-controller needs to be installed as "homebridge" But before that, a couple of files/directories have to have their ownership transfered from root to homebridge => Log into the raspi via ssh as root/pi cd /home/homebridge/ sudo chown homebridge .cache cd .cache sudo chown homebridge node-gyp

Then you can install "idasen-controller" as "homebridge" For that open the config ui in a browser and open the terminal from the menu in the top right corner. /usr/bin/python3 -m pip install idasen_controller

I then launched the scipt in the same terminal: /home/homebridge/.local/bin/idasen-controller --mac-address FF:11:18:9A:56:13 --base-height 626 --movement-range 650 Connected FF:11:18:9A:56:13 Height: 780mm Disconnected

Hope it works for others too!