gismo141 / homebridge-server

Server plugin for homebridge
https://gismo141.github.io/configure-your-homebridge-2/
152 stars 20 forks source link

Server does not find config.json, if location is specified with --user-storage-path #13

Closed David-Noble-at-work closed 7 years ago

David-Noble-at-work commented 7 years ago

If the directory containing config.json is specified with -U, life is good: homebridge starts. Otherwise, if the directory containing config.json is specified with --user-storage-path, homebridge fails to start because homebridge-server raises an exception.

Here are the relevant log entries:

[12/18/2016, 12:00:04 AM] Loaded plugin: homebridge-harmonyhub
[12/18/2016, 12:00:05 AM] Registering platform 'homebridge-harmonyhub.HarmonyHub'
[12/18/2016, 12:00:05 AM] ---
[12/18/2016, 12:00:07 AM] Loaded plugin: homebridge-nest
[12/18/2016, 12:00:07 AM] Registering platform 'homebridge-nest.Nest'
[12/18/2016, 12:00:07 AM] ---
[12/18/2016, 12:00:07 AM] Loaded plugin: homebridge-server
[12/18/2016, 12:00:07 AM] Registering platform 'homebridge-server.Server'
[12/18/2016, 12:00:07 AM] ---
[12/18/2016, 12:00:07 AM] Loaded config.json with 0 accessories and 3 platforms.
[12/18/2016, 12:00:07 AM] ---
[12/18/2016, 12:00:07 AM] Loading 3 platforms...
[12/18/2016, 12:00:07 AM] [Harmony Hub] Initializing HarmonyHub platform...
[12/18/2016, 12:00:07 AM] Initializing Nest platform...
[12/18/2016, 12:00:07 AM] Fetching Nest devices.
[12/18/2016, 12:00:07 AM] [Homebridge Server] Initializing Server platform...
[12/18/2016, 12:00:07 AM] [Homebridge Server] !!!
[12/18/2016, 12:00:07 AM] [Homebridge Server] !!!
[12/18/2016, 12:00:07 AM] [Homebridge Server] ERROR: No 'config.json' found!
[12/18/2016, 12:00:07 AM] [Homebridge Server] Please specify the path of your 'config.json'! E.g.: '-U /home/pi/.homebridge'
David-Noble-at-work commented 7 years ago

So no comment then?

gismo141 commented 7 years ago

Sorry David! I instantly fixed that issue when I saw it :(

It should work now either by using the -U or --user-storage-path.

David-Noble-at-work commented 7 years ago

Thank you :)

Sent from my iPhone

On Dec 18, 2016, at 8:34 AM, Michael Riedel notifications@github.com<mailto:notifications@github.com> wrote:

Sorry David! I instantly fixed that issue when I saw it :(

It should work now either by using the -U or --user-storage-path.

- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/gismo141/homebridge-server/issues/13#issuecomment-267831067, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AC5Zr14mQKEaLFiAB0QEycG7yE9A_swIks5rJWCagaJpZM4LQE0-.

cms365 commented 7 years ago

Hi! I'm running into the same issue. Apologies, but could you provide a bit more detail to what you mean by using -U or -user-storage-path? When exactly do you refence these? I ran the install as documented in your readme. Appreciate your help, I'm new to these kind of things and trying to learn.

David-Noble-at-work commented 7 years ago

Yes, when you start homebridge you can specify a path to the directory containing your config.json file. Home bridge will the use that directory to fetch and then later store information about the accessories bound to it. On Linux systems--if you are running homebridge as a system service--a good place to keep this information is '/usr/local/etc/homebridge'. I can go into this more deeply, if you like.

Here is a sample command line from my Armbian service setup:

homebridge --user-storage-path /usr/local/etc/homebridge
David-Noble-at-work commented 7 years ago

Issue this command to get the full list of options:

homebridge --help

I hope this helps.

gismo141 commented 7 years ago

If you prefer, I could change the way to retrieve the path. For example instead of requesting it as a commandline parameter with the -U or the --user-storage-path switch, I also could ask the user to write the path into the config.json-file itself.

However I find the second approach a little bit cumbersome but if it is easier to understand, why not ;)

What would you prefer?

gismo141 commented 7 years ago

Using the command line parameter:

homebridge -U /usr/local/etc/homebridge
gismo141 commented 7 years ago

Or adding it to the config:

{
    "platform": "Server",
    "port": 8765,
    "name": "Homebridge Server",
    "log" : "systemd",
    "config" : "/usr/local/etc/homebridge"
}
David-Noble-at-work commented 7 years ago

I would actually prefer that homebridge provide a stable API for you to call. It seems odd to require that an end user tell homebridge and then also tell homebridge-server by way of config.json where config.json is located.

Parsing the command line is better but not as good as a stable API. This would allow, for example, homebridge to change the mechanism for finding config.json without affecting plugins who wish to access it.

Sent from my iPhone

On Dec 18, 2016, at 10:23 PM, Michael Riedel notifications@github.com<mailto:notifications@github.com> wrote:

If you prefer, I could change the way to retrieve the path. For example instead of requesting it as a commandline parameter with the -U or the --user-storage-path switch, I also could ask the user to write the path into the config.json-file itself.

However I find the second approach a little bit cumbersome but if it is easier to understand, why not ;)

What would you prefer?

- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/gismo141/homebridge-server/issues/13#issuecomment-267890712, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AC5Zr_M63R_lkZTP6_eLY19YHmZLTjChks5rJiLegaJpZM4LQE0-.

gismo141 commented 7 years ago

I totally agree with that - an API would be much better. At the moment I've implemented both solutions, hopefully it helps most people until this system gets more professional. Maybe I'll have a look at the "homebridge"-project itself and provide an API-access for the config.json.

farstreet commented 7 years ago

So adding "config" : "/usr/local/etc/homebridge" will work now too? Assuming that that is the right path for me of course. I find that easier personally :)

gismo141 commented 7 years ago

Yes I've implemented both possibilities but I totally agree with @David-Noble-at-work that it is double-work.

Note to myself: I really have to document these things better :)

gismo141 commented 7 years ago

@David-Noble-at-work and @farstreet I haven't looked deep enough!

In fact Homebridge already provides a way to retrieve the config.json. I already updated my code so no one needs to add the path to the config itself!

David-Noble-at-work commented 7 years ago

Thank you :)

AchimPieters commented 7 years ago

Keep up the good work!