Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceback in decoding #37

Closed
macf0x opened this issue Feb 12, 2017 · 5 comments
Closed

Traceback in decoding #37

macf0x opened this issue Feb 12, 2017 · 5 comments

Comments

@macf0x
Copy link

macf0x commented Feb 12, 2017

Title might not be accurate, but with a recent HS100 V2, the component seems to be failing with the error.

The device is function with the app.

Attach screenshot and packet capture.

>>> from pyHS100 import SmartPlug
>>> from pprint import pformat as pf
>>> plug = SmartPlug("192.168.10.27")
>>> print("Alias, type and supported features: %s" % (plug.identify(),))
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/pyHS100/pyHS100.py", line 99, in _query_helper
    request={target: {cmd: arg}}
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/pyHS100/protocol.py", line 65, in query
    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 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

capture3

HS100.pcap.zip

Regards
Rob

@macf0x
Copy link
Author

macf0x commented Feb 16, 2017

Sean, has suggested (in email) that I confirm if future is installed. Will confirm.

@macf0x
Copy link
Author

macf0x commented Feb 16, 2017

Installing future got the cli working, however the decoding issue still persists.

pi@hass:/home/hass/.homeassistant/pyHS100-master $ python -m examples/cli 192.168.10.27
DEBUG:pyHS100.protocol:> (31) {"system": {"get_sysinfo": {}}}
DEBUG:pyHS100.protocol:< (572) {"system":{"get_sysinfo":{"sw_ver":"1.0.10 Build 161012 Rel.165510","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(AU)","mac":"50:C7:BF:39:84:CA","dev_name":"Smart Wi-Fi Plug","alias":"Pagola Fairy Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-64,"led_off":0,"longitude_i":1385850,"latitude_i":-350498,"hwId":"D3CB232A2C936C37AE441A16BD2CBE64","fwId":"00000000000000000000000000000000","deviceId":"800643A465EF4142ABA69F3143D377F1182347C5","oemId":"2768475E8EC1F98BD216C2BF981B2DD1","err_code":0}}}
DEBUG:pyHS100.protocol:> (31) {"system": {"get_sysinfo": {}}}
DEBUG:pyHS100.protocol:< (572) {"system":{"get_sysinfo":{"sw_ver":"1.0.10 Build 161012 Rel.165510","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(AU)","mac":"50:C7:BF:39:84:CA","dev_name":"Smart Wi-Fi Plug","alias":"Pagola Fairy Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-63,"led_off":0,"longitude_i":1385850,"latitude_i":-350498,"hwId":"D3CB232A2C936C37AE441A16BD2CBE64","fwId":"00000000000000000000000000000000","deviceId":"800643A465EF4142ABA69F3143D377F1182347C5","oemId":"2768475E8EC1F98BD216C2BF981B2DD1","err_code":0}}}
INFO:root:Identify: (u'Pagola Fairy Light', u'HS100(AU)', [u'TIM'])
DEBUG:pyHS100.protocol:> (31) {"system": {"get_sysinfo": {}}}
DEBUG:pyHS100.protocol:< (572) {"system":{"get_sysinfo":{"sw_ver":"1.0.10 Build 161012 Rel.165510","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(AU)","mac":"50:C7:BF:39:84:CA","dev_name":"Smart Wi-Fi Plug","alias":"Pagola Fairy Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-64,"led_off":0,"longitude_i":1385850,"latitude_i":-350498,"hwId":"D3CB232A2C936C37AE441A16BD2CBE64","fwId":"00000000000000000000000000000000","deviceId":"800643A465EF4142ABA69F3143D377F1182347C5","oemId":"2768475E8EC1F98BD216C2BF981B2DD1","err_code":0}}}
INFO:root:Sysinfo: {u'active_mode': u'none',
 u'alias': u'Pagola Fairy Light',
 u'dev_name': u'Smart Wi-Fi Plug',
 u'deviceId': u'800643A465EF4142ABA69F3143D377F1182347C5',
 u'feature': u'TIM',
 u'fwId': u'00000000000000000000000000000000',
 u'hwId': u'D3CB232A2C936C37AE441A16BD2CBE64',
 u'hw_ver': u'2.0',
 u'icon_hash': u'',
 u'latitude_i': -350498,
 u'led_off': 0,
 u'longitude_i': 1385850,
 u'mac': u'50:C7:BF:39:84:CA',
 u'model': u'HS100(AU)',
 u'oemId': u'2768475E8EC1F98BD216C2BF981B2DD1',
 u'on_time': 0,
 u'relay_state': 0,
 u'rssi': -64,
 u'sw_ver': u'1.0.10 Build 161012 Rel.165510',
 u'type': u'IOT.SMARTPLUGSWITCH',
 u'updating': 0}
DEBUG:pyHS100.protocol:> (31) {"system": {"get_sysinfo": {}}}
DEBUG:pyHS100.protocol:< (572) {"system":{"get_sysinfo":{"sw_ver":"1.0.10 Build 161012 Rel.165510","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(AU)","mac":"50:C7:BF:39:84:CA","dev_name":"Smart Wi-Fi Plug","alias":"Pagola Fairy Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-64,"led_off":0,"longitude_i":1385850,"latitude_i":-350498,"hwId":"D3CB232A2C936C37AE441A16BD2CBE64","fwId":"00000000000000000000000000000000","deviceId":"800643A465EF4142ABA69F3143D377F1182347C5","oemId":"2768475E8EC1F98BD216C2BF981B2DD1","err_code":0}}}

Hass log errors

Feb 20 01:58:09 hass hass[12191]: ERROR:homeassistant.components.switch:Error while setting up platform tplink
Feb 20 01:58:09 hass hass[12191]: Traceback (most recent call last):
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 99, in _query_helper
Feb 20 01:58:09 hass hass[12191]: request={target: {cmd: arg}}
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/protocol.py", line 65, in query
Feb 20 01:58:09 hass hass[12191]: return json.loads(response)
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
Feb 20 01:58:09 hass hass[12191]: return _default_decoder.decode(s)
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
Feb 20 01:58:09 hass hass[12191]: obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
Feb 20 01:58:09 hass hass[12191]: raise ValueError(errmsg("Expecting value", s, err.value)) from None
Feb 20 01:58:09 hass hass[12191]: ValueError: Expecting value: line 1 column 1 (char 0)
Feb 20 01:58:09 hass hass[12191]: The above exception was the direct cause of the following exception:
Feb 20 01:58:09 hass hass[12191]: Traceback (most recent call last):
Feb 20 01:58:09 hass hass[12191]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 151, in _async_setup_platform
Feb 20 01:58:09 hass hass[12191]: entity_platform.add_entities, discovery_info
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
Feb 20 01:58:09 hass hass[12191]: yield self  # This tells Task to wait for completion.
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
Feb 20 01:58:09 hass hass[12191]: value = future.result()
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
Feb 20 01:58:09 hass hass[12191]: raise self._exception
Feb 20 01:58:09 hass hass[12191]: File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
Feb 20 01:58:09 hass hass[12191]: result = self.fn(*self.args, **self.kwargs)
Feb 20 01:58:09 hass hass[12191]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/tplink.py", line 40, in setup_platform
Feb 20 01:58:09 hass hass[12191]: add_devices([SmartPlugSwitch(SmartPlug(host), name)], True)
Feb 20 01:58:09 hass hass[12191]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/tplink.py", line 52, in __init__
Feb 20 01:58:09 hass hass[12191]: self._name = self.smartplug.alias
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 359, in alias
Feb 20 01:58:09 hass hass[12191]: return self.sys_info['alias']
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 119, in sys_info
Feb 20 01:58:09 hass hass[12191]: return self.get_sysinfo()
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 171, in get_sysinfo
Feb 20 01:58:09 hass hass[12191]: return self._query_helper("system", "get_sysinfo")
Feb 20 01:58:09 hass hass[12191]: File "/home/hass/.homeassistant/deps/pyHS100/pyHS100.py", line 102, in _query_helper
Feb 20 01:58:09 hass hass[12191]: raise SmartPlugException(ex) from ex
Feb 20 01:58:09 hass hass[12191]: pyHS100.pyHS100.SmartPlugException: Expecting value: line 1 column 1 (char 0)

@kirichkov
Copy link
Collaborator

kirichkov commented Feb 17, 2017

Can you place your code surrounded by three backticks ``` followed by newline so we can get something more readable like so:

```
line1
line2
```

or copy-paste it in a gist.

@macf0x
Copy link
Author

macf0x commented Feb 19, 2017

Sorry about that. Will do. Will get fresh output... Now updated

@rytilahti
Copy link
Collaborator

This should have been fixed by #30 which will be in the new release, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants