home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.19k stars 31.16k forks source link

Tplink switch fails to load #4601

Closed texanman closed 7 years ago

texanman commented 8 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):

Python release (python3 --version): Python3-3.4

Component/platform: tplink switch

Description of problem:

Switch fails to be detected Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

Traceback (if applicable):

About

Home Assistant 0.33.4

Path to configuration.yaml: /home/hass/.homeassistant

Developed by a bunch of awesome people.

Published under the MIT license Source: server — frontend-ui — frontend-core

Built using Python 3, Polymer 1.7.0, NuclearJS 1.3.0 Icons by Google and MaterialDesignIcons.com.

The following errors have been logged this session:

16-11-27 13:39:16 homeassistant.components.switch: Error while setting up platform tplink Traceback (most recent call last): File "/srv/hass/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 150, in _async_setup_platform entity_platform.add_entities, discovery_info File "/usr/lib/python3.4/asyncio/futures.py", line 388, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup value = future.result() File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result raise self._exception File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run result = self.fn(*self.args, **self.kwargs) File "/srv/hass/lib/python3.4/site-packages/homeassistant/components/switch/tplink.py", line 43, in setup_platform add_devices([SmartPlugSwitch(SmartPlug(host), name)], True) File "/srv/hass/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 299, in add_entities entity.update() File "/srv/hass/lib/python3.4/site-packages/homeassistant/components/switch/tplink.py", line 99, in update emeter_statics = self.smartplug.get_emeter_daily() File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 132, in get_emeter_daily response = self._send_command('{"emeter":{"get_daystat":{"month":' + str(month) + ',"year":' + str(year) + '}}}') File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 250, in _send_command return json.loads(response) File "/usr/lib/python3.4/json/init.py", line 318, in loads return _default_decoder.decode(s) File "/usr/lib/python3.4/json/decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.4/json/decoder.py", line 359, in raw_decode obj, end = self.scan_once(s, idx) ValueError: Expecting ':' delimiter: line 1 column 1445 (char 1444)

Additional info:

kirichkov commented 8 years ago

This looks to me as malformatted JSON returned by the plug. Which plug do you have, HS100 or HS110 (with energy meter)?

rytilahti commented 7 years ago

This issue is caused by pyHS100 not reading all chunks belonging to the response, see https://github.com/GadgetReactor/pyHS100/pull/11 , one of the patches is the fix to this issue. If/when this pull request gets accepted, it's necessary to adapt the tplink module too for the new API.