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

user error? or library? #188

Open
spencercap opened this issue Oct 4, 2024 · 7 comments
Open

user error? or library? #188

spencercap opened this issue Oct 4, 2024 · 7 comments

Comments

@spencercap
Copy link

spencercap commented Oct 4, 2024

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
Copy link
Author

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
Copy link

deseipel commented Oct 7, 2024

same issue, I'm on Python 3.8.8.

@cwshugg
Copy link

cwshugg commented Oct 12, 2024

Looks like this was fixed in this PR, as pointed out by this issue. I ran into this on Python 3.10.12, but I realized it may be because I installed using python3 -m pip install lifxlan. According to pypi.org, there hasn't been a release since 2021, so perhaps the fix didn't make it into pip yet.

@mclarkk - would it be possible to get an updated release so the pip method of installation pulls in the latest updates?

@HaberHash
Copy link

HaberHash commented Oct 13, 2024 via email

@cwshugg
Copy link

cwshugg commented Oct 13, 2024

@HaberHash yes, I was able to get it working on Python 10. Instead of running python3 -m pip install lifxlan, clone the repo on your machine, cd into it, and install it with the setup.py script:

git clone https://github.com/mclarkk/lifxlan
cd lifxlan
python3 -m pip install ./

This got things working for me, and this bug has not been an issue.

@mclarkk
Copy link
Owner

mclarkk commented Oct 13, 2024

@mclarkk - would it be possible to get an updated release so the pip method of installation pulls in the latest updates?

Done! Everyone with pip-installed lifxlan can get the fix now with pip install lifxlan --upgrade.

@spencercap
Copy link
Author

works! thanks @mclarkk 🙏

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

5 participants