Skip to content

Commit

Permalink
Add get_port_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkGodwin committed May 28, 2023
1 parent c07a433 commit 6e69bea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/tplink_omada_client/omadasiteclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ async def get_switch_port_overrides(
)

# Otherwise the profile's config values are returned
profiles = await self.get_port_profiles()
prof = next((p for p in profiles if p.profile_id == port.profile_id), None)
prof = await self.get_port_profile(port.profile_id)

# The API doesn't provide the PoE mode of the switch (couldn't even find in Omada
# GUI how to set the PoE mode of a switch). Thus, use True as a default value.
poe_mode = (prof.poe_mode != PoEMode.DISABLED)
Expand Down Expand Up @@ -373,6 +373,15 @@ async def update_switch_port(
# Read back the new port settings
return await self.get_switch_port(mac, port)

async def get_port_profile(self, profile_id: str) -> OmadaPortProfile:
profiles = await self.get_port_profiles()

profile = next((p for p in profiles if p.profile_id == profile_id), None)

if not profile:
raise InvalidDevice(f"Port profile {profile_id} does not exist")
return profile

async def get_port_profiles(self) -> List[OmadaPortProfile]:
"""Lists the available switch port profiles that can be applied."""

Expand Down

0 comments on commit 6e69bea

Please sign in to comment.