Skip to content

Conversation

@akash329d
Copy link

Add some retry logic to the light controller. Since these are UDP packets I've had lots of issues with setting a state in home assistant and it not being reflected by the light (this is specifically with the ceiling fixture, but I'm assuming it affects others too). This attempts to solve the issue. We do the following:

  1. Send initial update message; immediately send state update request 100ms afterwards.
  2. If we don't receive a state update, we attempt to retry sending the update request w/ the following retry pattern: [0.2, 0.3, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]. This totals around 30 seconds before entirely giving up.
  3. While waiting if we ever receive a state update response we immediately cancel all further retries.

If any other command is submitted on the device, it overrides the previous command and that task is immediately cancelled.

I know this is a bit of an aggressive strategy, so am open to feedback but it was pretty unresponsive previously and I find that my requests go through a lot more frequently now.

@xav-ie
Copy link

xav-ie commented Mar 26, 2025

I also experience issues with bad states or lights only doing half of what I request (e.g. turning on but not setting color).
I was able to figure out how to override my local version with this PR version. I will update here if I face no issues after a week :).

@xav-ie
Copy link

xav-ie commented Apr 1, 2025

Update: This PR seems to have fixed my issues. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants