WTH can't I see what my android tv is doing?

No time spent with chatgpt will be viewed here as time well spent.

Not sure this is an HA issue. Understand that ‘any’ other device used in HA must allow the usage. Have you asked this question in the Android TV communities?

There is nothing that HA can do that Android TV (or any other device) does not allow!

I’m not really sure I get what you are saying, I have asked in the forums here, in relation to the ADB integration on how to set up the custom wake_lock_states, I have waited for over weeks and still no answer, most threads here in the forums end up with questions and no answers.

I welcome you to try and setup a trigger based on a ADB state, if you find it easy you are welcome to explain it to me and others. If not this is something that could be simplied from how it is now.

I thought that is the whole point of the “WTH”? This was working until 3 months back, from what I can see in the documentation it is still working, it is just extreamly unclear on how to set it up.

That is exactly what the WTH is for. I did not mean to push you away from that.

But, unless I missed it, you did not say it was working in the past. That IS useful information! Maybe what was removed was from Android TV and not HA.

I don’t have an Android TV. So, I am not able to test anything. But I am replying ONLY based on the WTH info you provided.

My point was that it is not always an HA issue. Maybe it is an Android TV issue. That should be investigated before WTH here.

I might have been unclear but it is stated in my first post:

“That took time but was possible to do. Recently that option has been removed and now I have no idea how to even solve it…”

I’m happy you are responding, but if you have not tried and not aware of the integration maybe it is beter to keep answering those post that you have more knowledge about.

You are welcome to check the ADB section for what questions come up and the lack of answers to those.

I apologize. I’ll bow out of here.

Again, has the ‘option’ been removed from HA or other areas? Multiple questions here with no answers make me think it happened elsewhere. We have some very smart folks here who are very reactive.

I hope you get your answer.

Ok, so from my first post, it was before setup using the configuration.yaml, now it is not possible it throws an error after a HA restart saying that the commands are not allowed and should be removed.

The documentation is stating that this should somehow be possible, I’m just not smart enought to understand it: Android Debug Bridge - Home Assistant

The whole point of my thread is just this WTH is this so difficult? It should be much easier for a feature that in my eyes is one of the most basic ones.

I understand the need for custome states, since there is no standard, but the implementation of those in HASSIO could be much easier than what it is today, or atleast the documentation could be improved.

Here are a few threads about people asking for help in this regard:

Again, I seem to have spoke out of turn.

But it seems to have gotten more ‘useful’ info :slight_smile:

Will see how that works!

The simple answer to your question is that Android is a rather large, semi-open ecosystem with a variety of actors doing things differently, and there is no easy way to do this reliably across the whole ecosystem (both device & app). Some vendors may constrain their systems more than others, just like how it’s done on mobile phones. For example, my FireTV stick does not even have Google Play even when it’s an Android (TV?) device.

The ADB integration you mentioned uses the Android Debug Bridge (ADB) to run some commands on the device and parse their output, as far as I know. As the name implies, this interface is aimed for developers and not for end users, and is very error-prone depending on what exactly is being queried and executed. This may be a hit or a miss, depending on the hardware you have :slight_smile:

On top of that, Android has not always provided common methods to find media playback state, requiring one to think about things like wake_lock_states that you mentioned. This specific issue was solved on Android ages ago through something called MediaSession, but it wasn’t mandatory so not all apps used that in the past.

The proper way to solve this, in my opinion, is to make the Android system to push the information to homeassistant. For some time now, I have been personally happy with MediaSesssion2MQTT and it has worked well with all the Android apps I use. Given how well it worked, I even went and contributed homeassistant discovery support to make it easier to use, but this is still a very cumbersome and according to the developer it is unlikely to change in the near future.

Long story short, Android is a complex ecosystem with its quirks and the lack of common interfaces used to be the issue. Things may have changed in the past few years, but old ways of doing things may be still alive and Android is still not a completely open ecosystem.

3 Likes

+1 this is a very cool automation, I would like it to be possible (and easy? reliable?) with my Android devices (TVs, streamers etc), so if someone willing to figure it out that would be amazing. I will try out MediaSession2MQTT, but proper integration with media players sounds like a great core feature

2 Likes

Hi, I agree with you, maybe I was unclear with my title, but the problem today is that you have a description for a integration that in my eyes is impossible to follow, or atleast very unclear, that if anything should be a “WTH” point. I will look into your sugestion with MediaSession2MQTT, that sounds promising for now, but it would be great if something could be done, maybe an HASSIO app that can be installed on the media player in question?

mediasessions2mqtt is crashing on my TV after installation, I can thou see it connecting to the mqtt in logs but I cant discover it on hassio, so sadly does not seem to work on my version of sony :frowning:

Yeah, having something like the homeassistant Android companion app, that implements this out-of-the-box, available on TVs would be awesome!

As I have been exploring this topic earlier, I just wanted to write about my experiences and advertise the mediasession2mqtt as it’s been the most reliable solution for me so far. You could try to report your crash to the mediasessions2mqtt developer if you can capture the logs using adb logcat, maybe there is some solution for that.

Thanks, I’ll try that, i can start the app, but as soon as I input the IP for the server and press start it just wont open again untill I reset it, so probably something with how I input the IP that is the issue.

I would recommend creating an issue on that repository, maybe the developer knows how to fix it or if it’s even fixable :slight_smile: That being said, I also voted for this issue and I hope in the future there would be an easier way to achieve this.

Yeah I don’t think this is a WTH. I use the androidtv integration (added through UI) and an automation for this which checks the change from any state to any other state. Then a condition template checks if it is “playing” or not. No ADB needed.

2 Likes

I’m voting your suggestion. However;

The underlying issue seems to be with Android TV rather than Home Assistant.
YouTube app on TV passes the Playing/Pause status to the Android TV integration.
Sony Pictures Core app doesn’t do it.

So, it seems that we also need to ask app developers to support our integration.

1 Like

I think the straightforward approach would be an app like the mediastate2mqtt or similar that you install and get the functionality that you wish. You could also combine and add other feathers like notifications support and so on

Not sure what integration you mean, here are the ones for “android”:

Android TV Remote only tells you what “app” you are using, not sure how you would get the “state” from it? Nothing in the documentation about it either.

Ah, you are correct. I have the android remote which adds a media_player entity but I don’t use that. I use the media_player entity for the same tv brought in by the cast integration in the automation.

That media player shows what app is active, and the automation is triggered by the state of that when it changes from anything to anything else. Then I use a condition template to check the state of playing, idle, off, paused, etc and this determines which lights are on or off or dimmed, etc.

Not really sure how your condition template can get the state when I cant see one in the entity… But still the documentation for tha does not seem to help anyone out, and should be fixed and hopefully the HA team can do one better and sort this out somehow

EDIT:
Ok, I managed to figure it out, the cast integration reports the state, and the automation can pick it up easy:

Now I just need to figure out how I can get Netflix to work properly…

Running into the exact same issue and android debug bridge no longer detects the app running on my tv which means I can’t use custom rules to detect if apps are playing content or not :sob: