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
127 stars 15 forks source link

CPU and Memory usage entities are not available #46

Closed devasheeshG closed 7 months ago

devasheeshG commented 7 months ago

Describe the bug CPU and Memory usage entities are not available

Additional Information (please complete the following information)

image image image

AlexandrErohin commented 7 months ago

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

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/status?form=all&operation=read', 'operation=read'))
print('---')
devasheeshG commented 7 months ago
{
    "wan_ipv4_netmask": "****",
    "wireless_2g_wds_status": "****",
    "wireless_2g_wep_format2": "****",
    "wireless_5g_txbf_enable": "****",
    "wan_ipv6_conntype": "****",
    "wireless_5g_wep_key2": "",
    "wireless_2g_port": "****",
    "wireless_2g_htmode": "****",
    "storage_vendor": "",
    "wireless_2g_wep_type2": "****",
    "wireless_5g_wep_select": "****",
    "wireless_2g_psk_key": "****",
    "wireless_2g_wep_type1": "****",
    "wireless_2g_wep_key1": "",
    "wan_ipv4_snddns": "****",
    "wireless_5g_extinfo": {
        "support_band": "****",
        "dual_band": "****",
        "wds2g_wds5g_compatible": "****"
    },
    "guest_2g_hidden": "****",
    "wireless_2g_channel": "****",
    "wireless_2g_wpa_version": "****",
    "wireless_5g_psk_key": "****",
    "lan_ipv4_netmask": "****",
    "wireless_5g_wep_key1": "",
    "lan_macaddr": "****",
    "wireless_2g_encryption": "****",
    "wireless_2g_psk_cipher": "****",
    "wireless_5g_port": "****",
    "wireless_5g_wps_state": "****",
    "wireless_5g_wpa_cipher": "****",
    "guest_5g_disabled": "****",
    "wireless_5g_hwmode": "****",
    "lan_ipv6_link_local_addr": "****",
    "modem_ipaddr": "****",
    "wan_ipv6_snddns": "****",
    "wireless_2g_atf": "****",
    "wan_ipv6_ip6addr": "****",
    "guest_2g_ssid": "****",
    "wireless_5g_wpa_key": "",
    "guest_isolate": "****",
    "wan_macaddr": "****",
    "wireless_5g_hidden": "****",
    "wireless_2g_wep_key4": "",
    "wireless_5g_atf": "****",
    "wireless_2g_disabled_all": "****",
    "wireless_5g_htmode": "****",
    "wan_ipv4_gateway": "****",
    "guest_2g_psk_key": "",
    "guest_5g_psk_version": "****",
    "wireless_5g_wep_format4": "****",
    "modem_type": "****",
    "modem_connstatus": 0,
    "wireless_5g_channel": "****",
    "wan_ipv6_enable": "****",
    "wireless_2g_wep_mode": "****",
    "wireless_5g_wpa_version": "****",
    "wireless_5g_wep_type3": "****",
    "wireless_5g_wds_status": "****",
    "wireless_2g_wep_format3": "****",
    "wireless_5g_disabled": "****",
    "wireless_5g_wep_type2": "****",
    "wireless_5g_wep_format1": "****",
    "storage_capacity": 0,
    "access_devices_wired": [
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        },
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        },
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        }
    ],
    "guest_2g_disabled": "****",
    "guest_5g_psk_key": "",
    "remote": false,
    "wireless_5g_encryption": "****",
    "guest_5g_hidden": "****",
    "guest_access": "****",
    "wireless_5g_disabled_all": "****",
    "guest_5g_extinfo": {
        "support_band": "****",
        "dual_band": "****",
        "wds2g_wds5g_compatible": "****"
    },
    "wireless_5g_current_channel": "****",
    "wireless_2g_wpa_cipher": "****",
    "wireless_2g_txpower": "****",
    "wireless_2g_wep_key3": "",
    "wireless_2g_wep_select": "****",
    "guest_2g_encryption": "****",
    "wireless_2g_extinfo": {
        "support_band": "****",
        "dual_band": "****",
        "wds2g_wds5g_compatible": "****"
    },
    "guest_5g_ssid": "****",
    "wireless_2g_wep_format4": "****",
    "wireless_2g_macaddr": "****",
    "guest_5g_enable": "****",
    "storage_available_unit": "****",
    "guest_2g_psk_version": "****",
    "printer_enable": "****",
    "wireless_2g_wep_key2": "",
    "storage_available": 0,
    "wan_ipv6_gateway": "****",
    "printer_name": "****",
    "usb_available": 1,
    "printer_count": 0,
    "wireless_2g_wep_format1": "****",
    "modem_snddns": "****",
    "modem_signal": "****",
    "modem_status": "****",
    "wireless_2g_current_channel": "****",
    "wireless_2g_psk_version": "****",
    "modem_gateway": "****",
    "wireless_5g_wep_type1": "****",
    "wireless_5g_ssid": "****",
    "wireless_2g_wps_state": "****",
    "modem_pridns": "****",
    "wireless_5g_psk_version": "****",
    "modem_netmask": "****",
    "wireless_2g_server": "",
    "conn_type": "****",
    "modem_available": 0,
    "wan_ipv4_ipaddr": "****",
    "guest_2g_extinfo": {
        "support_band": "****",
        "dual_band": "****",
        "wds2g_wds5g_compatible": "****"
    },
    "lan_ipv6_assign_type": "****",
    "access_devices_wireless_host": [
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        },
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        },
        {
            "wire_type": "****",
            "macaddr": "****",
            "ipaddr": "****",
            "hostname": "****"
        }
    ],
    "wireless_2g_wep_type3": "****",
    "lan_ipv4_ipaddr": "****",
    "wireless_2g_enable": "****",
    "wireless_5g_txpower": "****",
    "guest_5g_psk_cipher": "****",
    "wireless_2g_disabled": "****",
    "wireless_5g_enable": "****",
    "wireless_5g_wep_type4": "****",
    "wireless_5g_mumimo": "****",
    "wireless_2g_wpa_key": "",
    "wireless_5g_wep_key4": "",
    "guest_5g_encryption": "****",
    "wireless_5g_wep_mode": "****",
    "wireless_5g_wep_format2": "****",
    "wireless_5g_macaddr": "****",
    "lan_ipv4_dhcp_enable": "****",
    "wireless_5g_wep_format3": "****",
    "wireless_2g_wep_type4": "****",
    "wireless_2g_hwmode": "****",
    "wireless_5g_server": "",
    "wireless_2g_ssid": "****",
    "wan_ipv4_pridns": "****",
    "guest_2g_enable": "****",
    "wireless_5g_wep_key3": "",
    "wireless_5g_psk_cipher": "****",
    "wan_ipv6_pridns": "****",
    "wireless_2g_hidden": "****",
    "storage_capacity_unit": "****",
    "wan_ipv4_conntype": "****",
    "lan_ipv6_ipaddr": "****",
    "guest_2g_psk_cipher": "****"
}

I have replaced all my confidential info with '****'.

AlexandrErohin commented 7 months ago

Your router doesnt provide information about CPU and memory usage

devasheeshG commented 7 months ago

image

Bro, but i can show it in my webui. Firmware Version: 1.2.1 Build 20220715 rel.19099(5553) Hardware Version: Archer C7 v5.0

AlexandrErohin commented 7 months ago

Then I need the url for getting these parameters and the response example from the url

devasheeshG commented 7 months ago

Then I need the url for getting these parameters and the response example from the url

image

bro, it constantly sends POST requests to a URL and receives data. I am not able to decrypt the data. can you tell me how can I get what you asked me

shar-mayank commented 7 months ago

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

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/status?form=all&operation=read', 'operation=read'))
print('---')

• The code you provided is not showing me CPU and memory usage too

    "wan_ipv4_netmask": "[Redacted]",
    "wireless_2g_wds_status": "[Redacted]",
    "wireless_2g_wep_format2": "[Redacted]",
    "wireless_5g_txbf_enable": "[Redacted]",
    "wan_ipv6_conntype": "[Redacted]",
    "wireless_5g_wep_key2": "[Redacted]",
    "wireless_2g_port": "[Redacted]",
    "wireless_2g_htmode": "[Redacted]",
    "storage_vendor": "[Redacted]",
    "wireless_2g_wep_type2": "[Redacted]",
    "wireless_5g_wep_select": "[Redacted]",
    "wireless_2g_psk_key": "[Redacted]",
    "wireless_2g_wep_type1": "[Redacted]",
    "wireless_2g_wep_key1": "[Redacted]",
    "wan_ipv4_snddns": "[Redacted]",
    "wireless_5g_extinfo": {
        "support_band": "[Redacted]",
        "dual_band": "[Redacted]",
        "wds2g_wds5g_compatible": "[Redacted]"
    },
    "guest_2g_hidden": "[Redacted]",
    "wireless_2g_channel": "[Redacted]",
    "wireless_2g_wpa_version": "[Redacted]",
    "wireless_5g_psk_key": "[Redacted]",
    "lan_ipv4_netmask": "[Redacted]",
    "wireless_5g_wep_key1": "[Redacted]",
    "lan_macaddr": "[Redacted]",
    "wireless_2g_encryption": "[Redacted]",
    "wireless_2g_psk_cipher": "[Redacted]",
    "wireless_5g_port": "[Redacted]",
    "wireless_5g_wps_state": "[Redacted]",
    "wireless_5g_wpa_cipher": "[Redacted]",
    "guest_5g_disabled": "[Redacted]",
    "wireless_5g_hwmode": "[Redacted]",
    "lan_ipv6_link_local_addr": "[Redacted]",
    "modem_ipaddr": "[Redacted]",
    "wan_ipv6_snddns": "[Redacted]",
    "wireless_2g_atf": "[Redacted]",
    "wan_ipv6_ip6addr": "[Redacted]",
    "guest_2g_ssid": "[Redacted]",
    "wireless_5g_wpa_key": "[Redacted]",
    "guest_isolate": "[Redacted]",
    "wan_macaddr": "[Redacted]",
    "wireless_5g_hidden": "[Redacted]",
    "wireless_2g_wep_key4": "[Redacted]",
    "wireless_5g_atf": "[Redacted]",
    "wireless_2g_disabled_all": "[Redacted]",
    "wireless_5g_htmode": "[Redacted]",
    "wan_ipv4_gateway": "[Redacted]",
    "guest_2g_psk_key": "[Redacted]",
    "guest_5g_psk_version": "[Redacted]",
    "wireless_5g_wep_format4": "[Redacted]",
    "modem_connstatus": "[Redacted]",
    "wireless_5g_channel": "[Redacted]",
    "wan_ipv6_enable": "[Redacted]",
    "wireless_2g_wep_mode": "[Redacted]",
    "wireless_5g_wpa_version": "[Redacted]",
    "wireless_5g_wep_type3": "[Redacted]",
    "wireless_5g_wds_status": "[Redacted]",
    "wireless_2g_wep_format3": "[Redacted]",
    "wireless_5g_disabled": "[Redacted]",
    "wireless_5g_wep_type2": "[Redacted]",
    "wireless_5g_wep_format1": "[Redacted]",
    "storage_capacity": "[Redacted]",
    "guest_2g_disabled": "[Redacted]",
    "guest_5g_psk_key": "[Redacted]",
    "remote": "[Redacted]",
    "wireless_5g_encryption": "[Redacted]",
    "guest_5g_hidden": "[Redacted]",
    "guest_access": "[Redacted]",
    "wireless_5g_disabled_all": "[Redacted]",
    "guest_5g_extinfo": {
        "support_band": "[Redacted]",
        "dual_band": "[Redacted]",
        "wds2g_wds5g_compatible": "[Redacted]"
    },
    "wireless_5g_current_channel": "[Redacted]",
    "wireless_2g_wpa_cipher": "[Redacted]",
    "wireless_2g_txpower": "[Redacted]",
    "wireless_2g_wep_key3": "[Redacted]",
    "wireless_2g_wep_select": "[Redacted]",
    "guest_2g_encryption": "[Redacted]",
    "wireless_2g_extinfo": {
        "support_band": "[Redacted]",
        "dual_band": "[Redacted]",
        "wds2g_wds5g_compatible": "[Redacted]"
    },
    "guest_5g_ssid": "[Redacted]",
    "wireless_2g_wep_format4": "[Redacted]",
    "wireless_2g_macaddr": "[Redacted]",
    "guest_5g_enable": "[Redacted]",
    "guest_2g_psk_version": "[Redacted]",
    "storage_available_unit": "[Redacted]",
    "wireless_2g_wep_key2": "[Redacted]",
    "wan_ipv6_gateway": "[Redacted]",
    "printer_name": "[Redacted]",
    "usb_available": "[Redacted]",
    "storage_available": "[Redacted]",
    "wireless_2g_wep_format1": "[Redacted]",
    "printer_count": "[Redacted]",
    "modem_signal": "[Redacted]",
    "modem_snddns": "[Redacted]",
    "wireless_2g_current_channel": "[Redacted]",
    "wireless_2g_psk_version": "[Redacted]",
    "wireless_5g_ssid": "[Redacted]",
    "modem_gateway": "[Redacted]",
    "wireless_5g_wep_type1": "[Redacted]",
    "wireless_2g_wps_state": "[Redacted]",
    "modem_pridns": "[Redacted]",
    "wireless_5g_psk_version": "[Redacted]",
    "modem_netmask": "[Redacted]",
    "wireless_2g_server": "[Redacted]",
    "conn_type": "[Redacted
image

• Facing the same issue with Hardware Version:Archer C6 v2.0 and Firmware Version:1.1.7 Build 20201010 rel.49458(5553)

AlexandrErohin commented 7 months ago

@devasheeshG try this

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/status?form=perf&operation=read', 'operation=read'))
print('---')
shar-mayank commented 7 months ago

Thanks, It's now showing CPU and memory usage too

devasheeshG commented 7 months ago

@AlexandrErohin can you integrate this in the plugin itself.

AlexandrErohin commented 7 months ago

@devasheeshG I need the output to add it from

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/status?form=perf&operation=read', 'operation=read'))
shar-mayank commented 7 months ago

This was the exact output @AlexandrErohin, and the unit is percentage.


{'mem_usage': 0.47, 'cpu_usage': 0.25}
devasheeshG commented 7 months ago

I think you should probably use mem_usage and cpu_usage from admin/status?form=perf&operation=read if the result from admin/status?form=all&operation=read does not contain these params.

Fix should be in this function: TP-Link-Archer-C6U

AlexandrErohin commented 7 months ago

@devasheeshG @shar-mayank Fixed in new release. Please download and let me know

devasheeshG commented 7 months ago

It's working, but CPU usage is too high (around 95%) 😂.