TP Link giving Communication error - unpack requires a buffer of 4 bytes

Any thoughts as to why? And how to fix it? Looks like a TP-Link device is failing. It’s giving a buffer error: unpack requires a buffer of 4 bytes

I don’t know what device is failing. Although, “smartstrip” hits it might be the christmas_tree_* devices - plugged into a TP outdoor dual smart plug (KP400). Any idea why?

Got exception Communication error

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 117, in _query_helper
    request=request,
  File "/usr/local/lib/python3.7/site-packages/pyHS100/protocol.py", line 60, in query
    length = struct.unpack(">I", chunk[0:4])[0]
struct.error: unpack requires a buffer of 4 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyHS100/discover.py", line 57, in discover
    devices[ip] = device_class(ip)
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartstrip.py", line 43, in __init__
    children = self.sys_info["children"]
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 186, in sys_info
    return defaultdict(lambda: None, self.get_sysinfo())
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 196, in get_sysinfo
    return self._query_helper("system", "get_sysinfo")
  File "/usr/local/lib/python3.7/site-packages/pyHS100/smartdevice.py", line 120, in _query_helper
    raise SmartDeviceException('Communication error') from ex
pyHS100.smartdevice.SmartDeviceException: Communication error

I have 3 devices that appear to be failing. I should note that Google Assistant can connect to these devices (through tp-link direct integration) without trouble. It’s an HA thing.

It’s not a HA-thing. The underlying library doesn’t yet support those multi socket variants. If you can help us with some dumps and testing we might be able to get it working:

1 Like

Ah. Thanks for the heads up!

If I was a python developer, I would. Sadly, my strengths are in PHP, shell, and Groovy right now. For now, I’ve subscribed to the issue to watch it.