derek-miller / homebridge-unifi-smartpower

Homebridge UniFi SmartPower Plugin
Apache License 2.0
7 stars 1 forks source link

Unifi Controllers with multiple Sites? #18

Closed StephenShamakian closed 1 year ago

StephenShamakian commented 1 year ago

I have configured this plugin using a local account with a cloud hosted Unifi Controller from Hostifi. This controller has multiple sites. So I'm thinking this may be why this plugin isn't seeing the power strip in one of my sites?

Logs:

[1/20/2023, 5:12:06 AM] [UniFi SmartPower] Initializing UniFiSmartPower platform...
[1/20/2023, 5:12:06 AM] [UniFi SmartPower] Initializing child bridge 0E:51:AE:A0:A3:C7

Plugin Config:

{
    "name": "UniFi SmartPower",
    "host": "HOST-HERE",
    "port": PORT-HERE,
    "username": "USER-HERE",
    "password": "PASSWORD-HERE",
    "refreshDevicesPollInterval": 600,
    "outletStatusCacheTtl": 15,
    "outletStatusPollInterval": 15,
    "platform": "UniFiSmartPower",
    "_bridge": {
        "username": "0E:51:AE:A0:A3:C7",
        "port": 36658
    }
}

Screenshots:

Environment:

derek-miller commented 1 year ago

Hmm, I have no way to test a remote controller from hostifi to confirm as I have local controllers. Im using the node-unifi library and it doesn't mention support for hostifi.

StephenShamakian commented 1 year ago

Hello @derek-miller,

So Hostifi vs. local Unifi controllers is really the same thing. As I am able to connect to my controller fine with this plugin (no errors). I think the problem is if you have multiple sites in your Unifi Controller this plugin fails to find the devices in the various sites.

Looking at node-unifi the example they have in their readme file shows how to load site's then the devices in that site. So I'm pretty sure node-unifi is cable of loading specific sites? Maybe a configuration param to load a specific site or comma delimited list of site IDs then get the devices under that site?

image

derek-miller commented 1 year ago

Yeah, I just looked at the code. Its only looking at the default site right now. I will add an option for configuring included/excluded sites.

derek-miller commented 1 year ago

Can you upgrade to v1.0.3-beta.0 and see if it works for you?

StephenShamakian commented 1 year ago

That worked! Thank you! I can now see POE devices and the USP-Strip in my network's site! :) I added the "includeSites" parameter to just include my site vs. the others.

derek-miller commented 1 year ago

Awesome. I will give it an official release sometime later today. Thanks for bringing this to my attention.

StephenShamakian commented 1 year ago

Are these changes in v1.0.4? I don't see them in the Changelog. Should I hold off upgrading until this is merged into master?

derek-miller commented 1 year ago

The changes landed in the v1.0.3 beta and are included in the v1.0.4 release. I will fix the release notes