Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only declare lifx update failure after 3 attempts #90872

Closed
wants to merge 1 commit into from

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Apr 5, 2023

Proposed change

These devices sometimes flakey and generate a lot of noise from drop outs since communication is UDP best-effort. We should only mark them unavailable if its not a momentary blip

fixes #78876

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

These devices sometimes flakey and generate a lot of noise
from drop outs since communication is UDP best-effort. We
should only mark them unavailable if its not a momentary blip

fixes #78876
@home-assistant
Copy link

home-assistant bot commented Apr 5, 2023

Hey there @Djelibeybi, mind taking a look at this pull request as it has been labeled with an integration (lifx) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of lifx can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign lifx Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@@ -189,41 +192,54 @@ def async_get_entity_id(self, platform: Platform, key: str) -> str | None:
async def _async_update_data(self) -> None:
"""Fetch all device data from the api."""
async with self.lock:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this lock, btw. I added it in the previous integration's incarnation to prevent multiple discoveries from firing at the same time, but that's no longer an issue (or possible).

For reference, Photons uses a Semaphore instead of a lock to limit the number of packets "in-flight", i.e. awaiting a response, but that's not bulb specific. Photons is essentially just a very fancy way of getting the least amount of packets on the network to do the most amount of work across the largest number of devices.

Comment on lines +210 to +212
# device.mac_addr is not the mac_address, its the serial number
if self.device.mac_addr == TARGET_ANY:
self.device.mac_addr = response.target_addr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: we should move this into the callback of async_execute_lifx so that it happens earlier.

@Djelibeybi
Copy link
Contributor

The code as written never gets passed a single attempt before the update coordinator marks the update as failed (for me). I refactored it like so: lifx_raise_fallback...Djelibeybi:home-assistant-core:lifx_raise_fallback (which is NOT production ready because I'm using warning logs for debugging purposes).

This refactor has not resulted in a single timeout at all. Not one in over 15 minutes of running. That's unprecedented with my fleet. Tests need to be updated, but they still all pass too.

@bdraco
Copy link
Member Author

bdraco commented Apr 6, 2023

The code as written never gets passed a single attempt before the update coordinator marks the update as failed (for me). I refactored it like so: lifx_raise_fallback...Djelibeybi:home-assistant-core:lifx_raise_fallback (which is NOT production ready because I'm using warning logs for debugging purposes).

This refactor has not resulted in a single timeout at all. Not one in over 15 minutes of running. That's unprecedented with my fleet. Tests need to be updated, but they still all pass too.

I'm happy to close this PR if you want to open another one. I'm working on release issues so it will be a while before I get back to this.

@Djelibeybi
Copy link
Contributor

Sure, that works. I'll fix up the tests shortly.

@Djelibeybi
Copy link
Contributor

I've just opened #90891 as a replacement for this one.

@bdraco
Copy link
Member Author

bdraco commented Apr 6, 2023

closing in favor of #90891

@bdraco bdraco closed this Apr 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2023
@bdraco bdraco deleted the lifx_raise_fallback branch May 25, 2023 13:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lifx integration with many devices frequently goes unavailable
2 participants