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

Add the ability to request a neutral SwitchPortOverrides for a particular port #20

Merged
merged 1 commit into from
May 6, 2023

Conversation

odouville
Copy link
Contributor

This allows to change the PoE mode of a single port, using ports overrides, without changing any other setting of the port, no matter how they are currently set.

The PoE switching method in the Home Assistant TP-Link Omada integration could then be changed from:

    async def _async_turn_on_off_poe(self, enable: bool) -> None:
        self.port_details = await self.omada_client.update_switch_port(
            self.device,
            self.port_details,
            overrides=SwitchPortOverrides(enable_poe=enable),
        )
        self._refresh_state()

To:

    async def _async_turn_on_off_poe(self, enable: bool) -> None:
        overrides = await self.omada_client.get_switch_port_overrides(device, port_details)
        overrides.enable_poe = enable
        self.port_details = await self.omada_client.update_switch_port(
            self.device,
            self.port_details,
            overrides,
        )
        self._refresh_state()

Hence without changing any of the port other settings.

The counterpart is that it uses one more API call to get the port status, and one more again if the port has no active overrides yet (in order to populate the neutral override settings with the port associated profile settings, which should mostly happen only once).

@MarkGodwin
Copy link
Owner

You're right, this is worth doing.
I already have an open PR on the HA integration to add gateway wan/lan connectivity sensors, so it will take a while before I can integrate this.

Copy link
Owner

@MarkGodwin MarkGodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I'll add port profile control to the CLI next I think.

@MarkGodwin MarkGodwin merged commit b89eaa0 into MarkGodwin:master May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants