Native support for Android TV / Android devices

Hi,
I have succesfully configured ADB and androidtv component.
I have a problem with my Philips TV. I have to send a wakeonlan packet to wake it up.
¿Can I use turn_on_command to send a wakeonlan command or what can I do?
TV doesn’t respond to androidtv component until the TV is up. After sending a magicpacket, the component works ok.

I have further read that it seems this Wireless Display connection is done via Miracast/via adb (different TCP/IP port?).

Could it be that the HA androidtv implementation cannot handle these “parallel” connections (or at least reconnect from it)?

Being able to use Wireless Display functionality from Windows10 while not losing the FireStick HA connectivity/functionality would be the cherry on top of the cake for me.

@JeffLIrion Any further insights or help I can provide to get this looked into?

I’m not familiar with Miracast, but devices only allow one ADB connection at a time. You may need to restart your device in order for HA to be able to reconnect.

You could try using the Python ADB implementation instead of an ADB server and see if that’s any better.

I’d rather suspect the FTV stick then the HA implemantation. Wouldn’t be the first time, that Windows isn’t correctly closing it’s connections…

Have you tried only restarting the FTV stick and wait for a little time for HA to find it? If this works, it is the FTV stick.

On the other hand, do you really need the screen mirroring or would it be possible, to use something else, that could chromecast? VLC does chromecasting for pics, music and videos.

Anyone able to get android_tv integration working for new Google TV Chromecast? I can only state as idle in home assistant.

So after digging through adb outputs, I found out that it is grepping of Window #1 instead of mCurrentFocus requires identfying currently running app


130|sabrina:/ $ CURRENT_APP=$(dumpsys window windows | grep 'Window #1') && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
com.google.android.youtube.tv
indows | grep 'Window #1') && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP                                                          <
com.disney.disneyplus
indows | grep 'Window #1') && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP                                                          <
com.disney.disneyplus
indows | grep 'Window #1') && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP                                                          <
com.hbo.hbonow ```

 Now I need to find out how to get my python-androidtv package on my docker installation.

Got it working with above change. reporting it here someone else tried Google TV Chromecast on home assistant.

1 Like

Just got the CCGTV couple days ago - it’s my first Android TV device. Do you need to do the ADB enabling stuff and then enable it using the standard ‘androidtv’ integration? Thanks.

Once you restart homeassistant after adding androidtv integration to your config, you should see pop on your android tv to allow adb connection just accept it and you should be good along with above minor change.

Hi @sacdroid Could you please let me know exactly what you did to get Chromecast with Google TV reporting status correctly? How do I update the androidtv component to 0.51 to support the new chromecast? How do I make the necessary changes to have the new chromecast device report playback status correctly?

Thank you.

@beninsteon To make it work it requires changes to https://github.com/JeffLIrion/python-androidtv and then installing this custom python module on your home assistant with custom android tv integration. This steps may vary based on your HA install method. I am planning to work submitting pr upstream to fix it.
Change is required how python module identifies current app https://github.com/JeffLIrion/python-androidtv/blob/4ab4f57f889bab3f0e947b44e754bebc128a56b4/androidtv/constants.py#L32

The changes to support Google TV devices are merged into the androidtv package and will be included in the next Home Assistant release.

2 Likes

Thanks! worked for me :slight_smile:

Don’t know if it was already mentioned in this thread (don’t want to spend all the time browsing 500+ messages), but for Philips TV’s you can follow the following steps graphically shown to enable Debugging: https://blog.codetitans.pl/post/howto-enable-android-developer-options-on-philips-tv/

I can confirm that by following these steps on my Philips 55OLED903 I managed to get everything working in conjunction with the https://github.com/hassio-addons/addon-adb ADB pluging of @frenck

I can ask what you managed to set to control the TV. I have a Philips 65 OLED 804, but I don’t know what can be set. Thank you

You can set anything with intents. Just as an example: go to developer tools -> services and start playing with the newly created mediplayer. You could, for example, turn on or off the television or run more complex things like playing the latest episode of Desperate Housewives.

Can you share some examples?

I would also be interested in an example to see where and how to start.

Check back to the post from this past summer: Native support for Android TV / Android devices

It references this gist that contains a bunch of examples: https://gist.github.com/mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304

@pepe59 @maurizio53

3 Likes

Thank you very much for a lot of examples. I will definitely use something .