Skip to content
New issue

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

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

Already on GitHub? # to your account

construct.core.StreamError: could not write bytes, expected 4, found 8 #227

Closed
syssi opened this issue Feb 17, 2018 · 5 comments
Closed

Comments

@syssi
Copy link
Collaborator

syssi commented Feb 17, 2018

@arekbulski Do you have an idea what's missing here?

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_platform.py", line 197, in _async_add_entity
    yield from entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/fan/xiaomi_miio.py", line 253, in async_update
    self._air_purifier.status)
  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/homeassistant/lib/python3.4/site-packages/miio/airpurifier.py", line 346, in status
    values.extend(self.send("get_prop", _props[:15]))
  File "/srv/homeassistant/lib/python3.4/site-packages/miio/device.py", line 227, in send
    m = Message.build(msg, token=self.token)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 281, in build
    self.build_stream(obj, stream, **kw)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 297, in build_stream
    self._build(obj, stream, context, "(building)")
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 1949, in _build
    buildret = sc._build(subobj, stream, context, path)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 2388, in _build
    return self.subcon._build(obj, stream, context, path)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 4181, in _build
    ret = self.subcon._build(value, stream, context, path)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 1949, in _build
    buildret = sc._build(subobj, stream, context, path)
  File "/srv/homeassistant/lib/python3.4/site-packages/construct/core.py", line 2392, in _build
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.StreamError: could not write bytes, expected 4, found 8
    (building) -> header -> device_id
@arekbulski
Copy link
Contributor

Its somehow related to that Hex field. Should have been fixed by #226 . Test against it.

@syssi
Copy link
Collaborator Author

syssi commented Feb 17, 2018

It looks like unhexlify is needed here. I'm testing #226 right now. This issue is the result.

syssi added a commit to syssi/python-miio that referenced this issue Feb 17, 2018
@syssi
Copy link
Collaborator Author

syssi commented Feb 17, 2018

Do you agree with this change? #228

@arekbulski
Copy link
Contributor

I am not faimiliar with how you handle the parsed data, I can only tell you what constructs are valid as far as the library itself is concerned.

I already declined to provide support. Ignoring repo, wont be tracking this thread.

@syssi
Copy link
Collaborator Author

syssi commented Feb 17, 2018

Wow. I didn't realize your decline. Sorry for the noise and the bad mood!? This wasn't my intention at any moment.

@syssi syssi closed this as completed in 026cf90 Feb 17, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants