core: HS300 reporting wrong number of plugs

Operating environment (Hass.io/Docker/Windows/etc.):

Hassio.io on a Pi4 4GB manually configured TPLink as a strip pointing to the device (HS300) Integration:

https://www.home-assistant.io/integrations/tplink/

Description of problem: TPLink does not auto discovery so I setup manually as a script. On startup / discovery sometimes the plug is reported as 5 sometimes as 6. it is a HS300 power strip.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):




Traceback (if applicable):


Additional information:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 111 (46 by maintainers)

Most upvoted comments

Thank you so much @TheGardenMonkey ! This has helped and my HS300 is working much better, all of the outlets show up now and the on/off functionality is working consistent enough to be used for my intended purposes. Thanks again.

I have 2 H300’s experiencing issues with plugs going unavailable. Just tried your latest changes. First time I have ever seen all my plugs online. All seem to be reporting properly and updating. Amazing work!

I take that back. After more testing, I am seeing that they really aren’t any better in the new group. Please let me know if there is any other info I can give you to help debug!

I’ll play around with it this weekend. It makes sense to me that this could happen though. I want to compare with some of the other changes proposed as well…I think there is a collection of changes that will make this integration more robust.

Hey everyone, I’m getting up the courage to enable this because I’ve gotten tired of waiting for the real fix. I’m pretty new to all this so I don’t wanna mess things up. I’m running Hassio on a rpi3. from what I understand, I can do the following to install this:

  1. using the hassio sidebar file editor, create a folder named custom_components in /config
  2. using the hassio sidebar file editor, create a new file and call it switch.py
  3. from TheGardenMonkey’s GitHub page copy the contents of switch.py and paste it into /config/custom_components/switch.py
  4. restart hassio

is that it? Do I need to disable my current tpLink integration before restarting? Do I need to delete all my existing devices and entities?

Thanks for the help

under custom_components you would add a directory named tplink. You should download all of the files from the repo so that the contents look like:

homeassistant@rpimain1:~/.homeassistant/custom_components/tplink $ ll
-rw-rw-r-- 1 homeassistant homeassistant  5785 Sep 24 20:50 common.py
-rw-rw-r-- 1 homeassistant homeassistant   364 Sep 13 13:37 config_flow.py
-rw-rw-r-- 1 homeassistant homeassistant   117 Sep 13 13:37 const.py
-rw-rw-r-- 1 homeassistant homeassistant  3764 Sep 13 13:37 __init__.py
-rw-rw-r-- 1 homeassistant homeassistant 16646 Sep 24 20:49 light.py
-rw-rw-r-- 1 homeassistant homeassistant   263 Sep 13 13:37 manifest.json
-rw-rw-r-- 1 homeassistant homeassistant   306 Sep 13 13:38 strings.json
-rw-rw-r-- 1 homeassistant homeassistant  5244 Sep 24 20:49 switch.py

You do not have to delete your existing devices or disable anything else. HA will just ignore the out of the box one.

For my existing PR, all of the checks are passing so I am hopeful that means it will be merged soon.

@TheGardenMonkey - All my tplink devices have been working flawlessly over here with your fork of the tplink component. It sounds like adjusting the SLEEP_TIME = 2 works better with the strips, so that is the only change I would recommend. That is also the original setting I was using over here. Would be great to have this merged so I don’t have to keep re-copying it after each upgrade. I know the long term plan is to go with the new back-end library, but we really need this merged prior - as this has been an issue for almost a year.

Thanks @TheGardenMonkey. I changed SLEEP_TIME to 2 and restarted HA. Seems good for now.

Cool, I guess I was being too aggressive 😃. I did also get the same error you did btw on turning on my strip this morning (mine only has 5 of the ports, 1 port I always have on). I think the 1 second is hammering it too much and is likely the cause of the other issue since I haven’t seen it before when doing 2 seconds. I am going to keep it at 2 for now.

Thank you @MarkHofmann11 !

@mikesalz and @aLTeReGo-SWI was curious if either or both of you wouldn’t also mind validating. I am not seeing issues with controlling multiple switches at once and the hs300 seems to respond a little better than with my previous change.

I think I merged those changes in a few weeks ago as well…they are part of my pull request.

I’d be happy to help with testing.

I have 3 of the HS300’s (I’m in the USA) and am having issues getting them connected to Hass. 3 x 6 sockets means I have 18 sockets to come online after a Hass/Hass.io reboot, and I’ve never seen it successfully bring all 18 online.

I’m running .107.5 with Hass.io Supervisor 209 on Ubuntu 18.04.4. I am having no issues with either my Alexa integration nor my Sense integration.

Awesome, thanks!!! Just updated mine over here and it loaded fine this time. Will report back tomorrow after I give it time to run for awhile. I have a good number of TP-Link switches, and a bulb, so should be a good test.

Attaching the full file instead…i should have done that in the first place

switch.py.txt