KieronQuinn / ClassicPowerMenu

Power Menu Replacement for Android
Apache License 2.0
675 stars 22 forks source link

Home Assistant entities loading #81

Closed NylonDiamond closed 10 months ago

NylonDiamond commented 1 year ago

My Home Assistant tiles are all saying loading. It seems to work once after a phone reboot. But after that, every time I show the tiles, they all say loading. Any idea on where I should look for a solution to this? The google home tiles are working fine btw.

NekoPavel commented 1 year ago

Same issue here. The controls work fine from the Android native "Device Controls" menu however.

NylonDiamond commented 1 year ago

Yea, I'm using those in the meantime. But, I much prefer the power menu. I'll spend some time trying to figure out the issue.

jce12356 commented 1 year ago

Glad I'm not the only one having this issue. This issue only occur on the app version which the "Manage Device Controls" setting was introduced. As I downgraded the Home Assistant companion app, the "always loading" issue disappeared. So i guess the new setting option has something to do with the issue.

HA_app_setting
AlessandroTischer commented 1 year ago

Same here. Is there a way to work this around or downgrade is the only way?

NylonDiamond commented 1 year ago

I've just been using the Google home quick settings in the meantime. They are much slower but at least they work.

AlessandroTischer commented 1 year ago

I don't know if you noticed this, but the controls load and work at first access (after a reboot), then stop. I don't know if this can be anyhow useful in order to debug...

FrankSalmick commented 1 year ago

I also have this issue on my oneplus 9 on android 13. My workaround is to use the home assistant tiles in the quick settings menu. These work when your phone is locked.

I noticed they also work 1 time after you add or remove tiles from the Add menu behind the 3 dots. It also works the first time after you reboot home assistant.

Maybe these will be helpful.

Home assistant app logcat:

01-22 17:28:47.645 12397 12397 D HaConProService: publisherFor [switch.kitchen_multi_on_off, switch.living_lamp_right_on_off]
01-22 17:28:47.646 12397 18085 D HaConProService: request 100000
01-22 17:28:47.648 12397 18100 D WebSocketRepository: Sending message 22: {type=config/area_registry/list, id=22}
01-22 17:28:47.649 12397 18100 D WebSocketRepository: Message number 22 sent
01-22 17:28:47.650 12397 12490 D UrlRepository: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
01-22 17:28:47.650 12397 12490 D UrlRepository: Using external URL
01-22 17:28:47.652 12397 12497 D WebSocketRepository: Sending message 23: {type=config/device_registry/list, id=23}
01-22 17:28:47.654 12397 12497 D WebSocketRepository: Message number 23 sent
01-22 17:28:47.654 12397 12492 D WebSocketRepository: Sending message 24: {type=config/entity_registry/list, id=24}
01-22 17:28:47.655 12397 12492 D WebSocketRepository: Message number 24 sent
01-22 17:28:47.664 12397 12498 D WebSocketRepository: Websocket: onMessage (text)
01-22 17:28:47.666 12397 12498 D WebSocketRepository: Message number 22 received
01-22 17:28:47.689 12397 12498 D WebSocketRepository: Websocket: onMessage (text)
01-22 17:28:47.698 12397 12498 D WebSocketRepository: Message number 23 received
01-22 17:28:47.699 12397 12498 D WebSocketRepository: Message number 24 received
01-22 17:28:47.720 12397 18069 D UrlRepository: localUrl is: false, usesInternalSsid is: false, usesWifi is: true

CPM logcat

01-22 17:27:23.613  5874 18091 D ControlsProviderLifecycleManager: Binding service Intent { cmp=io.homeassistant.companion.android/.controls.HaControlsProviderService (has extras) }
01-22 17:27:23.613  5874 18091 D ControlsListingControllerImpl: Subscribing callback, service count: 3
01-22 17:27:23.628  5874  5874 I Quality : Skipped: true 1 cost 11.323223 refreshRate 8259321 bit true processName com.kieronquinn.app.classicpowermenu
01-22 17:27:23.632  5874  5874 D AutofillManager: Fill dialog is enabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate]
01-22 17:27:23.632  5874  5874 V TextView: notifyAutoFillManagerAfterTextChanged
01-22 17:27:23.632  5874  5874 V AutofillManager: notifyValueChanged(1073741824): ignoring on state UNKNOWN
01-22 17:27:23.633  5874  5874 V TextView: notifyAutoFillManagerAfterTextChanged
01-22 17:27:23.634  5874  5874 V AutofillManager: notifyValueChanged(1073741824): ignoring on state UNKNOWN
01-22 17:27:23.637  5874  5874 V TextView: notifyAutoFillManagerAfterTextChanged
01-22 17:27:23.637  5874  5874 V AutofillManager: notifyValueChanged(1073741825): ignoring on state UNKNOWN
01-22 17:27:23.637  5874  5874 V TextView: notifyAutoFillManagerAfterTextChanged
01-22 17:27:23.637  5874  5874 V AutofillManager: notifyValueChanged(1073741825): ignoring on state UNKNOWN
01-22 17:27:23.645  5874  5874 D ControlsProviderLifecycleManager: onServiceConnected ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService}
01-22 17:27:23.645  5874  5874 D ControlsProviderLifecycleManager: handle queue 1 items to run
01-22 17:27:23.645  5874  5874 D ControlsProviderLifecycleManager: subscribe ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService} - [switch.kitchen_multi_on_off, switch.living_lamp_right_on_off]
01-22 17:27:23.647  5874 18091 D ControlsProviderLifecycleManager: startSubscription: android.service.controls.IControlsSubscription$Stub$Proxy@44db02f
01-22 17:27:23.957  5874  5874 D VRI[PowerMenuActivity]: onFocusEvent true
NylonDiamond commented 1 year ago

It has something to do with OpenGLRenderer but I'm not an Android developer.

I think It has to do with these two lines:

03-06 21:20:22.427 13200 10578 E OpenGLRenderer: Unable to match the desired swap behavior.
03-06 21:20:22.438 13200 10578 W Parcel  : Expecting binder but got null!

or possible this as well

03-06 21:19:50.871  1949  3651 D CoreBackPreview: Window{2da437c u0 PopupWindow:f88e6e6}: Setting back callback null
03-06 21:19:50.872  1949 14318 W InputManager-JNI: Input channel object '2da437c PopupWindow:f88e6e6 (client)' was disposed without first being removed with the input manager!

I open the page the first time and get this:

03-06 21:19:50.850 13200 13200 D ControlsProviderLifecycleManager: invokeOrQueue queue
03-06 21:19:50.850 13200 12753 D ControlsProviderLifecycleManager: Unbinding service Intent { cmp=com.google.android.apps.chromecast.app/.systemcontrol.HomeControlService (has extras) }
03-06 21:19:50.850 13200 12753 D ControlsProviderLifecycleManager: Binding service Intent { cmp=io.homeassistant.companion.android/.controls.HaControlsProviderService (has extras) }
03-06 21:19:50.851 13200 12753 D ControlsListingControllerImpl: Subscribing callback, service count: 5
03-06 21:19:50.871  1949  3651 D CoreBackPreview: Window{2da437c u0 PopupWindow:f88e6e6}: Setting back callback null
03-06 21:19:50.872  1949 14318 W InputManager-JNI: Input channel object '2da437c PopupWindow:f88e6e6 (client)' was disposed without first being removed with the input manager!
03-06 21:19:50.941 13200 13200 D ControlsProviderLifecycleManager: onServiceConnected ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService}
03-06 21:19:50.941 13200 13200 D ControlsProviderLifecycleManager: handle queue 1 items to run
03-06 21:19:50.941 13200 13200 D ControlsProviderLifecycleManager: subscribe ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService} - [light.living_room_color, light.kitchen_color, light.bathroom_lights, light.white_three, switch.switch_1, switch.kasa_one, light.white_five, switch.switch_three_2, switch.switch_two_2, light.strip_one, script.toggle_ac, script.play_spotify_nest_living_room, script.wake_fractal, script.wake_nas, script.wake_fractal_2, script.plex_time, script.lg_power]

I then closed the page and reopened it and got this:

03-06 21:20:22.417 13200 13200 D ControlsUiController: show()
03-06 21:20:22.417 13200 13273 D ControlsListingControllerImpl: Subscribing callback, service count: 5
03-06 21:20:22.418 13200 13200 D ControlsProviderLifecycleManager: invokeOrQueue queue
03-06 21:20:22.418 13200 13273 D ControlsProviderLifecycleManager: Binding service Intent { cmp=io.homeassistant.companion.android/.controls.HaControlsProviderService (has extras) }
03-06 21:20:22.419 13200 13273 D ControlsListingControllerImpl: Subscribing callback, service count: 5
03-06 21:20:22.427 13200 10578 E OpenGLRenderer: Unable to match the desired swap behavior.
03-06 21:20:22.438 13200 10578 W Parcel  : Expecting binder but got null!
03-06 21:20:22.440 12851 12851 I HdmBroadcastRecvUpd: (REDACTED) received broadcast: %s
03-06 21:20:22.440 12851 15316 I HdmHotwordRequestListen: (REDACTED) received broadcast: %s
03-06 21:20:22.440 12851 15316 I SodaTriggeringFrontend: (REDACTED) #onConfigUpdate. requester: %s
03-06 21:20:22.441 12851 15317 I SodaTriggeringFrontend: #onConfigUpdate inside sequencer
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) Voice Match (Speaker-id) supported : %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) hotword enrollment state is enrolled:  %b, speakerId model exist: %b. Voice Match supported : %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) isHotwordAvailable():  %b, isHotwordEnabled() %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) isHotwordAvailable():  %b, isHotwordEnabled() %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) Hotword enrollment state : %s.
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) Voice Match (Speaker-id) supported : %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) Voice Match (Speaker-id) supported : %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) hotword enrollment state is enrolled:  %b, speakerId model exist: %b, voice match supported : %b
03-06 21:20:22.441 12851 15317 I A       : (REDACTED) Hotword isNonVoiceMatchHotwordEnabled: %b, isHotwordAvailable : %b, isHotwordEnabled : %b, isVoiceMatchSupported: %b, isHotwordEnrolled: %b.
03-06 21:20:22.441 12851 15317 I SodaTriggeringFrontend: (REDACTED) Ignore the legacy hotword request. voice match enabled %b, isHotwordSupported %b, isIncompleteEnrollmentState %b, nonVoiceMatchHotwordEnabled %b
03-06 21:20:22.452 13385 13385 I A       : (REDACTED) onApplyWindowInsets: systemWindowInsets=%s
03-06 21:20:22.452 13385 13385 I A       : (REDACTED) onApplyWindowInsets: systemWindowInsets=%s
03-06 21:20:22.462  1949  2480 I ActivityTaskManager: Displayed com.kieronquinn.app.classicpowermenu/.ui.activities.PowerMenuActivity: +121ms
03-06 21:20:22.540 13200 13200 D ControlsProviderLifecycleManager: onServiceConnected ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService}
03-06 21:20:22.540 13200 13200 D ControlsProviderLifecycleManager: handle queue 1 items to run
03-06 21:20:22.540 13200 13200 D ControlsProviderLifecycleManager: subscribe ComponentInfo{io.homeassistant.companion.android/io.homeassistant.companion.android.controls.HaControlsProviderService} - [light.living_room_color, light.kitchen_color, light.bathroom_lights, light.white_three, switch.switch_1, switch.kasa_one, light.white_five, switch.switch_three_2, switch.switch_two_2, light.strip_one, script.toggle_ac, script.play_spotify_nest_living_room, script.wake_fractal, script.wake_nas, script.wake_fractal_2, script.plex_time, script.lg_power]

Hopefully, there is an android expert in here who can chime in!

@KieronQuinn, Any ideas? I can keep looking into it but I will have to learn Android development. Should be up to speed in a year or so :D

mozyu28282828 commented 1 year ago

Same here... No solution found.

NylonDiamond commented 1 year ago

Yea, Never figured it out. I'm just using the google integration until it gets fixed. A bit slower but it works for now.

js6pak commented 11 months ago

Looks like the core issue is that ClassicPowerMenu is unable to figure out that a service binding to the device controls provider app (like hass) is already in place, so it hangs forever (until you force kill the provider app after which it works for one time again). I've attached a patch which unbinds the service after the power menu is closed which makes the situation a lot better, but it still breaks rarely.

diff --git a/app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/powermenu/main/PowerMenuFragment.kt b/app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/powermenu/main/PowerMenuFragment.kt
index b57beb6..e1f22ff 100644
--- a/app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/powermenu/main/PowerMenuFragment.kt
+++ b/app/src/main/java/com/kieronquinn/app/classicpowermenu/ui/screens/powermenu/main/PowerMenuFragment.kt
@@ -71,6 +71,11 @@ class PowerMenuFragment :
         )
     }

+    override fun onStop() {
+        super.onStop()
+        contentAdapter.controlsUiController?.hide()
+    }
+
     private fun getItems(): List<PowerMenuContentItem> {
         return ArrayList<PowerMenuContentItem>().apply {
             if(viewModel.showQuickAccessWallet) add(PowerMenuContentItem.Cards)
KieronQuinn commented 10 months ago

The above workaround was added in 1.7.1. I'm going to close this as pre-embedded controls it did sometimes break on the native UI, so I suspect the same thing is happening here.