mclarkk / lifxlan

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

Inconsistency with bitstring.py #117

Open mikcox opened 6 years ago

mikcox commented 6 years ago

Thanks for a great module. This has saved me a ton of time!

I'm trying to incorporate the lifxlan package into a custom twitch chatbot, but I'm experiencing issues that I've never run into before.

The chatbot service is running python 2.7 on a windows 10 box. When I try and run the following (mac_addr and ip_addr are both hard-coded strings that I've redacted for this post):

...
strip = MultiZoneLight(mac_addr, ip_addr)
all_zones = strip.get_color_zones()
original_zones = deepcopy(all_zones)
zone_count = len(all_zones)
...

I get the following error related to bitstring.py (which I've verified is installed on my system and is the most recent version 3.1.5):

Traceback (most recent call last):
File ".\Services\Scripts\IoTcontrol\IoTcontrol_StreamlabsSystem.py", line 82, in Execute
all_zones = strip.get_color_zones()
File "C:\Python27\Lib\site-packages\lifxlan\multizonelight.py", line 18, in get_color_zones
response = self.req_with_resp(MultiZoneGetColorZones, [MultiZoneStateZone, MultiZoneStateMultiZone], {"start_index":0, "end_index":255})
File
"C:\Python27\Lib\site-packages\lifxlan\device.py", line 494, in req_with_resp
msg = msg_type(self.mac_addr, self.source_id, seq_num=0, payload=payload, ack_requested=False, response_requested=True)
File "C:\Python27\Lib\site-packages\lifxlan\msgtypes.py", line 542, in __init__
super(MultiZoneGetColorZones, self).__init__(MSG_IDS[MultiZoneGetColorZones], target_addr, source_id, seq_num, ack_requested, response_requested)
File "C:\Python27\Lib\site-packages\lifxlan\message.py", line 43, in
__init__
self.packed_message = self.generate_packed_message()
File "C:\Python27\Lib\site-packages\lifxlan\message.py", line 46, in generate_packed_message
self.payload = self.get_payload()
File "C:\Python27\Lib\site-packages\lifxlan\msgtypes.py", line 547, in get_payload
start_index = little_endian(bitstring.pack("8", self.start_index))
File "C:\Python27\Lib\site-packages\lifxlan\message.py", line 134, in little_endian
int_bytes_little_endian = [int(bs.uintbe >> i & 0xff) for i in shifts]
File "C:\Python27\Lib\site-packages\bitstring.py", line 1463, in _getuintbe
return self._readuintbe(self.len, 0)
File "C:\Python27\Lib\site-packages\bitstring.py", line 1459, in _readuintbe
return self._readuint(length, start)
File "C:\Python27\Lib\site-packages\bitstring.py", line 1399, in _readuint
i = int(b, 16)
TypeError: expected str, got bytes

I've been bashing my head against a wall for the better part of a day trying to figure out where this issue is coming from. Does anybody here have any insight?

Thank you in advance!