AlexandrErohin / home-assistant-tplink-router

Home Assistant component for TP-Link router administration with sensors, button reboot, switches and device tracking.
https://community.home-assistant.io/t/custom-component-tp-link-router-integration
MIT License
137 stars 16 forks source link

TL-MR6400 not supported #49

Closed Percherie closed 7 months ago

Percherie commented 7 months ago

Describe the bug Configuration is echec There seems to be a problem with the MAC address but I don't know how to improve the situation.

Logs

Error setting up entry http://192.168.1.1 for tplink_router
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_router/__init__.py", line 47, in async_setup_entry
    firmware, status = await hass.async_add_executor_job(TPLinkRouterCoordinator.request, client, callback)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tplink_router/coordinator.py", line 56, in request
    data = callback()
           ^^^^^^^^^^
  File "/config/custom_components/tplink_router/__init__.py", line 43, in callback
    stat = client.get_status()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tplinkrouterc6u/client.py", line 853, in get_status
    status._wan_macaddr = macaddress.EUI48(item['MACAddress'])
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/macaddress.py", line 106, in __init__
    self._address, _ = _parse(address, type(self))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/macaddress.py", line 362, in _parse
    raise ValueError('hardware address cannot be an empty string')
ValueError: hardware address cannot be an empty string

Additional Information (please complete the following information)

AlexandrErohin commented 7 months ago

@Percherie Hi Could you download this client https://github.com/AlexandrErohin/TP-Link-Archer-C6U, run the code and post the output here

from tplinkrouterc6u import TPLinkMRClient
from logging import Logger

client = TPLinkMRClient('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
acts = [
    client.ActItem(client.ActItem.GS, 'LAN_IP_INTF', attrs=['X_TP_MACAddress', 'IPInterfaceIPAddress']),
    client.ActItem(client.ActItem.GS, 'WAN_IP_CONN',
                 attrs=['enable', 'MACAddress', 'externalIPAddress', 'defaultGateway']),
    client.ActItem(client.ActItem.GL, 'LAN_WLAN', attrs=['enable', 'X_TP_Band']),
    client.ActItem(client.ActItem.GL, 'LAN_WLAN_GUESTNET', attrs=['enable', 'name']),
    client.ActItem(client.ActItem.GL, 'LAN_HOST_ENTRY', attrs=[
        'IPAddress',
        'MACAddress',
        'hostName',
        'X_TP_ConnType',
        'active',
    ]),
    client.ActItem(client.ActItem.GS, 'LAN_WLAN_ASSOC_DEV', attrs=[
        'associatedDeviceMACAddress',
        'X_TP_TotalPacketsSent',
        'X_TP_TotalPacketsReceived',
    ]),
]
result, values = client.req_act(acts)
print(result)
Percherie commented 7 months ago

Thank it's first time to run Python ;-p The output is

>>> print(result)
[1,1,0,0,0,0]0
X_TP_MACAddress=30:DE:4B:17:D0:68
IPInterfaceIPAddress=192.168.1.1
[2,1,1,0,0,0]1
enable=0
MACAddress=
externalIPAddress=0.0.0.0
defaultGateway=0.0.0.0
[1,1,0,0,0,0]2
enable=0
X_TP_Band=2.4GHz
[1,1,0,0,0,0]3
enable=0
name=wlan1
[error]0
AlexandrErohin commented 7 months ago

@Percherie I have fixed it. Please try v1.13.2 and let me know how it works

Percherie commented 7 months ago

Nice it's work Entities CPU used and Memory used don't work, it's unavailable, mayby with MR6400 it's impossible ??

Good job 👍👍

AlexandrErohin commented 7 months ago

@Percherie Your router doesnt provide CPU used and Memory used info :(

P.S. Would be great if you could give a star for this repo :) Thanks