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 ![]()
FWIW, This issue is also affecting the new Walmart Onn 4k pro Android TV (Android 12).
You can add it to HA, but the integration has issues.
It reports the Android TV as idle, when its playing something. And regardless what you do in the Android TV device it says the status has not changed in hours.
Also It reports that the google launcher is open when in fact youtube is open in the foreground playing a video. And the volume mute button is not working (but volume bar is).
The media_player.android_tv state is Idle and attributes of the entity are:
adb_response: null
hdmi_input: null
device_class: tv
friendly_name: Android TV
supported_features: 23997
volume_level: 1
is_volume_muted: false
app_name: Google TV Launcher
source: Google TV Launcher
entity_picture: /api/media_player_proxy/media_player.android_tv?token=e976a3383e1cd24e53b7ba4cfbc80ae5fca34e0cc114545aa099ed2c0bf5172f&cache=fc1e1a9f1b304f5a
Nice! Here is my take on it for reference. I also disable the normally active presence automation in the room when something is playing, and set it back on when nothing is playing.
alias: TV States
description: Check TV states
trigger:
- platform: state
entity_id: media_player.hisense_google_tv_2
from: null
to: null
condition:
- condition: or
conditions:
- condition: time
after: "13:00:00"
- condition: time
before: "06:00:00"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'playing' }}"
sequence:
- service: light.turn_off
target:
entity_id:
- light.theater
- light.desk
- light.globes
- service: light.turn_on
target:
entity_id:
- light.ambient_left_light_2
- light.ambient_right_light_3
data:
color_temp: 454
brightness: 86
- service: automation.turn_off
target:
entity_id: automation.family_room_motion
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state in ['paused', 'idle', 'turned_off'] }}"
sequence:
- service: automation.turn_on
target:
entity_id: automation.family_room_motion
- service: light.turn_off
target:
entity_id:
- light.ambient_left_light_2
- light.ambient_right_light_3
- service: light.turn_on
target:
entity_id:
- light.theater
- light.globes
mode: single
Hello @cogneato,
I’m using a similar automation like you do, but in my experience the state that is showing by the Google Cast integration isn’t flawless. I’ve noticed that when I look a television show or movie for over an hour that the state isn’t changed when I paused and play again. What’s your experience so far?
I managed to get the mediasessions2mqtt working, that is truly the best solution.
Was a bit of googling to find out how to sideload apps on my TV but after that was sorted out the MQTT addon picked up the states and I can now have everything triggered based on the state and I can even see what “app” is being used. So I would strongly recommend that solution.
I think you mean this one: https://github.com/cbeyls/MediaSession2MQTT ?
I will give it a try, thanks! If you have any configuration tips, then please let me know ![]()
yes that one, there is almost no config, you just fill the three fields in hte app after installtation and then install the MQTT addon, MQTT - Home Assistant
For me everything just showed up automatically
Thank you, I will try this soon. Do I have to create and sign the .APK file myself?
I just downloaded it from the website.
Got it and installed this on my Android TV media player. In the app, I’ve setup the following settings:
- Enabled = true
- Enable Home Assistant Integration = true
- Protocol version = 3.1.1
- Hostname or IP address = IP address of my Home Assistant installation
- Port = 1883
- Username = (unset)
- Password = (unset)
After that I’ve installed the MQTT - Home Assistant Integration and set it up as ‘Use the official Mosquitto Mqtt Broker add-on.’
What should I do next so this add-on can find my media player because I see ‘No devices or entries’ at the moment.
If you go into the log of the mqtt you should see some data:
You should have the MQTT addon like this:

if you open it up you should have 3 entities:
You can use the above enteties for automation and so on
All I see is ‘No devices or entries’. Is there something I should change in the app settings on my media player? Is it required to set a user/password?
Is broker started?
Only config I have in the broker is that I have added the fullchain.pem and privkey.pem
No config in the mqtt addon as I can see
The thing I had to configure is a user in Home Assistant and set the username and password in the app of the Android TV. After I had done that, it created a successfull connection when I press ‘Test Connection’ in the app.
However… When I press the notification settings in the app, It displays:
System notification access settings screen not found
Please manually allow MediaSession2MQTT to access notifications using ADB
Is it necessary to install/configure this ADB?
pretty sure you need to do this as last step
adb shell cmd notification allow_listener be.digitalia.mediasession2mqtt/be.digitalia.mediasession2mqtt.service.MediaSessionListenerService
assuming you’re on Android 9 or greater.
Sorry to randomly jump in but I happened across this thread and just finished building/signing/installing this app. Sign and install were a learning curve ![]()
It looks like this when it works:
Yeah, sorry about what the youtube algorithm picked… I started watching this guy when he happened to cover that youtube streamer in Korea
Wow it even gets the title when you cast from VNC. I’m glad I don’t have teenage kids, I’d be setting up an alert on com.google.android.apps.mediashell
Did you follow some kind of tutorial, maybe it can be usefull for me.
I actually didn’t follow a tutorial. Just the readme instructions on the main github page. There’s no shame asking Google how to sign an apk although I almost gave up. I discovered that I got an unsigned apk file if I just did the build in gradle from the command line. I knew the IP for my Google TV from the notifications for android app. VLC will also show your Google TV IP address.
Decided Android Studio might be worth the gig of disk space and it was - there’s an option to build a release that signs the app right after it builds. I pointed it at my keystore created from the command line machinations and a minute later had a self-signed app.
But it was an iterative process. Went from one adb install error message to another until it finally went. That’s the thing with the error messages - google about eight words of it and you’ll find a forum posting somewhere from someone, maybe not even about building this code, but some other.
I already had MQTT running - I have two Ulanzi displays, two Tasmota lightbulbs and several different sensors on there. On iphone there’s an app called MQTT explorer and if you point it at your mosquitto broker you’ll be able to see MQTT traffic. I think there’s an MQTT explorer for most platforms, and you can test that your mosquitto broker is functioning as it should be and confirm that part is working.
But I really think you just need to run that ADB command because you wouldn’t get the error message about permissions if the app wasn’t installed. Reboot your device after the ADB command, the permissions won’t apply to the app until restart.
Thank you for the extended answer @tekno-yanqui!
I have a Nvidia Shield media player which is running on Android 11.
Should I enable something on this device? From where should I process the adb shell command you suggesting?






