-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Cache entity properties that are never expected to change in the base class #95315
Conversation
I'm not sure this is actually going to work, but it should would be nice to calculate these once |
This is a bit of a grind, but |
there are just too many things that change their UOM to do here. This would need to be another PR since it will need a lot more exploration to make work |
just need to adjust that last test. But its too late in the cycle to merge this so will do after beta |
need to fix tests for this again. Might be good to wait for https://docs.python.org/3.12/whatsnew/3.12.html#pep-698-override-decorator-for-static-typing as well |
2a1397e
to
96e610e
Compare
no change squash to see if the CI will try again |
that seems to have fixed it |
double checked to make sure we didn't get any changes from the squash |
@@ -781,7 +790,7 @@ def __init__( | |||
additional_info=[property_key_name] if property_key_name else None, | |||
) | |||
|
|||
@property | |||
@property # type: ignore[override] |
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.
These probably can be cached, but that is left up to the zwave_js code owners for a future PR as I didn't want to make a change here that might have side effects.
thanks will update all my production to give it a final test (running an older version of this now) |
Also going to run a |
Still deploying to more systems. |
all of primary production looks good. core/homeassistant/util/location.py Line 78 in 5f20725
no bug here |
finishing up testing on the secondary systems .... |
pushed it to my box with 3 zwave js devices. all good |
All looks good. I'm out of ways to test this, so lets do it. |
Thanks for all the 👀 |
Regarding the profiling hit: I suspect the convergence threshold can be increased significantly: core/homeassistant/util/location.py Lines 28 to 29 in 5f20725
The threshold is for the difference in longitude for two points (on the auxiliary sphere) for successive approximations, so 1e-12 corresponds to a change of nearly a tenth of a mm, which I think may be a little excessive. We can probably bump it up to 1e-10 and still retain ~cm accuracy and save on the number of iterations. Or switch to a C library 😄. |
If I see it again in profiles with any frequency, I'll probably make a c lib. |
Bummer, but we still ended up with a lot of value from all the PRs that moved things to be done in the constructor anyways |
Yes, but I suggest we start an architectural discussing proposing making some attributes frozen or cached. Overall it will be a breaking change. Erik mentioned helpers and may be some other integrations (like MQTT) are having the ability updating the |
The alternative solution, which has some more benefits, is to avoid writing state in the first place by not calling |
Breaking change
Cache entity properties that are never expected to change in the base class
attribution
device_class
translation_key
are now cached and only calculated once.
Proposed change
There is some risk that there are bugs in entities that may incorrectly set these values to
None
and than set the correct value after startup, or the value is set late because its not available at startup (or when state is first written) for some reason which would result in them being cached incorrectly. edit: update: Since we checked every integration that was overridingdevice_class
this far less likely at this point.Type of change
Additional information
Checklist
black --fast 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:
TODO:
Research: