derek-miller / homebridge-unifi-smartpower

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

Make it easier to exclude entire devices from controllability via the UI #27

Closed aveach closed 1 year ago

aveach commented 1 year ago

Hi,

Great plugin, thanks so much for the work here!

Over the weekend Siri must've misheard a command and it turned off every PoE port throughout the house at about 1 am. Long story short, it was a huge pain to get everything back up and running as it wasn't immediately apparent that all the PoE ports were physically off.

Would be great to have an easier way to exclude entire devices from any power control at all (via cached devices in the config-ui maybe? Or ability to remove/disable in HomeKit itself?) rather than trying to track down all the specific strings/ids in the massive stream of logs.

Thanks again!

derek-miller commented 1 year ago

You can exclude entire devices using the excludeDevices config option. Just look in the logs during a restart for the following:

...
[UniFi SmartPower] Device [<DEVICE_ID>]: <DEVICE_NAME>
...

Then just add that to your config:

...
{
    "name": "UniFi SmartPower",
    "platform": "UniFiSmartPower",
    ...
    "excludeDevices": [
        "<DEVICE_ID>"
    ],
    ...
},
...
aveach commented 1 year ago

@derek-miller i realize there is a way to do this by rebooting, looking through logs, marking down ids, rewriting the config, then rebooting again...

It's convoluted and a bit tedious. This is a request for enhancement to make the process easier, hopefully through the UI.

derek-miller commented 1 year ago

You can paste in the id from the log using the settings UI. Making the settings UI aware of the discovered devices requires writing a custom settings UI plugin. I dont have the time to look into that right now, but it is possible.

image
aveach commented 1 year ago

Yup, I know you can paste into config-ui. Definitely nicer than editing the json itself, but still have to reboot, manually parse logs, paste into the config, reboot again, etc...

Thanks for looking into this. Understood it's likely not high priority. Not familiar with the HomeKit side, but is it easier to make it able to be disabled (or removed completely) from the HomeKit app itself?

derek-miller commented 1 year ago

There is no way to avoid the boot, load data, block, reboot pattern regardless if it’s in the UI or not. The plugin won’t know what’s there until it loads and homebridge does not propagate config changes so you have to reboot when it’s changed. This the only thing this feature would solve is the copy paste from the logs.

derek-miller commented 1 year ago

Ignoring the config stuff for a minute, in another plugin I added a “Disable Switch” feature that would add a switch to HomeKit and would control whether or not to ignore commands from the other accessories exposed by the plugin. I think this would be a better solution for your exact use case. You get to still have the ability to include all of your devices but require a second factor to be able to control them. Does that sound good to you? If so I can add this feature to this plugin.

aveach commented 1 year ago

Yeah, that sounds like it could work well! Thank you

derek-miller commented 1 year ago

I have added this as a opt-in config option in v1.1.0. Try it out and let me know if you have any questions/concerns.

derek-miller commented 1 year ago

Actually, I inverted the logic to the switch must be ON to allow control in v1.2.0. This way if it tries to turn everything OFF it can't inadvertently turn off the "disable" switch then proceed to turn everything else off.

aveach commented 1 year ago

Thanks for implementing Derek! It's definitely a nice feature to have, but I think I'll have to just parse the logs and exclude all the switches themselves. It's nice to block control, but it fully blocks control... I'd still like the SmartPower Plugs to have control (mostly used for lights, etc) just don't want switch ports randomly being taken down by an erroneous Siri command.

Appreciate the help here though!

derek-miller commented 1 year ago

Would be easy to configure it to block just switch ports vs outlets. Let me add that.

derek-miller commented 1 year ago

@aveach I have added the ability to configure if outlets and/or switch ports should be guarded by this switch in v1.3.0. Let me know if this solves your issues.

aveach commented 1 year ago

Looks like that works! I'm able to control the plugs as normal and the switch ports just give a "No Response" error when the UniFi Control Enable switch is off. LGTM thank you!