-
Notifications
You must be signed in to change notification settings - Fork 60
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
Android TV 12 devices not working properly #323
Comments
Hi @Dillton In readme of this repo owner said that he have no time to work on this project. |
@JeffLIrion clear explain that he will not have time to work on fix, but PR are welcome. Anyone with some programming competence and a valid device for test can create PR on this repo, and I think that @JeffLIrion will found the time to review them. HA architecture is base on the fact that communication with devices are based on external and open source python library. This can be strength and weakness at the same time of this architecture, but that's it. I think that HA team will never work on external library, but this doesn't means that fix will not be implemented, this is just based on goodwill of the community. |
I think I might have found a fix for this already, but haven't had time to fully test & open a PR yet. It seems that the
From there, since the screen is on, the rest of the logic seems to work so far. But once again, I haven't tested everything yet, and also haven't regression tested other devices (e.g. my Nvidia Shield). I recall reading up a bit on a major architectural shift for this project during the last major Android version bump, but am not sure specifically what changed to make it easier to add more device-specific commands (perhaps something to do with custom commands???) In the long-run, it would seem better to have device profiles (something like ZWaveJS does I think) instead of a lot of |
I can help test this ;) I have valid device ;) |
What type of install do you have? I'm running docker, so I had to shell into the container and manually make the edit to In any event, if you can get to that file in your install and change python-androidtv/androidtv/constants.py Lines 179 to 182 in b1425b1
to the code snippet in my prior comment (here it is again):
That should be the extent of the fix. At that point, once the state is being correctly derived, it will be much easier to test other parts of the AndroidTV integration to see if further Android 12 changes are needed in addition to the device state. |
@breakthestatic, I suggest you to setup a HA dev environment as explained here. It's quite simple (it works with windows, linux or mac), will simplify your tests and will avoid to hack your default HA installation. |
I already have that set up but am not sure how to make the needed change since it's in this library, not HA core. To test the fix, I was already using the dev env, but still manually changing the python-androidtv file in site-packages. |
Evening. I can also help with testing with my Chromecast and so far I can say this seems to be the trick, thank you. I will keep it modifyed like that and see. |
I can confirm that this fixes the issue for me too (CCwGTV Android TV 12). Thanks! |
Hi All i looking this path on my instance But i cannot find it first of all i don't have python 3.10 folder i have only 3.9 My installation is on virtual machine and up to date |
If it's Hass os in a VM you need to access home assistant core docker container shell. |
@breakthestatic Found an additional problem so there might be needed additional modification of the code. |
Not saying you are definitely wrong about needing some additional fixes, but I recall seeing behavior like this with the Nvidia Shield recently as well. I believe the integration polls the device every 10 seconds, so perhaps there is some logic that defaults the playing state to So far I haven't seen this myself on the Chromecast, but I have also not done much testing. I'll see if I can reproduce it if/when I have some spare time over the next few days. Also, if you are somewhat familiar w/ ADB as well, you could manually set up an ADB session on another computer and see if |
Just a quick follow-up regarding the intermittent Once again, I'm not really familiar with the actual functionality of this library beyond the basic ADB commands used to determine state, but it seems like the python-androidtv/androidtv/androidtv/base_androidtv.py Lines 112 to 114 in b1425b1
Looking at this piece of code, it seems that only two things can trigger it, either an incorrect screen_on value or when the current_app is set to off . I'm still not 100% sure if a failed poll could return what is eventually interpreted as an incorrect screen_on state. I tried faking it by pulling my ethernet cable for ~20 seconds, but HA correctly interpreted that as "unavailable" in that case (not off as is seen in your screenshot), so it seems unlikely that a dropped poll can cause it. That leaves either a truly incorrect reading of screen state (i.e if, for some reason your mScreenState isn't ON for that particular poll response), or an invalid current_app .
There's a bit more logic surrounding the state of |
@breakthestatic Really does not matter which application I think. I was watching youtube and netflix yesterday and with both the same behaviour. Sometimes also state changed to standby even when it should be playing. |
Not really sure what's going on there :( My two Chromecasts have been very consistent with their state reporting since putting in the fix. In Twitch, I noticed that whenever the stream goes from actively playing to buffering (doesn't happen often, but still), the state switches from python-androidtv/androidtv/androidtv/base_androidtv.py Lines 208 to 210 in b1425b1
It seems that condition is rather open-ended, in that as long as none of the app-specific rules above it trigger, and there is no media_session_state , it will try to get the overall state from the current audio state (as long as it isn't idle ). If audio_state is off , that could also seemingly lead to what you guys are seeing.
Maybe you could try adding extra logging at the bottom to see what all the various state variables look like at the time the problem occurs (i.e. put it right before line 228 in base_androidtv.py):
|
a side-question @breakthestatic : did you reinstall/re-add your CCwGTV in HomeAssistant? I can see that the firmware shows "12" - mine CCwGTV upgraded itself over the night [probably - yesterday it was Android 10, today it's 12, and I didn't do anything ;)] but it still shows "10" in the firmware info in HA. of course all my automations stopped working [and I was using different ones according to which app is running with what state], but I'm too afraid to fiddle "with system" or try your hot fixes. I'll just wait patiently :) also I've noticed that service |
Hey @pejotigrek, I didn't reinstall my Chromecast, but I have both reloaded the integration, as well as completely restarted HA. I'm not sure which (or both) of those might have updated the firmware version, but I would definitely be sure that you are seeing the updated version before doing further debugging. When my Chromecast was updated to 12 (already said fw12 in HA), doing the |
ok checked now, reloading did the trick! thanks! :) also looks like |
ok, tested, my |
Yeah, I believe that most of the values are dependent on |
I'm also affected by this. I applied the Let me know if you want me to test anything specific. If the change works for some people and is unlikely to break anything, maybe it's worth releasing it so that others can test more easily without having to manually to edit code inside containers. |
maybe I'm too naive, but I guess that it won't be worse than "not working" as it is without fixes, so yeah, release would be cool :) but maybe there's an relatively easy way to put it as custom integration - just for testing? so it could be checked without fiddling within dockers? |
Hi @breakthestatic I just added extra logging and will watch some movie today so hopefully we will learn something more about the states. EDIT1: So far HA is not able to load the integration with added logging. |
@breakthestatic Ok got some logs, you can check below. When state changes to standby: Seems like no data available at that time? |
Hmm, so it seems likely the actual dumpsys response is incorrect when the problem occurs. The only extra logic that is performed before it gets to the state logic is an inversion. The actual ADB command performs a silent grep for the commands, which returns a python-androidtv/androidtv/constants.py Lines 72 to 73 in b1425b1
Are you familiar with ADB at all? If so, perhaps you could set up an ADB connection to your Chromecast, and then either set up an automation to alert you when the media player's state changes to
or run a small loop that automatically saves the output every N seconds, e.g. (sorry for my likely poor shell scripting abilities):
From there you can open the file and inspect all the various display state info at the time HA saw the errant state to see if maybe |
@breakthestatic Got the logs when HA sees OFF however mScreenState is ON in logs. You can check if you find something else. |
Were these just manual dumps after noticing the player status switching to @ollo69 or @JeffLIrion, are you familiar with the flow of data from the ADB commands in constants.py through to the HA state? I'm trying to see if we can get the raw data that ADB returns to determine if the ADB state is incorrect, or if it's something further downstream. I believe that it's something later on, or perhaps some different (but related) ADB call that is failing, but I'm not very well-versed in this and without being able to reproduce it myself, am having a hard time trying to get any data to help debug. |
Yes manual right after state changed. I didn't managed to get the loop work and had very little time this weekend so at least I got the manual log however I will take a look at the loop in the following days. |
Hello, when this can be implemented into HA? |
I'll make a PR with the mentioned CMD_SCREEN_ON change. I have confirmed that this works to regain get_properties() functionality, but there are probably still changes that need to be made to address the dropout issues people are having: #323 (comment) I am not running this in HASS, as I wanted to have a good development environment, so I cannot confirm whether or not I see the dropout-issue. I will do some more testing on this today, however. |
Is anyone able to provide a method to update the [python-androidtv/androidtv/constants.py] on hassio.core, the home assistant command line ext doesn't provide access and I don't think ha docker bash command works here? |
This specifically refers to Home Assistant OS setups, which might not be what you want https://developers.home-assistant.io/docs/operating-system/debugging has instructions for ssh'ing into the supervisor, but they require physically inserting a USB drive into the host. Afterwards you can probably exec into the homeassistant docker container as mentioned here: https://community.home-assistant.io/t/editing-component-files-in-hassio/24273/6 There might be a way of doing it with custom components, but I haven't looked into it. |
Sorry but I'm a bit confused. Do you refer HASSIO or HA - Core installation (throught Docker)? With the latter you can outsource the whole |
Regarding the dropping out issue, I've been running a script that just calls the same update() method as HA every 5 seconds, and logging the returned properties. In a little over three hours of running with various different applications running on an Android TV 12 Chromecast, it didn't report the screen to be off a single time, nor did anything else look out of place. I'll have to dig a little deeper to figure out what might be going on, but if anyone else experiencing the dropout issue could post some more information of how often it happens, and during what kind of operation, then that would be great. edit: a lot more is going on when polling than I initially realized, so an actual HA connection might actually be easier. |
I've also noticed that you cannot control volume from the UI Slider/Automation for CCwGTV w/ Android 12. I use a home assistant docker based and |
android 12 /google TV still broken on my home assistant core install Nov 30 update. |
looks like we are waiting for home-assistant to bump python-androidtv |
Most likely @JeffLIrion needs to publish a new pypi release before HA can bump it. The last one is still 0.0.69: https://pypi.org/project/androidtv/#history Afterwards a simple PR needs to be opened in home-assistant/core, like this one: |
androidtv 0.0.70 seems to be released just a few hours ago: https://pypi.org/project/androidtv/0.0.70/ |
Just made a PR: |
Hi when can we expect this fix in HA officially? |
The PR is merged and scheduled for 2022.12.2, so likely in the following days. |
Just one more thing I noticed. State detection is delayed around 5 seconds. I also have google cast integration when there is no or very little delay. For example when switching from youtube to main launcher it is update after some time which is bad for automations based on this state. |
Use this automation to increase updating frequency to every 2 seconds. Also disable automatic updating in the integration settings `alias: Update AndroidTV
|
Thanks man. It works. Kinda... Even when setting to 1 sec. I get delay around 3 seconds |
Google Cast integration has immediate reaction. |
Hi. I think you can try use the action below in automation if it will be faster instead of homeassistant.update_entity. |
Unfortunately that didn't help. |
After I have updated the HA with this fixing, the device status will be reported as "off" sometimes when I browse the thumbnails in Netflix or during video playing in YouTube. It impacts the automation trigger. |
i find it much better since the HA update. play/pause has been great in YouTube. |
I found I had to update the state detection rule for Emby to the below. Works fine, now, however, my Chromecast still gets detected as being "off" sometimes. That's nothing to do with Emby, though. [{"playing": {"wake_lock_size": 2}}, {"paused": {"wake_lock_size": 1}}] |
I love the sound of what you are saying... but have no idea where to put that code. i dont know of a "state detection rule" to edit |
In HA, go to Integrations, select the Android TV instance and click Configure. In the screen that pops up, you can select New Rule at the bottom and then click Submit. That will allow you to enter the app ID for Emby along with the state detection rule I provided. |
I had to input, [{"playing": {"wake_lock_size": 3, "wake_lock_size": 4}}, {"paused": {"wake_lock_size": 2, "wake_lock_size": 1}}] regardless mark, thank you so much, |
Hello.
After my Chromecast with Google TV received an update from Android 10 to Android 12 the state of the device is always only "off".
ADB commands seems to be working at least for me however the key states like idle, playing, paused, etc. does not. Automations depends on those.
This is common issue for Android 12 devices, other users already reported this in different threads for example:
home-assistant/core#80555
home-assistant/core#79154
@ollo69 recommends the issue should be opened here instead of HA/core as this problem is inside AndroidTV library.
@JeffLIrion Could you please check this issue?
If you need logs or something let me know I can collect and provide them once I am home.
The text was updated successfully, but these errors were encountered: