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

Error: Unable to parse message payload #1411

Closed
heyjared opened this issue May 5, 2022 · 0 comments · Fixed by #1438
Closed

Error: Unable to parse message payload #1411

heyjared opened this issue May 5, 2022 · 0 comments · Fixed by #1438
Labels

Comments

@heyjared
Copy link

heyjared commented May 5, 2022

Describe the bug
JSON parsing fails when the value returned from device is 00.

Version information (please complete the following information):

  • OS: Linux
  • python-miio: master (31c5d74)

Device information:
If the issue is specific to a device:

  • Model: 090615.curtain.jldj03
  • Hardware version: esp8266
  • Firmware version: 2.1.2

To Reproduce
Steps to reproduce the behavior:

  1. miiocli -d miotdevice --ip x.x.x.x --token xxx get_property_by 2 1

Expected behavior
A clear and concise description of what you expected to happen.

Console output

INFO:miio.cli:Debug mode active
WARNING:miio.miot_device:Neither the class nor the parameter defines the mapping
Running command get_property_by
DEBUG:miio.click_common:Unknown model, trying autodetection. None None
DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x0e\x80h\xd9\x00:\xa8\xed' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('0e8068d9')
            ts = 1970-02-14 11:52:13
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 0e8068d9 with ts: 1970-02-14 11:52:13, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:x.x.x.x:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
DEBUG:miio.miioprotocol:x.x.x.x:54321 (ts: 1970-02-14 11:52:13, id: 1) << {'id': 1, 'result': {'life': 3844333, 'uid': 2489088409, 'model': '090615.curtain.jldj03', 'token': 'xxx', 'ipflag': 1, 'fw_ver': '2.1.2', 'mcu_fw_ver': '0006', 'miio_ver': '0.0.8', 'hw_ver': 'esp8266', 'mmfree': 23784, 'mac': 'xxx', 'wifi_fw_ver': 'e0ed3c4', 'ap': {'ssid': 'xxx', 'bssid': 'xxx', 'rssi': -74, 'primary': 11}, 'netif': {'localIp': 'x.x.x.x', 'mask': '255.255.255.0', 'gw': 'x.x.x.x'}}, 'exe_time': 40}
DEBUG:miio.device:Detected model 090615.curtain.jldj03
DEBUG:miio.miioprotocol:x.x.x.x:54321 >>: {'id': 2, 'method': 'get_properties', 'params': [{'did': '2-1', 'siid': 2, 'piid': 1}]}
DEBUG:miio.protocol:Unable to parse json '{"id":2,"result":[{"did":"2-1","siid":2,"piid":1,"code":0,"value":00}],"exe_time":420}': Expecting ',' delimiter: line 1 column 68 (char 67)
DEBUG:miio.click_common:Exception: Unable to parse message payload
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/miio/protocol.py", line 195, in _decode
    return json.loads(decoded)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 68 (char 67)

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

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/miio/click_common.py", line 51, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/miio/click_common.py", line 305, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/miio/click_common.py", line 270, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/miio/click_common.py", line 217, in call
    return method(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/miio/click_common.py", line 184, in _wrap
    return func(self, *args, **kwargs)
  File "/usr/lib/python3.9/site-packages/miio/miot_device.py", line 117, in get_property_by
    return self.send(
  File "/usr/lib/python3.9/site-packages/miio/device.py", line 107, in send
    return self._protocol.send(
  File "/usr/lib/python3.9/site-packages/miio/miioprotocol.py", line 194, in send
    m = Message.parse(data, token=self.token)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 288, in parse
    return self.parse_stream(io.BytesIO(data), **contextkw)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 300, in parse_stream
    return self._parsereport(stream, context, "(parsing)")
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 1981, in _parse
    subobj = sc._parsereport(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 2439, in _parse
    return self.subcon._parsereport(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 3987, in _parse
    obj = self.subcon._parsereport(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 4265, in _parse
    obj = self.subcon._parsereport(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
  File "/usr/lib/python3.9/site-packages/construct/core.py", line 698, in _parse
    return self._decode(obj, context, path)
  File "/usr/lib/python3.9/site-packages/miio/protocol.py", line 201, in _decode
    raise PayloadDecodeException(
miio.exceptions.PayloadDecodeException: Unable to parse message payload
Error: Unable to parse message payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant