sanghviharshit / script.kodi.lifx.ambilight

💡📺🌈Kodi add-on for Lifx lights with ambilight support.
https://bit.ly/kodilifx
GNU General Public License v2.0
33 stars 13 forks source link

Plugin stops working if fails to receive a response from from light #6

Closed daviddever closed 6 years ago

daviddever commented 7 years ago

I noticed that after a seemingly random amount of time the plugin would stop working while watching a video in ambilight mode.

I found this error in the kodi log

18:26:16.022 T:140584396437248   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.IOError'>
                                            Error Contents: WorkflowException: Did not receive <class 'lifxlan.msgtypes.Acknowledgement'> in response to <class 'lifxlan.msgtypes.LightSetColor'>
                                            Traceback (most recent call last):
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/default.py", line 512, in <module>
                                                run()
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/default.py", line 343, in run
                                                fade_light_hsv(hue.light, hsvRatios[0])
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/default.py", line 380, in fade_light_hsv
                                                light.set_light2(h, s, v, kel=None, power=None, duration=duration)
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/resources/lib/hue.py", line 567, in set_light2
                                                group_light.set_color(color, data["transitiontime"] * 100, rapid=False)
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/resources/lib/lifxlan/light.py", line 65, in set_color
                                                self.req_with_ack(LightSetColor, {"color": color, "duration": duration})
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/resources/lib/lifxlan/device.py", line 387, in req_with_ack
                                                self.req_with_resp(msg_type, Acknowledgement, payload, timeout_secs, max_attempts)
                                              File "/home/kodi/.kodi/addons/script.kodi.lifx.ambilight/resources/lib/lifxlan/device.py", line 427, in req_with_resp
                                                raise IOError("WorkflowException: Did not receive {0} in response to {1}".format(str(response_type), str(msg_type)))
                                            IOError: WorkflowException: Did not receive <class 'lifxlan.msgtypes.Acknowledgement'> in response to <class 'lifxlan.msgtypes.LightSetColor'>
                                            -->End of Python script error report<--

It looks like the lifxlan throws an exception if it does not receive a response from the lifx light. This post recommends using the rapid=True option. https://community.lifx.com/t/lifxlan-mclarkk-help/2243

I tested changing group_light.set_color(color, data["transitiontime"] * 100, rapid=False) to group_light.set_color(color, rapid=True) and group_light.set_color(color, data["transitiontime"] * 100, rapid=False) to group_light.set_color(color, rapid=True) in hue.py (lines 337 and 567).

Maybe providing an option to use the rapid=True option or the exception in lifxlan could be handled in hue.py.

Thanks for all your work on this plugin.