mclarkk / lifxlan

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

Discovery + Use Appears to Fail on LIFX Firmware 3.70 #168

Open ne0ndrag0n opened 3 years ago

ne0ndrag0n commented 3 years ago

Problem Description

Using lifxlan library in a support script to power a custom home automation server. I have two LIFX bulbs that were recently upgraded to firmware version 3.70. Following the firmware update the library appears to be unable to communicate with the bulbs in any fashion. Version 3.70 appears to have been released after the last update to the repository and I suspect the lifxlan library may require changes to be compatible with firmware 3.70.

Applicable Version

$ pip3 show lifxlan
Name: lifxlan
Version: 1.2.7
Summary: API for local communication with LIFX devices over a LAN.
Home-page: http://github.com/mclarkk/lifxlan
Author: Meghan Clark
Author-email: mclarkk@berkeley.edu
License: MIT
Location: /home/ashley/.local/lib/python3.6/site-packages
Requires: ifaddr, bitstring

Reproduction Steps

The following script will fail to discover any devices:

Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lifxlan import LifxLAN
>>> lifxlan = LifxLAN()
>>> lifxlan.get_lights()
[]

The device appears on network in router settings and is fully controllable via LIFX android app. Using MAC address and ip address reported in router settings, I run this script but to no effect:

Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lifxlan import Light
>>> light = Light( "<reported mac address>", "10.0.0.9" )
>>> light.set_power( 0 )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ashley/.local/lib/python3.6/site-packages/lifxlan/light.py", line 56, in set_power
    self.req_with_ack(LightSetPower, {"power_level": 0, "duration": duration})
  File "/home/ashley/.local/lib/python3.6/site-packages/lifxlan/device.py", line 501, in req_with_ack
    self.req_with_resp(msg_type, Acknowledgement, payload, timeout_secs, max_attempts)
  File "/home/ashley/.local/lib/python3.6/site-packages/lifxlan/device.py", line 550, in req_with_resp
    raise WorkflowException("WorkflowException: Did not receive {} from {} (Name: {}) in response to {}".format(str(response_type), str(self.mac_addr), str(self.label), str(msg_type)))
lifxlan.errors.WorkflowException: WorkflowException: Did not receive [<class 'lifxlan.msgtypes.Acknowledgement'>] from d0:73:d5:68:e1:42 (Name: None) in response to <class 'lifxlan.msgtypes.LightSetPower'>
ne0ndrag0n commented 3 years ago

Update: Without any changes it appears discovery and lighting have spontaneously resolved and the library is now working properly again.

However while this was occurring, a lack of discovery results was a fairly reliable bug and I would get the same result running the above scripts many times. This may still be a bug, or it may have been a malfunction in the bulbs.

bobbobbio commented 1 year ago

I just updated my lights and I'm having the exact same issue. Do you know what you might have done which made it somehow resolve itself?

bobbobbio commented 1 year ago

My issue stemmed from the fact that the mac-address changed for the lights after I updated them, so I was getting the same error but might be a slightly different reason. Discovery seemed to work for me, although the mac-address the light has ins't the same one it uses to connect to the network.

bobbobbio commented 1 year ago

relevant link about the mac-address change https://lan.developer.lifx.com/page/beta-firmware-updates