mclarkk / lifxlan

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

Can't get Group or Light to work with static MAC/IP definitions... #167

Closed dspears0809 closed 2 years ago

dspears0809 commented 2 years ago

Can't get this to work...

#!/usr/bin/env python

from lifxlan import Light, Group

def main():

  a19_1 = Light('d0:73:d5:22:4a:61', '192.168.0.211')
  a19_2 = Light('d0:73:d5:22:41:f5', '192.168.0.212')
  a19_3 = Light('d0:73:d5:20:ab:e7', '192.168.0.213')

  g = Group([a19_1, a19_2, a19_3])
  g.set_power("on")

if __name__=="__main__":
    main()

Results in...

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/group.py", line 42, in set_power_helper
    if device.is_light():
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 384, in is_light
    self.vendor, self.product, self.version = self.get_version_tuple()
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 279, in get_version_tuple
    response = self.req_with_resp(GetVersion, StateVersion)
  File "/usr/local/lib/python2.7/dist-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)))
WorkflowException: WorkflowException: Did not receive [<class 'lifxlan.msgtypes.StateVersion'>] from d0:73:d5:22:41:f5 (Name: None) in response to <class 'lifxlan.msgtypes.GetVersion'>
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/group.py", line 42, in set_power_helper
    if device.is_light():
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 384, in is_light
    self.vendor, self.product, self.version = self.get_version_tuple()
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 279, in get_version_tuple
    response = self.req_with_resp(GetVersion, StateVersion)
  File "/usr/local/lib/python2.7/dist-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)))
WorkflowException: WorkflowException: Did not receive [<class 'lifxlan.msgtypes.StateVersion'>] from d0:73:d5:22:4a:61 (Name: None) in response to <class 'lifxlan.msgtypes.GetVersion'>
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/group.py", line 42, in set_power_helper
    if device.is_light():
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 384, in is_light
    self.vendor, self.product, self.version = self.get_version_tuple()
  File "/usr/local/lib/python2.7/dist-packages/lifxlan/device.py", line 279, in get_version_tuple
    response = self.req_with_resp(GetVersion, StateVersion)
  File "/usr/local/lib/python2.7/dist-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)))
WorkflowException: WorkflowException: Did not receive [<class 'lifxlan.msgtypes.StateVersion'>] from d0:73:d5:20:ab:e7 (Name: None) in response to <class 'lifxlan.msgtypes.GetVersion'>
Djelibeybi commented 2 years ago

This is because the latest LIFX firmware changed the MAC address of Gen3 and Gen4 bulbs to be different to the serial of the bulb. If you substract one from your MAC address (in hexadecimal), it should work, i.e. try:

a19_1 = Light('d0:73:d5:22:4a:60', '192.168.0.211')

Djelibeybi commented 2 years ago

For reference from a LIFX employee on Reddit: https://www.reddit.com/r/lifx/comments/pb9hbe/comment/hahsyp7/?utm_source=share&utm_medium=web2x&context=3

dspears0809 commented 2 years ago

Hi, thanks for the response. Well, as it turns out it was my fault :-( I didn't account for a change I made to static IPs (shifted the lightbulbs by 10 IP addresses). Sorry for opening the issue.