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

Problem with add switch TL-SG1016DE V6 #2

Open
vigoware opened this issue Feb 11, 2024 · 17 comments
Open

Problem with add switch TL-SG1016DE V6 #2

vigoware opened this issue Feb 11, 2024 · 17 comments
Assignees
Labels
bug Something isn't working

Comments

@vigoware
Copy link

GHi I have 2 switches TL-SG1016DE, one is V4.20 and second is V6.0, I have problem with V6.0, after trying to add HAS show "Unknown error occurred", Ur plugin is great, but i need use for both switches. Can u helpme ?

@Aohzan
Copy link
Owner

Aohzan commented Feb 11, 2024

Hello
Is it the same web interface between 4.2 and 6 ?

@DerEingerostete
Copy link
Contributor

Hello, I also own a TL-SG1016DE V6. Unfortunately, I do not own a V4.20 and therefore cannot confirm if it is the same WebUI. However, I have taken a screenshot of the WebUI of the V6 just in case. Maybe that will help.

If you have any questions, e.g. about network traffic in the Developer Tools, I will be happy to help.

Best regards!

Web UI

@Aohzan
Copy link
Owner

Aohzan commented Feb 11, 2024

you have Monitoring => Port statistics ? If yes send a screeshot please
and paste integration error too

@DerEingerostete
Copy link
Contributor

DerEingerostete commented Feb 11, 2024

It does have statistics:
Port Statistics

Also this is the error:

2024-02-11 21:23:52.093 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 416, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_easysmartswitch/config_flow.py", line 71, in async_step_user
    await switch.get_data()
  File "/config/custom_components/tplink_easysmartswitch/tplink.py", line 151, in get_data
    port_number = int(pattern.search(str(soup.script)).group(2))  # type: ignore
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PS: Unrelated to the problem. "connection" is misspelled in the config progress

@Aohzan
Copy link
Owner

Aohzan commented Feb 11, 2024

Thank, fix released for the misspelled

Can you go to http://192.168.1.X/PortStatisticsRpm.htm, do Ctrl+U to show source code and paste it here

@DerEingerostete
Copy link
Contributor

Here you go:

<!DOCTYPE html>
<script>
var max_port_num = 16;
var port_middle_num  = 16;
var all_info = {
state:[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0],
link_status:[6,6,6,0,0,0,0,0,0,0,0,0,6,0,5,5,0,0],
pkts:[289930074,0,680700261,0,70952885,0,49561738,51,278189611,0,91716707,0,0,0,0,0,114126592,0,48354947,0,0,0,0,0,105362065,0,34808599,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,154994443,0,73970472,0,0,0,0,0,20382612,0,1044614,0,22457736,0,5682867,0,0,0]
};
var tip = "";
</script>
<html> <head> <meta charset="gb2312"> <script>document.write(top.Abbrev);</script><script type=text/javascript>function dosubmitClear(){return document.port_statistics.submit(),!0}function dosubmitRefresh(){document.location.href="PortStatisticsRpm.htm"}incCss("main.css"),incCss("help.css"),incJs("ui.js"),incJs("help.js"),incJs("tips.js");var state_info=new Array("Disabled","Enabled"),link_info=new Array("Link Down","Auto","10M Half","10M Full","100M Half","100M Full","1000M Full","");</script><body> <div id=div_tip_mask class=TIP_MASK> <div id=div_tip_svr class=TIP><span id=sp_tip_svr class=TIP_CONTENT></span></div> </div>  <form name=port_statistics action=port_statistics_set.cgi enctype=multipart/form-data> <fieldset> <legend> <span id=portStatisticsInformation class=PAIN_TITLE>Port Statistics Info</span> </legend> <div id=div_sec_title> <table class=BORDER> <script>var index,tmp_info2,all_info2,port_id,state,link_status,tx_good,tx_bad,rx_good,rx_bad,LineTd="<td class=TABLE_HEAD_BOTTOM align=center width=78px>";for(docW("<tr class=TD_FIRST_ROW>"),docW(LineTd+"Port"),docW("</td>"),docW(LineTd+"Status"),docW("</td>"),docW(LineTd+"Link Status"),docW("</td>"),docW(LineTd+"TxGoodPkt"),docW("</td>"),docW(LineTd+"TxBadPkt"),docW("</td>"),docW(LineTd+"RxGoodPkt"),docW("</td>"),docW(LineTd+"RxBadPkt"),docW("</td>"),docW("</tr>"),index=0;index<max_port_num;index++)port_id=index+1,port="Port "+port_id,state=state_info[all_info.state[index]],link_status=link_info[all_info.link_status[index]],tx_good=all_info.pkts[4*index],tx_bad=all_info.pkts[4*index+1],rx_good=all_info.pkts[4*index+2],rx_bad=all_info.pkts[4*index+3],docW("<tr>"),docW(LineTd+port),docW("</td>"),docW(LineTd+state),docW("</td>"),docW(LineTd+link_status),docW("</td>"),docW(LineTd+tx_good),docW("</td>"),docW(LineTd+tx_bad),docW("</td>"),docW(LineTd+rx_good),docW("</td>"),docW(LineTd+rx_bad),docW("</td>"),docW("</tr>");</script></table><table class=BTN_WRAPPER align=center> <tr> <td class=BTN_WRAPPER><a class=BTN> <input type=button value=Refresh name=refresh onclick=dosubmitRefresh() class="BTN_NORMAL_BTN"> </a>  <td class=BTN_WRAPPER><a class=BTN> <input type=submit value=Clear id=btn_slt_clear name=clear onclick=dosubmitClear() class="BTN_NORMAL_BTN"> </a>  <td class=BTN_WRAPPER> <a class=BTN> <input type=button class=BTN_NORMAL_BTN value=Help name=help onclick="doShowHelp(&quot;div_sec_title&quot;,&quot;div_help_lan_svr&quot;,&quot;PortStatisticsHelpRpm.htm&quot;)"> </a>   </table> </div> </fieldset> </form> <script>ShowHelp('<span class="HELP_TITLE" id="t_help_title">Port Statistics Info</span> ');</script><script>window.onload=function(){new Drag("div_help_lan_svr","div_help_lan_svr")};</script><script>""!=tip&&(ShowTips("sp_tip_svr",tip),startDownScroll("div_tip_svr"));</script>

@Aohzan
Copy link
Owner

Aohzan commented Feb 11, 2024

It's the same code except the port count 🤔

Do you have an other text error before or after the one you paste ?

@DerEingerostete
Copy link
Contributor

This error was the only one I found in the log files. All the others were from another Zigbee Device that has nothing to do with the error

@vigoware
Copy link
Author

Hi the web interface is same like twins and also when i configure both switches with "Easy Smart Configuration Utility" I didn't find any differences... It happened once when I turned off and on the v6 switch that it HAS loaded, but only until the HAS configuration reloading

@Aohzan
Copy link
Owner

Aohzan commented Feb 12, 2024

Maybe you lost the authentication ? If you restart HA again, it works ?

@vigoware
Copy link
Author

No, restarting the home assistant does not help, only turning off and turning on the V6 switch again, and that only until the next reload of the home assistant configuration. then it is not possible to load switch V6 again

@vigoware
Copy link
Author

I have already tried to delete the V6 switch and add it again, but without success. It throws an error already when adding a device.

@DerEingerostete
Copy link
Contributor

DerEingerostete commented Feb 16, 2024

I'm currently investigating the error. It seems like the login failed, because the string that is throwing an error due to the regex not matching is showing the login code instead of the actual code for the table view.

Here's the "soup.script" variable:

<script>
var logonInfo = new Array(
0,
0,0);
var g_Lan = 1;
var g_year=2023;
</script>

Will do further investigating...

@Aohzan
Copy link
Owner

Aohzan commented Feb 16, 2024

Maybe I have a better authentication failure handling to manage 🤔
the issue is that, when you log from somewhere, it disconnect elsewhere (so from your HA too), so I should add a automatic reconnection

@DerEingerostete
Copy link
Contributor

That could help. But if I understand everything I tried to correctly, the login worked. It returned a cookie for the authentication. But I am not sure if the get method used the cookie

@Aohzan Aohzan self-assigned this Feb 16, 2024
@Aohzan Aohzan added the bug Something isn't working label Feb 16, 2024
@Aohzan
Copy link
Owner

Aohzan commented Feb 16, 2024

I will check that, in the mean time try to not login on the web ui 😅

@FillR2
Copy link

FillR2 commented Mar 6, 2024

Hi @Aohzan

Same device and same error here:

image

  File "/config/custom_components/tplink_easysmartswitch/config_flow.py", line 71, in async_step_user
    await switch.get_data()
  File "/config/custom_components/tplink_easysmartswitch/tplink.py", line 151, in get_data
    port_number = int(pattern.search(str(soup.script)).group(2))  # type: ignore
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants