mirror of
https://github.com/home-assistant/android
synced 2024-10-15 12:32:54 +00:00
Only subscribe to state changes for added controls (#2864)
- Instead of receiving all state changes when the device controls are open, only receive state changes for entities that were added as controls. This potentially reduces the amount of data used while controls are open.
This commit is contained in:
parent
69beab3a2a
commit
a31afb3455
|
@ -168,8 +168,7 @@ class HaControlsProviderService : ControlsProviderService() {
|
|||
|
||||
// Listen for the state changed events.
|
||||
webSocketScope.launch {
|
||||
integrationRepository.getEntityUpdates()?.collect {
|
||||
if (controlIds.contains(it.entityId)) {
|
||||
integrationRepository.getEntityUpdates(controlIds)?.collect {
|
||||
val control = domainToHaControl[it.domain]?.createControl(
|
||||
applicationContext,
|
||||
it as Entity<Map<String, Any>>,
|
||||
|
@ -181,7 +180,6 @@ class HaControlsProviderService : ControlsProviderService() {
|
|||
subscriber.onNext(control)
|
||||
}
|
||||
}
|
||||
}
|
||||
webSocketScope.launch {
|
||||
webSocketRepository.getAreaRegistryUpdates()?.collect {
|
||||
areaRegistry = webSocketRepository.getAreaRegistry()
|
||||
|
|
Loading…
Reference in a new issue