-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Don't add fritz entities with update_before_add #110667
Conversation
Hey there @mammuth, @AaronDavidSchneider, @chemelli74, @mib1185, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@@ -68,7 +68,7 @@ async def async_setup_entry( | |||
if description.is_suitable(connection_info) | |||
] | |||
|
|||
async_add_entities(entities, True) | |||
async_add_entities(entities) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to set update_before_add
to True
because we do an initial config entry refresh during setup, before adding platforms
if self.fritz_status: | ||
self.data["entity_states"][key] = update_fn( | ||
self.fritz_status, self.data["entity_states"].get(key) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have fritz_status, call the value function
@@ -317,10 +321,7 @@ async def _async_update_data(self) -> UpdateCoordinatorDataType: | |||
await self.async_scan_devices() | |||
for key in list(self._entity_update_functions): | |||
_LOGGER.debug("update entity %s", key) | |||
entity_data["entity_states"][ | |||
key | |||
] = await self.hass.async_add_executor_job( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my understanding, all the value functions just look up data which is already in the coordinator, so there's no need to run them in executor threads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @emontnemery
nice finding and thx for the fix 👍
indeed the fritz_status
does i/o on every property access, so we need to keep it run in executer
Thanks for the review @mib1185 🎉 ../Frenck |
Proposed change
Don't add fritz entities with update_before_add set to True
This fixes racy behavior during startup which were causing fritz tests to flap
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: