Update method names reflecting changes in UniFi library (#64817)

* Update method names

* Bump dependency to v30
This commit is contained in:
Robert Svensson 2022-01-24 08:50:08 +01:00 committed by GitHub
parent a65a0b5903
commit 76bfbbafe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 27 deletions

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/unifi", "documentation": "https://www.home-assistant.io/integrations/unifi",
"requirements": [ "requirements": [
"aiounifi==29" "aiounifi==30"
], ],
"codeowners": [ "codeowners": [
"@Kane610" "@Kane610"
@ -22,7 +22,7 @@
{ {
"manufacturer": "Ubiquiti Networks", "manufacturer": "Ubiquiti Networks",
"modelDescription": "UniFi Dream Machine SE" "modelDescription": "UniFi Dream Machine SE"
} }
], ],
"iot_class": "local_push" "iot_class": "local_push"
} }

View File

@ -74,7 +74,7 @@ async def async_reconnect_client(hass, data) -> None:
): ):
continue continue
await controller.api.clients.async_reconnect(mac) await controller.api.clients.reconnect(mac)
async def async_remove_clients(hass, data) -> None: async def async_remove_clients(hass, data) -> None:

View File

@ -136,9 +136,9 @@ def add_poe_entities(controller, async_add_entities, clients, known_poe_clients)
# If poe_enable is False we can't know if a POE client is available for control. # If poe_enable is False we can't know if a POE client is available for control.
if mac not in known_poe_clients and ( if mac not in known_poe_clients and (
mac in controller.wireless_clients mac in controller.wireless_clients
or client.sw_mac not in devices or client.switch_mac not in devices
or not devices[client.sw_mac].ports[client.sw_port].port_poe or not devices[client.switch_mac].ports[client.switch_port].port_poe
or not devices[client.sw_mac].ports[client.sw_port].poe_enable or not devices[client.switch_mac].ports[client.switch_port].poe_enable
or controller.mac == client.mac or controller.mac == client.mac
): ):
continue continue
@ -153,8 +153,8 @@ def add_poe_entities(controller, async_add_entities, clients, known_poe_clients)
if ( if (
client2.is_wired client2.is_wired
and client.mac != client2.mac and client.mac != client2.mac
and client.sw_mac == client2.sw_mac and client.switch_mac == client2.switch_mac
and client.sw_port == client2.sw_port and client.switch_port == client2.switch_port
): ):
multi_clients_on_port = True multi_clients_on_port = True
break break
@ -199,7 +199,7 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchEntity, RestoreEntity):
super().__init__(client, controller) super().__init__(client, controller)
self.poe_mode = None self.poe_mode = None
if client.sw_port and self.port.poe_mode != "off": if client.switch_port and self.port.poe_mode != "off":
self.poe_mode = self.port.poe_mode self.poe_mode = self.port.poe_mode
async def async_added_to_hass(self): async def async_added_to_hass(self):
@ -214,10 +214,10 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchEntity, RestoreEntity):
self.poe_mode = state.attributes.get("poe_mode") self.poe_mode = state.attributes.get("poe_mode")
if not self.client.sw_mac: if not self.client.switch_mac:
self.client.raw["sw_mac"] = state.attributes.get("switch") self.client.raw["sw_mac"] = state.attributes.get("switch")
if not self.client.sw_port: if not self.client.switch_port:
self.client.raw["sw_port"] = state.attributes.get("port") self.client.raw["sw_port"] = state.attributes.get("port")
@property @property
@ -235,26 +235,26 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchEntity, RestoreEntity):
return ( return (
self.poe_mode is not None self.poe_mode is not None
and self.controller.available and self.controller.available
and self.client.sw_port and self.client.switch_port
and self.client.sw_mac and self.client.switch_mac
and self.client.sw_mac in self.controller.api.devices and self.client.switch_mac in self.controller.api.devices
) )
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
"""Enable POE for client.""" """Enable POE for client."""
await self.device.async_set_port_poe_mode(self.client.sw_port, self.poe_mode) await self.device.set_port_poe_mode(self.client.switch_port, self.poe_mode)
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs):
"""Disable POE for client.""" """Disable POE for client."""
await self.device.async_set_port_poe_mode(self.client.sw_port, "off") await self.device.set_port_poe_mode(self.client.switch_port, "off")
@property @property
def extra_state_attributes(self): def extra_state_attributes(self):
"""Return the device state attributes.""" """Return the device state attributes."""
attributes = { attributes = {
"power": self.port.poe_power, "power": self.port.poe_power,
"switch": self.client.sw_mac, "switch": self.client.switch_mac,
"port": self.client.sw_port, "port": self.client.switch_port,
"poe_mode": self.poe_mode, "poe_mode": self.poe_mode,
} }
return attributes return attributes
@ -262,12 +262,12 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchEntity, RestoreEntity):
@property @property
def device(self): def device(self):
"""Shortcut to the switch that client is connected to.""" """Shortcut to the switch that client is connected to."""
return self.controller.api.devices[self.client.sw_mac] return self.controller.api.devices[self.client.switch_mac]
@property @property
def port(self): def port(self):
"""Shortcut to the switch port that client is connected to.""" """Shortcut to the switch port that client is connected to."""
return self.device.ports[self.client.sw_port] return self.device.ports[self.client.switch_port]
async def options_updated(self) -> None: async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled.""" """Config entry options are updated, remove entity if option is disabled."""
@ -307,11 +307,11 @@ class UniFiBlockClientSwitch(UniFiClient, SwitchEntity):
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
"""Turn on connectivity for client.""" """Turn on connectivity for client."""
await self.controller.api.clients.async_unblock(self.client.mac) await self.controller.api.clients.unblock(self.client.mac)
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs):
"""Turn off connectivity for client.""" """Turn off connectivity for client."""
await self.controller.api.clients.async_block(self.client.mac) await self.controller.api.clients.block(self.client.mac)
@property @property
def icon(self): def icon(self):
@ -419,7 +419,7 @@ class UniFiDPIRestrictionSwitch(UniFiBase, SwitchEntity):
"""Restrict access of apps related to DPI group.""" """Restrict access of apps related to DPI group."""
return await asyncio.gather( return await asyncio.gather(
*[ *[
self.controller.api.dpi_apps.async_enable(app_id) self.controller.api.dpi_apps.enable(app_id)
for app_id in self._item.dpiapp_ids for app_id in self._item.dpiapp_ids
] ]
) )
@ -428,7 +428,7 @@ class UniFiDPIRestrictionSwitch(UniFiBase, SwitchEntity):
"""Remove restriction of apps related to DPI group.""" """Remove restriction of apps related to DPI group."""
return await asyncio.gather( return await asyncio.gather(
*[ *[
self.controller.api.dpi_apps.async_disable(app_id) self.controller.api.dpi_apps.disable(app_id)
for app_id in self._item.dpiapp_ids for app_id in self._item.dpiapp_ids
] ]
) )

View File

@ -269,7 +269,7 @@ aiosyncthing==0.5.1
aiotractive==0.5.2 aiotractive==0.5.2
# homeassistant.components.unifi # homeassistant.components.unifi
aiounifi==29 aiounifi==30
# homeassistant.components.vlc_telnet # homeassistant.components.vlc_telnet
aiovlc==0.1.0 aiovlc==0.1.0

View File

@ -204,7 +204,7 @@ aiosyncthing==0.5.1
aiotractive==0.5.2 aiotractive==0.5.2
# homeassistant.components.unifi # homeassistant.components.unifi
aiounifi==29 aiounifi==30
# homeassistant.components.vlc_telnet # homeassistant.components.vlc_telnet
aiovlc==0.1.0 aiovlc==0.1.0