bitstring.CreationError : Token with length 64 packed with value of length 0 lifxlan issue
The firelight runs into an error after selecting the lifx system, either from an argument or from the prompt
🐟 ❯ firelight
Welcome to Firelight!
We currently support the following lights:
lifx
openrgb
Which system do you use?
lifx
lifx selected.
Traceback (most recent call last):
File "/home/david/.local/bin/firelight", line 8, in <module>
sys.exit(main())
File "/home/david/.local/lib/python3.10/site-packages/firelight/firelight.py", line 59, in main
system = get_system(system)()
File "/home/david/.local/lib/python3.10/site-packages/firelight/interfaces/lifx/lifx.py", line 17, in __init__
self.discover_lights()
File "/home/david/.local/lib/python3.10/site-packages/firelight/interfaces/lifx/lifx.py", line 23, in discover_lights
lights = self._lifxlan.get_color_lights()
File "/home/david/.local/lib/python3.10/site-packages/lifxlan/lifxlan.py", line 86, in get_color_lights
all_lights = self.get_lights()
File "/home/david/.local/lib/python3.10/site-packages/lifxlan/lifxlan.py", line 42, in get_lights
self.discover_devices()
File "/home/david/.local/lib/python3.10/site-packages/lifxlan/lifxlan.py", line 50, in discover_devices
responses = self.broadcast_with_resp(GetService, StateService,)
File "/home/david/.local/lib/python3.10/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 "/home/david/.local/lib/python3.10/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 "/home/david/.local/lib/python3.10/site-packages/lifxlan/message.py", line 43, in __init__
self.packed_message = self.generate_packed_message()
File "/home/david/.local/lib/python3.10/site-packages/lifxlan/message.py", line 47, in generate_packed_message
self.header = self.get_header()
File "/home/david/.local/lib/python3.10/site-packages/lifxlan/message.py", line 55, in get_header
frame_addr = self.get_frame_addr()
File "/home/david/.local/lib/python3.10/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 "/home/david/.local/lib/python3.10/site-packages/bitstring.py", line 4689, in pack
s._addright(BitStream._init_with_token(name, length, value))
File "/home/david/.local/lib/python3.10/site-packages/bitstring.py", line 1435, in _init_with_token
raise CreationError(f"Token with length {token_length} packed with value of length {b.len} "
bitstring.CreationError: Token with length 64 packed with value of length 0 (bits:64=0).
I believe this was related to this issue with the lifxlan module. The fix is on the lifxlan github repo but not in the version installed by pip.
I removed the older lifxlan version from pip and firelight and then installed lifxlan from the github repo (running sudo python setup.py install) and reinstalling firelight and it seems to have resolved the issue.
🐟 ❯ firelight lifx
lifx selected.
['Hall', 'Living Room', 'Kitchen', 'Stairway', 'Bedroom', 'Closet', 'TV Group']
Found the following groups:
Hall
Living Room
Kitchen
Stairway
Bedroom
Closet
TV Group
If you'd like to use a certain group, enter the name of the group.
Otherwise, if you'd like to use all the lights, hit enter.
Hall
All good to go! Sit back and enjoy the show :)
Not sure what the best way to resolve this in firelight would be or why the pip version of the lifxlan is a couple years old.
Thanks!
Thanks for bringing this up! I see an issue was raised in lifxlan. If the pip version doesn't get updated, I'll add a copy to this repo as a local dependency.