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

Q: TL-SG1016PE new hardware-versions working? #8

Open
hannpet opened this issue Jul 10, 2023 · 4 comments
Open

Q: TL-SG1016PE new hardware-versions working? #8

hannpet opened this issue Jul 10, 2023 · 4 comments
Labels
question Further information is requested

Comments

@hannpet
Copy link

hannpet commented Jul 10, 2023

Hi there,

I'm about to (maybe) buy the TL-SG1016PE switch, because I love that it can be controlled with your component.
Do you have any guess or advice, if the newest hardware-versions could cause trouble? In your docs it read that V1 and V3 work, but on the TPLink-website they are already talking about version 5, so... I'm a bit scared to run into trouble :-)
I want to switch the POE ports on/off via Home Assistant.

Thank you for the great work!

@vmakeev
Copy link
Owner

vmakeev commented Jul 11, 2023

Hi!

In principle, I don't see any fundamental restrictions on interaction with new hardware revisions. Versions V1 and V3 are listed in the documentation because the component was guaranteed to work on these revisions (unfortunately, I don't have access to a large number of different devices to personally check the integration or add support for them)

My component essentially emulates working with a switch through a built-in web interface, with all the advantages and disadvantages. The hardware revision should not impose any restrictions on this method of interaction.

However, if the format of data transmitted via http requests has changed in the new version, then the component may not work (there were precedents with other switch models).

In this case, you can create an issue, and we can try to figure it out together

@vmakeev vmakeev added the question Further information is requested label Jul 12, 2023
@kevpatts
Copy link

kevpatts commented Nov 13, 2023

I have this device (hardware version 5.2) and I'm getting this error in the logs, device is failing to configure:

This error originated from a custom integration.

Logger: custom_components.tplink_easy_smart.update_coordinator
Source: helpers/update_coordinator.py:290
Integration: TP-Link Easy Smart (documentation, issues)
First occurred: 16:42:22 (26 occurrences)
Last logged: 17:01:39

Unexpected error fetching TP-Link Switch data: Api call error, status:200; code: -2, category: unauthorized
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easy_smart/update_coordinator.py", line 121, in async_update
    await self._update_switch_info()
  File "/config/custom_components/tplink_easy_smart/update_coordinator.py", line 133, in _update_switch_info
    self._switch_info = await self._api.get_device_info()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easy_smart/client/tplink_api.py", line 110, in get_device_info
    data = await self._core_api.get_variable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easy_smart/client/coreapi.py", line 463, in get_variable
    result = await self.get_variables(path, [(variable, variable_type)], **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easy_smart/client/coreapi.py", line 446, in get_variables
    response_text = await self.get(path)
                    ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easy_smart/client/coreapi.py", line 403, in get
    raise ApiCallError(
custom_components.tplink_easy_smart.client.coreapi.ApiCallError: Api call error, status:200; code: -2, category: unauthorized

The username and password are correct by the way, and changed from default. Easy Smart utility (1.3.13.0) is working.

@SteffenSenchyna
Copy link

For anyone who ends up here with the error @kevpatts had, after quite a bit of time reviewing the network calls from the browser it showed that the request headers for login.cgi use the Referer header pointing to the root page "/", so by by adding await self._get_raw("") to the authenticate method in coreapi.py you are able to get the integration working.

async def authenticate(self) -> None:
    """Perform authentication and return true when authentication success"""
    try:
        _LOGGER.debug("Authentication started")
        self._refresh_session()

        _LOGGER.debug("Performing initial GET to obtain cookies")
        await self._get_raw("")
        
        _LOGGER.debug("Performing logon")
        response = await self._post_raw(
            "logon.cgi",
            {"username": self._user, "password": self._password, "logon": "Login"},
        )
TP-Link-5 2

@Vasilich
Copy link

Vasilich commented Sep 17, 2024

For anyone who ends up here with the error @kevpatts had, after quite a bit of time reviewing the network calls from the browser it showed that the request headers for login.cgi use the Referer header pointing to the root page "/", so by by adding await self._get_raw("") to the authenticate method in coreapi.py you are able to get the integration working.

Great! Thanks. Helped to get connection to TL-SG116E with FW v2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants