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

Auto: reload entity registry, show loading when changing servers #3769

Merged
merged 2 commits into from
Aug 8, 2023

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Aug 7, 2023

Summary

When changing servers the Auto interface (should) reload some server related stuff: the device registry and entities. In this PR:

  • actually reload the entity registry instead of keeping the registry for the first server
  • show a loading indicator while changing servers and loading registry/entities, instead of the screen for no entities while loading

Screenshots

n/a, it is like the first load

Link to pull request in Documentation repository

n/a

Any other notes

@jpelgrom jpelgrom marked this pull request as draft August 7, 2023 21:56
@jpelgrom
Copy link
Member Author

jpelgrom commented Aug 7, 2023

Changing this to draft because I realize I'm not handling stopping collection properly, this only works because of the screen lifecycle.

@jpelgrom
Copy link
Member Author

jpelgrom commented Aug 8, 2023

^ Screen does stop when changing servers, but server ID collection wasn't completing because of the allEntities.collect, meaning after the first server ID was collected it never collected another one and the issue surfaced again. This resulted in not always reloading the entity registry.

Now updated to wrap it in a Job so it doesn't block and actually cancels/invalidates correctly.

Initial load:

2023-08-08 17:42:22.464 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: started
2023-08-08 17:42:22.470 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received server 1
2023-08-08 17:42:26.064 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received new entities, invalidate true

After changing servers, note that on load the server ID is the same and it will take 30ms to change which would result in no reloading as it collected server ID 1 + the loading indicator not showing up here:

2023-08-08 17:42:29.189 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: started
2023-08-08 17:42:29.197 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received server 1
2023-08-08 17:42:29.199 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received new entities, invalidate false
2023-08-08 17:42:29.232 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received server 3
2023-08-08 17:42:30.056 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received new entities, invalidate true
2023-08-08 17:42:30.240 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received new entities, invalidate true
2023-08-08 17:42:31.723 31063-31063 MainVehicleScreen       io....stant.companion.android.debug  D  Lifecycle: received new entities, invalidate false

@jpelgrom jpelgrom marked this pull request as ready for review August 8, 2023 15:51
@jpelgrom jpelgrom requested a review from dshokouhi August 8, 2023 15:51
@JBassett JBassett merged commit f90d806 into home-assistant:master Aug 8, 2023
@jpelgrom jpelgrom deleted the auto-reload-server-change branch August 8, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants