How do we start @neeo/cli on Raspberry Pi startup?

Michael Vogt

I've tried to create a systemd service file (neeo_cli.service) with the following contents saved in /etc/systemd/system/:

[Unit]
Description=Node.js Neeo HomeKit Driver
After=syslog.target network-online.target

[Service]
Type=simple
User=pi
ExecStart=/usr/local/lib/npx neeo-cli start
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

But I get the following error in systemctl logs when I start the neeo_cli service: Error: ENOENT: no such file or directory, scandir '/etc/systemd/system/node_modules'

The folder where my driver is located: /usr/local/lib/node_modules/neeo-driver-homekit

I can get it to run if I execute 'npx neeo-cli start' from /usr/local/lib.

Reply
2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Contents of driver folder (/usr/local/lib/node_modules/neeo-driver-homekit):

    - package.json

    -index.js

    -controller.js

    Contents of package.json:

    {
      "name": "neeo-driver-homekit",
      "version": "0.0.1",
      "description": "NEEO driver to trigger HomeKit scenes",
      "main": "index.js",
      "scripts": {
        "test": "node index.js"
      },
      "repository": {
        "type": "git"
      },
      "keywords": [
        "neeo",
        "neeo-driver",
        "homekit",
        "homebridge"
      ],
      "author": "Humayun Hasan",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.0",
        "homebridge": ">=0.2.0"
      },
      "dependencies": {
        "request": "^2.83.0",
        "url": "^0.11.0",
        "ws": "^3.2.0",
        "neeo-sdk": "*"
      }
    }

    Reply Like
  • Solved it myself but this is more of a hack rather than a proper neeo-cli implementation.

    First, I created a shell script and saved it in /usr/local/lib (I think the script can be saved anywhere, it just needs to have executable permissions):

    #!/bin/bash

    cd /usr/local/lib
    npx neeo-cli start

     

    Then, I call this script from the neeo_cli.service file for systemd:

    [Unit]
    Description=Node.js Neeo HomeKit Driver
    After=syslog.target network-online.target 

    [Service]
    Type=simple
    User=pi
    ExecStart=/usr/local/lib/npx neeo-cli start
    Restart=on-failure
    RestartSec=10
    KillMode=process 

    [Install]
    WantedBy=multi-user.target

     

    Now, you just need the following three commands:

    sudo systemctl daemon-reload

    sudo systemctl enable neeo_cli

    sudo systemctl start neeo_cli

    If all went fine, neeo-cli should run your drivers after each reboot of the Pi or if your driver encounters an issue and crashes. To check status or see other messages, you can try either of the following two commands:

    systemctl status neeo_cli

    sudo journalctl -u neeo_cli

    Reply Like
reply to topic
Like Follow