mclarkk / lifxlan

Python library for accessing LIFX devices locally using the official LIFX LAN protocol.
MIT License
502 stars 115 forks source link

user error? or library? #188

Open spencercap opened 4 days ago

spencercap commented 4 days ago

Hi- so happy this library exists, would love to get it working!

somehow i'm caught up at even the simplest sweep for devices on my network (LifxLAN().get_lights())

i'm on a mac running 14.3.1 w/ python v 3.12.4 i AM able to ping my devices' IPs from terminal (though 2 show up in my router's device list with 1 final digit different, 1 of them is ping-able)

here are the errors i'm seeing, any help would be rad! cheers

python 05_LIFXLan-lib.py 
Traceback (most recent call last):
  File "/Users/spencer/Documents/lifx-lights/05_LIFXLan-lib.py", line 39, in <module>
    devices = lifx.get_lights()
              ^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/lifxlan.py", line 42, in get_lights
    self.discover_devices()
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/lifxlan.py", line 50, in discover_devices
    responses = self.broadcast_with_resp(GetService, StateService,)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/lifxlan.py", line 234, in broadcast_with_resp
    msg = msg_type(BROADCAST_MAC, self.source_id, seq_num=0, payload=payload, ack_requested=False, response_requested=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/msgtypes.py", line 19, in __init__
    super(GetService, self).__init__(MSG_IDS[GetService], target_addr, source_id, seq_num, ack_requested, response_requested)
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/message.py", line 43, in __init__
    self.packed_message = self.generate_packed_message()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/message.py", line 47, in generate_packed_message
    self.header = self.get_header()
                  ^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/message.py", line 55, in get_header
    frame_addr = self.get_frame_addr()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/lifxlan/message.py", line 80, in get_frame_addr
    mac_addr = little_endian(bitstring.pack(mac_addr_format, convert_MAC_to_int(self.target_addr)))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/spencer/Documents/lifx-lights/.venv/lib/python3.12/site-packages/bitstring/methods.py", line 76, in pack
    raise CreationError(f"Token with length {length} packed with value of length {len(value)}.")
ValueError: Token with length 64 packed with value of length 0.
spencercap commented 3 days ago

ah, solved (ish) downgraded to python v 3.6.15 and it works as expected.

didnt mess about further to find which version it breaks at

deseipel commented 1 day ago

same issue, I'm on Python 3.8.8.