mclarkk / lifxlan

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

"It's no longer possible to auto initialise a bitstring from an integer" error #181

Open ath0rus opened 11 months ago

ath0rus commented 11 months ago

as the title suggests I keep getting It's no longer possible to auto initialise a bitstring from an integer. Use 'Bits(0)' instead of just '0' as this makes it clearer that a bitstring of 0 zero bits will be created. when ever I try to use the library, is there something im doing wrong and how can i fix it

ath0rus commented 11 months ago

my code is as follows `from lifxlan import LifxLAN import time

def main():

Initialize LifxLAN object

lifx = LifxLAN(1)  # 1 light

# Get the first light
light = lifx.get_lights()[0]

# Store the current color
original_color = light.get_color()

# Set the light to red
red_color = [65535, 65535, 65535, 3500]  # [Hue, Saturation, Brightness, Kelvin]
light.set_color(red_color, rapid=True)

# Wait for 3 seconds
time.sleep(3)

# Revert to the original color
light.set_color(original_color, rapid=True)

if name == "main": main()`

curtsy of chatgpt4

salil-khanna commented 11 months ago

facing same issue :(

aredon commented 11 months ago

I'm getting hit by this as well now. I thought it was my own inputs to set_zone_colors() but seeing this here is worrying...

aredon commented 11 months ago

Ok I'm digging in a bit here and it looks like bitstring is another package. Lifxlan is using bitstring.pack() in message.py in order to send information to the light. I would suspect that is where the error lives.

aredon commented 11 months ago

It might be possible to load an older version of bitstring. It appears as of 4.1.0 this was disallowed.

HaberHash commented 11 months ago

I had a similar issue a while back. This is the feedback pedantic79 sent me privately:

The problem is that the current version of lifxlan only works with v3 of bitstring, and you have v4 of bitstring. So your options are:

  1. If you pip install lifxlan, then run pip list, you should see bitstring 4.0.2 (or some other version 4 bitstring package). To fix this run pip install bitstring==3.1.9, this will force your install to work.

  2. Rather than installing in a global python package directory, consider using venv. Once your venv is activated, then follow the instructions in 1. This solution is useful if you have other things that depend on bitstring and installing bitstring==3.1.9 will conflict globally.

  3. Wait until there is a version of lifxlan that supports bitstring

——

1 worked for me although a longer-term fix would be better. I discovery issues and crashes.

aredon commented 11 months ago

Nice! I figured that would work. Unfortunately I'm running this in home assistant which appears to be running bitstring 4 so I'll have to find another solution.

I had a similar issue a while back. This is the feedback pedantic79 sent me privately:

The problem is that the current version of lifxlan only works with v3 of bitstring, and you have v4 of bitstring. So your options are:

  1. If you pip install lifxlan, then run pip list, you should see bitstring 4.0.2 (or some other version 4 bitstring package). To fix this run pip install bitstring==3.1.9, this will force your install to work.
  2. Rather than installing in a global python package directory, consider using venv. Once your venv is activated, then follow the instructions in 1. This solution is useful if you have other things that depend on bitstring and installing bitstring==3.1.9 will conflict globally.
  3. Wait until there is a version of lifxlan that supports bitstring

——

1 worked for me although a longer-term fix would be better. I discovery issues and crashes.