homebridge-harmonyhub icon indicating copy to clipboard operation
homebridge-harmonyhub copied to clipboard

Working in standalone homebridge but not in systemd

Open guiggess opened this issue 7 years ago • 24 comments

Hello,

I recently added the HarmonyHub platform.

I had to change permission to NPM by following the Option 2 in this tutorial

I modified the config.json find under ~/.homebridge/config.json like so :

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:37",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "excludedDevices": []
        },
        {
            "platform": "HarmonyHub",
            "name": "Harmony Hub"
        }
    ],
    "accessories": []
}

When I launch Homebridge by typing homebridge, everything works like a charm.

BUT

I always used Homebridge like a system daemon by following the wiki tutorial.

I did cp the config.json above in /var/lib/homebridge/config.json

When I sudo systemctl restart home bridge.service I get an error in the journal : "The requested platform '" + name + "' was not registered by any plugin."

I would like to add that it works when I remove the HarmonyHub platform.

Any thoughts ?

guiggess avatar Sep 30 '17 19:09 guiggess

Did you install the Harmony plugin by using the -g operator? It looks like you have installed it "locally" so it will not be found by the system daemon. Try the following:

# This should not work - if it uninstalls it was locally installed
npm uninstall homebridge-harmonyhub

# Try to install it global
npm install -g homebridge-harmonyhub

# If it still not works you can try also
npm install -g --unsafe -perm homebridge-harmonyhub

ramsnerm avatar Oct 01 '17 17:10 ramsnerm

Hi,

Thanks for the reply. I did try to uninstall locally without any success. I uninstalled globally and then tried both installation commands (and uninstalling again in between).

I still have the same error...

guiggess avatar Oct 01 '17 18:10 guiggess

Another "weird" thing is that when I npm list -g I only see the harmonyhub platform but not the edomoticz one (which is working)...

guiggess avatar Oct 01 '17 18:10 guiggess

Having the exact same problem as @guiggess . Installing globally or even with --unsafe -perm did not fix it.

drewthor avatar Oct 02 '17 04:10 drewthor

I see this error in the homebridge logs:

/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:243 throw new Error("Cannot update reachability on non-bridged accessory!"); ^

Error: Cannot update reachability on non-bridged accessory! at Accessory.updateReachability (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:243:11) at PlatformAccessory.updateReachability (/usr/local/lib/node_modules/homebridge/lib/platformAccessory.js:129:34) at ActivityAccessory.refreshConnection (/usr/local/lib/node_modules/homebridge-harmonyhub/lib/hub-accessory-base.js:56:17) at emitOne (events.js:101:20) at HubConnection.emit (events.js:188:7) at HubConnection._OnConnectionChanged (/usr/local/lib/node_modules/homebridge-harmonyhub/lib/hub-connection.js:151:7) at HubConnection.refreshAsync (/usr/local/lib/node_modules/homebridge-harmonyhub/lib/hub-connection.js:140:7) at HubConnection.refresh (/usr/local/lib/node_modules/homebridge-harmonyhub/lib/hub-connection.js:132:7) at HubConnection._HandleConnectionOffline (/usr/local/lib/node_modules/homebridge-harmonyhub/lib/hub-connection.js:127:14) at emitNone (events.js:86:13) at Client.emit (events.js:185:7) at Client. (/usr/local/lib/node_modules/homebridge-harmonyhub/node_modules/node-xmpp-client/lib/Client.js:157:12) at emitOne (events.js:101:20) at Connection.emit (events.js:188:7) at Socket.onDisconnect (/usr/local/lib/node_modules/homebridge-harmonyhub/node_modules/reconnect-core/index.js:59:17) at emitNone (events.js:91:20)

All of my accessories show as "No Response" despite confirming that Homebridge is running

drewthor avatar Oct 02 '17 05:10 drewthor

Reverting back to version 0.1.1 resolved this issue for me.

drewthor avatar Oct 14 '17 01:10 drewthor

And how do you do that ?

guiggess avatar Oct 14 '17 08:10 guiggess

npm install -g [email protected]

ToddGreenfield avatar Oct 14 '17 08:10 ToddGreenfield

I had no chance trying to install v0.1.1.

I still don't have a working Harmony under systemd daemon

guiggess avatar Oct 29 '17 13:10 guiggess

@guiggess I am using the same method you did (above) to change the location of the npm-global location (all my plugins get installed with the -g flag). I am thinking you are running into a permissions issue still. Be sure permissions for both the npm-global directory (and all recursively) and the /var/lib/homebridge directory are correct for the user you are running homebridge as defined in the homebridge.service config files. I run homebridge with a service account "homebridge", but my "pi" user owns most files... so also check all group permissions as well if you are doing that. (It also looks like you had a space in the command above "home bridge" but that could just be a typo...)

ToddGreenfield avatar Oct 31 '17 10:10 ToddGreenfield

@ToddGreenfield I did chmod -R 777 ~/.npm-global and chmod -R 777 /var/lib/homebridge without any success...

guiggess avatar Nov 03 '17 21:11 guiggess

@guiggess lets see your home bridge.service and homebridge (/etc/default) files. May also not be using the correct config.json file... see how many you have.. (sudo find / -name config.json) and look to be sure you have the platform defined in them... eventually you want to remove if more than the right ones...

ToddGreenfield avatar Nov 04 '17 15:11 ToddGreenfield

@ToddGreenfield here are my findings : pi@raspberrypi:~ $ sudo nano /etc/default/homebridge

# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file an$
HOMEBRIDGE_OPTS=-U /var/lib/homebridge

# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*

pi@raspberrypi:~ $ sudo nano /etc/systemd/system/homebridge.service

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

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
# Adapt this to your specific setup (could be /usr/bin/homebridge)
# See comments below for more information
ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

I have one (working) config.json file under pi@raspberrypi:~ $ sudo nano /var/lib/homebridge/config.json

 {
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:39",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "excludedDevices": []
        }
    ],
    "accessories": []
}

and one (non-working) config.json.new file under pi@raspberrypi:~ $ sudo nano /var/lib/homebridge/config.json.new

 {
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:36",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "excludedDevices": []
        },
        {
            "platform": "HarmonyHub",
            "name": "Harmony Hub"
        }
    ],
    "accessories": []
}

guiggess avatar Nov 05 '17 09:11 guiggess

I also have one (working, but only when I launch Homebridge manually) config.json file under pi@raspberrypi:~/.homebridge $ sudo nano ~/.homebridge/config.json

 {
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:37",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "excludedDevices": []
        },
        {
            "platform": "HarmonyHub",
            "name": "Harmony Hub"
        }
    ],
    "accessories": []
}

guiggess avatar Nov 05 '17 09:11 guiggess

Hello there, It's been a long time a try to fix this issue without any success. Today, I tried a completely fresh install on a new SD card. And I have the same behavior. Working standalone, but not as a service. I start to think that there are no solution :-(

guiggess avatar Dec 23 '17 20:12 guiggess

@guiggess I tried everything to get systemctl to start homebridge. I finally just used the init.d method. It took 2 minutes and works.

foomanshoe avatar Jan 14 '18 06:01 foomanshoe

@foomanshoe For my issue, it looks like HarmonyHub isn't installed in the same directory. So I created a symlink between the "normal" location and the actual one, and it worked !

guiggess avatar Jan 17 '18 12:01 guiggess

@guiggess You got this working now with the latest version? I’d also be interested to know how long this hub works for you. Whenever I run this hub all of my activities become unreachable/unusable after a couple days

drewthor avatar Jan 17 '18 16:01 drewthor

@aturn3 So, here is the complete process that I followed for making homebridge-harmonyhub work : Install Raspbian Lite (https://www.raspberrypi.org/downloads/raspbian/)


Install Domoticz

  • sudo curl -L install.domoticz.com | sudo bash

Install Homebridge :

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get dist-upgrade
  • sudo reboot
  • sudo apt-get install git make
  • curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash
  • sudo apt-get install -y nodejs
  • sudo apt-get install libavahi-compat-libdnssd-dev
  • sudo npm install -g --unsafe-perm homebridge
  • https://timleland.com/setup-homebridge-to-start-on-bootup/

Install homebridge-edomoticz

  • sudo npm install -g homebridge-edomoticz

Change NPM permissions :

  • mkdir ~/.npm-global
  • npm config set prefix '~/.npm-global'
  • export PATH=~/.npm-global/bin:$PATH
  • source ~/.profile

Install homebridge-harmonyhub :

  • npm install -g homebridge-harmonyhub

Create a symlink :

  • sudo ln -s ~/.npm-global/lib/node_modules/homebridge-harmonyhub/ /usr/lib/node_modules/homebridge-harmonyhub

Edit config.json :

  • sudo nano /var/lib/homebridge/config.json
{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:37",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 0,
            "excludedDevices": []
        },
        {
            "platform": "HarmonyHub",
            "name": "Harmony Hub"
        }
    ],
    "accessories": []
}

ENJOY !

PS : I should give a try by changing NPM permissions before installing anything.

guiggess avatar Jan 25 '18 09:01 guiggess

Oh, and BTW, if nothing works, you can still add the HarmonyHub inside Domoticz and have it available in HomeKit that way.

guiggess avatar Jan 25 '18 09:01 guiggess

None got a solution for this? I have no idea how to get my home bridge pi to auto boot and with a functional harmony plugin. Works standalone but not as service

malmentm avatar Mar 05 '18 21:03 malmentm

@foomanshoe how did you do that? I also tried but get exactly the same results, it seem to work and I can flip the switches but nothing happens. If I start the service manually (init.d) it does work if I delete the cached accessory file. But never works after a reboot even though the service starts.

malmentm avatar Mar 05 '18 22:03 malmentm

@malmentm I succeeded by following the sequence posted above

guiggess avatar Mar 06 '18 06:03 guiggess

i had the same issue because of the same root cause posted by guiggess.

I had to find the location of the harmony-hub installation and create a symlink from /usr/lib/node_modules/ to the location of the homebridge-harmonyhub folder

flipside786 avatar Sep 06 '18 01:09 flipside786