Fix excessive CPU usage when you're rate limited by the bulb, and/or on a spotty network
there is an infinite loop that - on error - immediately retries. this has the following consequences:
-
if you are on a spotty network, and you drop out, you will constantly try to retry the connection
-
if you are rate limited, the bulb will simply send nothing to you. because the system is constantly polling, you will immediately consume all CPU available to you.
-
the rate limits are going to be a little wonky if multiple instances of this application is running at once - or is simply threaded
this solves the problem by adding three random delays between 0-1 second, which (in my setup at least) on a rate-limited bulb no longer completely drains the CPU.