Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix port power setting #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pyunifi/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging

import requests
import urllib3
from urllib3.exceptions import InsecureRequestWarning


Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__( # pylint: disable=r0913
raise APIError("%s controllers no longer supported" % version)

if ssl_verify is False:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
warnings.simplefilter("default", category=InsecureRequestWarning)

self.log.debug("Controller for %s", self.url)
Expand Down Expand Up @@ -398,10 +400,10 @@ def _switch_port_power(self, target_mac, port_idx, mode):
overrides = device_stat.get("port_overrides")
found = False
if overrides:
for i in overrides:
if overrides[i]["port_idx"] == port_idx:
for o in overrides:
if o["port_idx"] == port_idx:
# Override already exists, update..
overrides[i]["poe_mode"] = mode
o["poe_mode"] = mode
found = True
break
if not found:
Expand Down