homebridge / homebridge-config-ui-x

The Homebridge UI. Monitor, configure and backup Homebridge from a browser.
https://homebridge.io
MIT License
2.61k stars 372 forks source link

custom ui path not recognised #1379

Closed thieren closed 2 years ago

thieren commented 2 years ago

Describe The Bug

Hi!

I'm working with the homebridge-eufy-security team and have recently redesigned the custom ui screen which utilises plugin-ui-utils. As mentioned here it should be possible to set a custom path to the ui through config.schema.json but for me this setting is ignored. It always falls back to the default ./homebridge-ui/public/index.html I looked briefly at the source and found that this setting is read in this repo rather then plugin-ui-utils, so I've opened an issue here.

An example branch can be found here

Let me know if the issue lies somewhere else.

Logs

[9.7.2022, 10:00:15] [Homebridge UI] [homebridge-eufy-security] ENOENT: no such file or directory, open '/usr/lib/node_modules/homebridge-eufy-security/homebridge-ui/public/index.html'

Config

{
  "pluginAlias": "EufySecurity",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./dist/homebridge-ui"
}

Homebridge UI Version

4.49.0

Homebridge Version

1.5.0

Node.js Version

16.13.0

Operating System

Ubuntu / Debian (or a variant)

Environment Info

Raspberry Pi Model

No response

oznu commented 2 years ago

It seems to be working when I build the plugin locally:

image

The UI may aggressively cache the customUiPath - please make sure you've tried to do a full restart of Homebridge UI (Drop down menu top right -> Homebridge Settings -> Force Service Restart).

oznu commented 2 years ago

I did initially get this error, but it's unrelated to the problem you were facing:

[09/07/2022, 18:28:54] [Homebridge UI] [homebridge-eufy-security] node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '../package.json'
Require stack:
- /Users/xxxxx/src/homebridge/Homebridge-eufy-plugin/dist/homebridge-ui/server.js

After fixing that it loaded fine.

thieren commented 2 years ago

Thx for your fast feedback.

The UI may aggressively cache the customUiPath - please make sure you've tried to do a full restart of Homebridge UI (Drop down menu top right -> Homebridge Settings -> Force Service Restart).

Force restart did help. But didn't realise that there is a difference to normal restart before. This way I don't think it's suitable for our plugin since most users would face this issue. (we used default path before, but the new path would suit our new workspace structure better).

Could the path caching be reset on normal restart?

oznu commented 2 years ago

The cache is per version of the plugin, and since you can't publish the same version twice, it will never be an issue in the real world.

oznu commented 2 years ago

My last comment may not be correct sorry.

oznu commented 2 years ago

Expecting users to also update the UI might be an issue, you can probably get away with creating a symlink from ./homebridge-ui to ./dist/homebridge-ui and publishing it as part of the package:

ln -s dist/homebridge-ui homebridge-ui
thieren commented 2 years ago

But wouldn't users running homebridge on windows have problems with symlinks?

oznu commented 2 years ago

Probably, but you're looking at less than 2% of total Homebridge users who run on Windows natively.

Fixed in 4.49.1-test.1

thieren commented 2 years ago

Wow. Thx for the fast fix!

oznu commented 2 years ago

I forgot to mention this yesterday. You should probably move the Angular and other UI dependencies to devDependencies, as once the bundle is created you don't need these at run time, and making your users install all these packages alongside your plugin will just slow things down.

https://github.com/thieren/Homebridge-eufy-plugin/blob/customUiPath/package.json#L37

thieren commented 2 years ago

I forgot to mention this yesterday. You should probably move the Angular and other UI dependencies to devDependencies, as once the bundle is created you don't need these at run time, and making your users install all these packages alongside your plugin will just slow things down.

https://github.com/thieren/Homebridge-eufy-plugin/blob/customUiPath/package.json#L37

Yeah you're likely right. I just used the default dependencies generated by ng new when creating a new angular app. But will look into it and move the dependencies not needed. Thx!