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

Always getting EOFError when trying to turn on the bulb #3

Open
Refuhr opened this issue Sep 14, 2022 · 0 comments
Open

Always getting EOFError when trying to turn on the bulb #3

Refuhr opened this issue Sep 14, 2022 · 0 comments

Comments

@Refuhr
Copy link

Refuhr commented Sep 14, 2022

My setup:
Rpi0 W, Philips Hue white GU10 (paired and trusted via bluetoothctl)
My script:

import libhueble
import asyncio

async def main():
    lamp = libhueble.Lamp('C1:14:8A:F4:FA:CC')
    await lamp.connect()
    print('Connected.')
    try:
        await lamp.set_power(True)
        await lamp.set_brightness(1.0)
        # await lamp.set_color_rgb(1.0, 0.0, 0.0)
    finally:
        await lamp.disconnect()

asyncio.run(main())

Error:

Traceback (most recent call last):
  File "/home/pi/libhueble/src/test.py", line 15, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/pi/libhueble/src/test.py", line 9, in main
    await lamp.set_power(True)
  File "/home/pi/libhueble/src/libhueble.py", line 52, in set_power
    await self.client.write_gatt_char(CHAR_POWER, bytes([1 if on else 0]), response=True)
  File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 707, in write_gatt_char
    reply = await self._bus.call(
  File "/home/pi/.local/lib/python3.9/site-packages/dbus_fast/aio/message_bus.py", line 337, in call
    await future
  File "/home/pi/.local/lib/python3.9/site-packages/dbus_fast/aio/message_bus.py", line 404, in _message_reader
    if self._unmarshaller.unmarshall():
  File "/home/pi/.local/lib/python3.9/site-packages/dbus_fast/_private/unmarshaller.py", line 332, in unmarshall
    self._read_header()
  File "/home/pi/.local/lib/python3.9/site-packages/dbus_fast/_private/unmarshaller.py", line 271, in _read_header
    self.read_to_offset(HEADER_SIGNATURE_SIZE)
  File "/home/pi/.local/lib/python3.9/site-packages/dbus_fast/_private/unmarshaller.py", line 174, in read_to_offset
    raise EOFError()
EOFError

a part of unmarshaller.py:

def read_to_offset(self, offset: int) -> None:
        """
        Read from underlying socket into buffer.

        Raises MarshallerStreamEndError if there is not enough data to be read.

        :arg offset:
            The offset to read to. If not enough bytes are available in the
            buffer, read more from it.

        :returns:
            None
        """
        start_len = len(self.buf)
        missing_bytes = offset - (start_len - self.offset)
        if self.sock is None:
            data = self.stream.read(missing_bytes)
        else:
            data = self.read_sock(missing_bytes)
        if data == b"":
            raise EOFError()

This seems to be indicating that the pi can't read data from the bulb?!
I'm not sure what I did wrong here. Help is appreciated.

@Refuhr Refuhr changed the title Alway getting EOFError when trying to turn on the bulb Always getting EOFError when trying to turn on the bulb Sep 14, 2022
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

1 participant