Kane610 / aiounifi

Asynchronous library to communicate with Unifi Controller
MIT License
57 stars 49 forks source link

Gateway Outlet Control #667

Open Nixon506E opened 1 month ago

Nixon506E commented 1 month ago

The ac outlet ports on the a gateway, such as the UXG should allow being cycled as if they were poe ports

Kane610 commented 1 month ago

Are there outlets on the UXG? How are they controlled?

Nixon506E commented 1 month ago

There is a single outlet on the back that shows up in the ports section of device info. It allows for automatic power cycling when the internet goes down or a manual power cycle.

Kane610 commented 1 month ago

Ok, you would have to provide complete data on how to control that output as I don't own a UXG, typically people use debug tools in a browser and figure out what commands and data is sent

Kane610 commented 1 month ago

https://community.home-assistant.io/t/unifi-next-gen-gateway-pro-outlet/700820

Nixon506E commented 1 month ago

Is it best just to see what calls are being made in the timeline or is there a more efficient way to get that data? I guess I'm not particularly sure what data you need or where to find it in the browser

Should I be looking for a call similar to poe cycling in devmgr? I see AC_OUTLET_POWER_CYCLE in the browser as well

Kane610 commented 1 month ago

You need to look at the network traces and find the correct calls, yes similar to devmgr

Nixon506E commented 1 month ago

Looks like the command to power cycle the outlet is a POST to /proxy/network/api/s/default/cmd/devmgr with the following body: {"mac":"xx:xx:xx:xx:xx:xx","outlet_table":[{"index":1}],"cmd":"outlet-ctl"}

Nixon506E commented 1 month ago

The GET to /proxy/network/api/s/default/stat/device responds with the following data to get info about the outlet: "outlet_table": [ { "index": 1, "name": "Outlet 1", "outlet_caps": 65537, "relay_state": true, "cycle_enabled": true } ]

Nixon506E commented 1 month ago

The outlet can be turned on and off with a PUT to /proxy/network/api/s/default/rest/device/xxxxxx with the following body: {"outlet_overrides":[{"index":1,"name":"Outlet 1","cycle_enabled":true,"relay_state":false}]} and it responds with the device configuration

Nixon506E commented 2 weeks ago

Would love to get an update on what next steps might be here, thanks!