API timeout after 6ish seconds

I’m using the API (again) to run an automated python script for controlling my 70+ LIFX products around my house. I send commands via python’s requests module and analyze the response to ensure all of the lights got the command. An observation that I’ve noted is that the API will wait up to around 6 seconds for all lights to reply or it will send back “time_out” responses for each light that doesn’t send back an “ok” status. I would like to use this to re-send the message to lights that time_out, however, some lights that responded “time_out” did get the message but can take up to a whole minute to change state. This is VERY common for the LIFX Mini product. I have 9 of these lights in my chandelier and about half of the time I send a group command to these lights, some or most will time out according to the request response but will eventually change state up to 1 minute later.
My question is, is it possible to increase the amount of time that the API waits to hear back from the lights to consider them “timed out”? Also, why is this such an issue with the Mini lights? I’ve also noted that the LIFX Mini lights also have 2 different MAC addresses when none of the other lights do.

I do something similar, but I do it via UDP instead of the API. I tried the API’s all endpoint but it was just too slow for my needs so I had to refactor my code.

Funny thing is, I run into the same issues you describe with UDP. Bulbs regularly timeout and as such I had to introduce routines to run in another thread to manage these timeouts and reconnect the bulb. The beams constantly timeout, but I figured it was because I was hammering 50+ lights with UDP requests. I find it interesting that you’re seeing the same behavior.

1 Like

I also have scripts that I’ve written to control my lights with the LAN protocol. I send my packets with the “acknowledgement required” flag set and use that to determine if the light got the message. Unfortunately I can’t send the message to a group or location so I have to make a loop to send the message to a list of lights and listen to a response from each, re-sending to all that don’t respond. I have a delay set between each packet to avoid “packet storms” but I’ve noticed that the LIFX Mini line of products seem to be more problematic than the rest of my devices (LIFX BR30, LIFX A19 and Z strips). I have no experience with Tiles or Beams.