lyricnz / tplink_ess

Home Assistant TP-Link Easy Smart Switches integration
MIT License
4 stars 0 forks source link

Integration makes many (unnecessary?) calls to switch #22

Open lyricnz opened 1 year ago

lyricnz commented 1 year ago

I was running a profiler against HA (investigating another issue) and saw that tplink_ess is taking a lot of the execution time:

Screenshot 2023-04-26 at 1 22 41 pm

The sector highlighted in purple is this integration, which makes many calls (during the 60 second profiling)

Screenshot 2023-04-26 at 1 26 51 pm

Looking into the code, and adding some debugging, I can see that the integration polls each configured switch every 10-30 seconds. Each time it calls update_data() this polls all the actions, which takes over a second:

2023-04-26 13:58:01.350 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a hostname
2023-04-26 13:58:01.453 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a num_ports
2023-04-26 13:58:01.538 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a ports
2023-04-26 13:58:01.638 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a trunk
2023-04-26 13:58:01.724 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a mtu_vlan
2023-04-26 13:58:01.813 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a vlan
2023-04-26 13:58:01.899 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a pvid
2023-04-26 13:58:01.988 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a qos1
2023-04-26 13:58:02.099 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a qos2
2023-04-26 13:58:02.200 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a mirror
2023-04-26 13:58:02.289 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a stats
2023-04-26 13:58:02.453 INFO (MainThread) [tplink_ess_lib] QUERY b4:b0:24:3a:ec:3a loop_prev

Most of this data is unnecessary.

Version of the custom_component

git Wed Mar 1

Configuration

In the profiler pictures above, THREE tp-link ESS switches are configured.

firstof9 commented 1 year ago

Can make the amount of things queried configurable, I think.