From e3ebb06b41a5c62483697532cbbbb4948090d712 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Fri, 7 Jan 2022 19:01:48 +0100 Subject: [PATCH] Fix port power setting Also fixes suppressing the TLS warning. Closes #67. --- pyunifi/controller.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyunifi/controller.py b/pyunifi/controller.py index aafc9a2..dcee2de 100644 --- a/pyunifi/controller.py +++ b/pyunifi/controller.py @@ -8,6 +8,7 @@ import logging import requests +import urllib3 from urllib3.exceptions import InsecureRequestWarning @@ -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) @@ -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: