studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.52k stars 267 forks source link

Long tail delay #105

Open jtulak opened 7 years ago

jtulak commented 7 years ago

Hi. I'm experimenting with this project and don't know if it is normal behaviour or not. If I do any state change, e.g. phue.AllLights(b).brightness=100, the bulbs react immediately, but the call takes about three or four seconds to end, like if it was stuck. It doesn't matter if I control just one light or all at once, or whether I use transitiontime parameter, I always get this tail delay.

When I control the bulbs through OpenHab, there is no such delay, I can send another command as soon as the transition time finishes. I don't see any such issue when I use another library to control IKEA Tradfri lights. So it seems to be an issue with this library and not the rest of my setup...

I tried both the version in pip and current master from the repo.

Is there something I can do about this? Thanks.

jtulak commented 7 years ago

I did some digging and it seems that this is an inherent property of Hue bulbs that can be masked out. The Hue bulbs (or hub) react immediately to any change but then waits before confirming it and closing the connection.

So, the solution is to control each bulb separately and in a standalone thread. Fire&forget approach with import threading seems to be enough. Perhaps something like this could be added to this project?