TP-Link HS100 Help

FWIW - I was getting the syntax error issue, I hunted down the pyHS100 repo on github. I found there were changes to the code base in both scripts, so I cloned the repo then copied the *py scripts into the python site-packages for pyHS100 used by home-assistant and into pyHS100 in the deps directory under .homeassistant. All worked fine from there.

I have had similar issues with my HS100 TP link plug.
It works with Alexa. My config is also correct.
What files did you copy over from Github?
I copied the same files into the deps directory but I am unsure where to copy other files to.
You mentioned the python site packages for pyHS100 - I couldn’t locate them.
I am running HASS 0.38.4 on MAC OS Sierra

I ran into the same problem after a clean install. You can install the dependency by:

git clone https://github.com/GadgetReactor/pyHS100.git

pip3 install pyHS100==0.2.3 --target ~/.homeassistant/deps

1 Like

im getting a different problem myself, tried updating pyHS100 from the repo, but not much changed:

17-03-08 03:56:31 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform tplink
Traceback (most recent call last):
  File "/root/.homeassistant/deps/pyHS100/pyHS100.py", line 99, in _query_helper
    request={target: {cmd: arg}}
  File "/root/.homeassistant/deps/pyHS100/protocol.py", line 65, in query
    return json.loads(response)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 151, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/switch/tplink.py", line 40, in setup_platform
    add_devices([SmartPlugSwitch(SmartPlug(host), name)], True)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 305, in add_entities
    entity.update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/switch/tplink.py", line 87, in update
    self._state = self.smartplug.state == \
  File "/root/.homeassistant/deps/pyHS100/pyHS100.py", line 132, in state
    relay_state = self.sys_info['relay_state']
  File "/root/.homeassistant/deps/pyHS100/pyHS100.py", line 119, in sys_info
    return self.get_sysinfo()
  File "/root/.homeassistant/deps/pyHS100/pyHS100.py", line 171, in get_sysinfo
    return self._query_helper("system", "get_sysinfo")
  File "/root/.homeassistant/deps/pyHS100/pyHS100.py", line 102, in _query_helper
    raise SmartPlugException(ex) from ex
pyHS100.pyHS100.SmartPlugException: Expecting value: line 1 column 1 (char 0)

Not really getting very far with that error, but i suspect the plug maybe returning different data than was expected by the lib?

Tried as well with various bash scripts that exist for controlling the plug and none of them can read status, but the can all change the state of the plug.

The one thing i could get to read the status of the plug was the hs100-api nodejs module, that can switch the plug and read its current state, not sure if thats of any help (personally python is one language i’m very poor with).