question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HS300 returns 5 children (plugs), when 6 is expected

See original GitHub issue

The HS300 has 6 outlets.

When I send command: ./tplink_smartplug.py -t HS300 -c info

I receive: Sent: {"system":{"get_sysinfo":{}}} Received: {"system":{"get_sysinfo":{"sw_ver":"1.0.10 Build 190103 Rel.163517","hw_ver":"1.0","model":"HS300(US)","deviceId":"<obfuscated>","oemId":"<obfuscated>","hwId":"<obfuscated>","rssi":-68,"longitude_i":<obfuscated>,"latitude_i":<obfuscated>,"alias":"TP-LINK_Power Strip_0320","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM:ENE","mac":"<obfuscated>","updating":0,"led_off":0,"children":[{"id":"<obfuscated>00","state":0,"alias":"outside fan","on_time":0,"next_action":{"type":-1}},{"id":"<obfuscated>01","state":1,"alias":"inside fan","on_time":1352807,"next_action":{"type":-1}},{"id":"<obfuscated>02","state":1,"alias":"Plug 3","on_time":1398685,"next_action":{"type":-1}},{"id":"<obfuscated>03","state":1,"alias":"Plug 4","on_time":1398685,"next_action":{"type":-1}},{"id":"<obfuscated>04","state":1,"alias":"Plug 5","

as you can see it stops at Plug 5, and it doesn’t finish

When I change data = sock_tcp.recv(2048) to data = sock_tcp.recv(4096)

I then receive all 6 children. Was this the correct fix?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ashleypittmancommented, Nov 10, 2019

I just spotted the formatting was wrong on my comment, updated. Don’t call decrypt on data2[4:] as that’s where the four bytes are being dropped, you need to append data and data2, then drop four bytes of both, it’s this line that you need “decrypt(data[4:] + data2)”

For testing I used the history functions which returns much larger values and so hit this case most invocations rather than simple reads which rarely exhibit it.

0reactions
amccombsahcecommented, Nov 9, 2019

Thanks Ashley, I tried some of your code, you’re doing something with json which wasn’t part of the original, so I left it out. As you can see, I am missing 5 bytes in the “id” for outlet id ending in “404”.

    abc002 = abc010 = "b"
    sock_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock_tcp.settimeout(2)
    sock_tcp.connect((ip, port))
    sock_tcp.send(encrypt(cmd))
    data = sock_tcp.recv(2048)
    abc001 = decrypt(data[4:])

if (abc001[-1] != '}'):
        data2 = sock_tcp.recv(2048)
        abc002 = decrypt(data2[4:])
sock_tcp.close()

    abc010 = abc001 + abc002

    print "Sent:     ", cmd
    print "Received: ", abc001
    print "\n\n\n\nReceived2: ", abc002
    print "\n\n\n\n ", abc010

Results:

{"id":"80066DED8DED9E47F301DCAA593661321B80D21403","state":0,"alias":"4 UV Light","on_time":0,"next_action":{"type":1,"schd_sec":68460,"action":1}}, {"id":"80066DED8D07F301DCAA593661321B80D21404","state":0,"alias":"5 Main Fans","on_time":0,"next_action":{"type":1,"schd_sec":68400,"action":1}}, {"id":"80066DED8DED9E47F301DCAA593661321B80D21405","state":1,"alias":"6 Veg Light","on_time":162304,"next_action":{"type":-1}}],"child_num":6,"err_code":0}}}

Read more comments on GitHub >

github_iconTop Results From Across the Web

HS300 reporting wrong number of plugs · Issue #28590 - GitHub
On startup / discovery sometimes the plug is reported as 5 sometimes as 6. it is a HS300 power strip. Problem-relevant configuration.yaml ...
Read more >
Kasa Smart Plug Power Strip HS300, Surge Protector with 6 ...
Kasa Smart Plug Power Strip HS300, Surge Protector with 6 Individually Controlled Smart Outlets and 3 USB Ports, Works with Alexa & Google...
Read more >
TP-Link HS300 Kasa Smart Power Strip Review - YouTube
Well not any more the TP-Link HS300 Kasa Smart Power Strip lets you have 6 smart plugs that uses just one outlet on...
Read more >
Got my TP-Link Kasa Smart Plug Power Strip HS300 - Reddit
So you've been warned, if you don't need 4-6 plugs and 3 USB get the ... have 5 or 10 different scheduled events...
Read more >
Kasa Smart Plug Power Strip HS300, Surge ... - Newegg.com
Buy Kasa Smart Plug Power Strip HS300, Surge Protector with 6 ... Smart Outlets and 3 USB Ports, Works with Alexa & Google...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found