External integration - Android TV Remote

I can’t stop now :joy: … I also started an Android TV Remote integration.

It allows you to connect and control Android TV and Google TV televisions and set-top boxes (Nvidia Shield, Chromecast with Google TV, Sony, Xiaomi Mi Box, TCL, etc.) directly on your local network.


Key Features

  • Native Remote v2 Protocol (TLS): Secure connection on ports 6466/6467. No need to enable developer mode or ADB on the TV.
  • Easy Pairing with PIN Code: Guided 2-step procedure directly in the Gladys interface (PIN code displayed on the TV screen).
  • Real-Time Status Feedback: Instant feedback in Gladys of the on/off status, volume level, and mute status.
  • Multi-TV Management: Pair and control multiple televisions independently.
  • Full Control:
    • Power On/Off switch
    • Volume and Mute management
    • Navigation Buttons (D-Pad): Up, Down, Left, Right, OK, Back, Home, Menu
    • Media Buttons: Play, Pause, Stop, Previous, Next, Fast Forward, Rewind
  • Application Shortcuts (Optional): Direct launch of your favorite apps (Netflix, YouTube, Prime Video, Disney+, Spotify, Plex, Arte, Molotov, myCANAL). An option in the settings allows you to disable them if you want to clean up your device card.

Ergonomics & Usage Tips (Scenes)

:information_source: Note on Dashboard Display:
Gladys Assistant currently does not have a dedicated « Remote / Media Player » widget with a visual directional pad, so the device appears as the generic « Devices » widget (vertical list of buttons).

For smooth daily use, it is highly recommended to use Gladys Scenes:

  • Create scenes for your key actions (« Turn on TV », « Movie Mode », « Pause », « Launch Plex »).
  • Place Scene cards/buttons on your Gladys dashboard to trigger these actions properly in one click.
  • For quick manual navigation in TV menus (browsing the Netflix catalog, typing text), the official Google TV app or the physical remote control remains the ideal companion.

Examples of Gladys Scenes

  • :popcorn: Movie Mode: Turn on the TV + set volume to 20% + dim the living room lighting.
  • :door: Departure / Night Mode: Automatically turn off the TV when the house switches to away or night mode.
  • :bell: Automatic Pause: Pause the TV when a call or connected doorbell is detected.

Installation & Configuration

  1. Add the external integration to your Gladys Assistant instance:
    https://github.com/guim31/gladys-integration-android-tv-remote
    
  2. Go to Integrations > Android TV Remote:
    • Step 1: Enter the IP address of your TV and launch the action. A 6-digit PIN code is displayed on the TV.
    • Step 2: Enter the PIN code and validate.
  3. Launch a Device Search in the Discovery tab to add the TV to your devices.

Links & Source Code

I remind you that I am not a professional developer, I trust AI because I don’t have the skills to understand everything. Don’t hesitate to tell me if something is wrong or missing … !

You can’t stop us now! Welcome to the developer side, and don’t worry in the age of AI, the only thing that matters is motivation :grin: The technique is perfectly handled by Claude :wink:

Good evening @guim31

Thank you for this integration that I just tested… and for which I am stuck at the moment of entering the IP address:

Integration status:

image

When I refresh the Gladys integrations page:

image

However, the container is indeed started:

I do not understand, however, why it cannot connect to Gladys via WS://gladys:8082, as the port is indeed available and listening:

image

Thanks in advance for your feedback,

Jean

Good evening Jean, thank you for the detailed feedback!
Good news: the integration itself is not the issue.
Your logs show that the container cannot open the WebSocket to Gladys (connect ETIMEDOUT 172.30.0.2:8082) — it therefore never managed to register, hence the action failure and the toggle that resets.

An ETIMEDOUT (and not « connection refused ») means that the packets are discarded along the way: this is typically a network problem between the two containers, not a port issue.

To check:

  1. Compare the networks of the two containers:
docker inspect -f '{{json .NetworkSettings.Networks}}' <gladys-container> | jq
docker inspect -f '{{json .NetworkSettings.Networks}}' gladys-ext-guim31-gladys-integration-android-tv-remote | jq 

If they do not share any network (different subnets), that is the cause: Docker isolates the bridges from each other.

  1. Test from the integration container:
docker exec gladys-ext-guim31-gladys-integration-android-tv-remote wget -qO- --timeout=5 http://gladys:8082 || echo KO 
  1. How did you install Gladys?
    The official installation runs the Gladys container in network_mode: host — this is the expected configuration for external integrations. According to your capture, your Gladys is running in bridge (IP 172.30.0.2, mapping 8082:8082): if that is the case, switching back to host network should solve the problem.

  2. If the networks are fine, check the host/NAS firewall (ufw, firewalld…), which may block inter-container traffic.

Let me know what points 1 and 3 yield — and as soon as the connection goes through, the integration will connect on its own (it retries continuously), no need to restart it.

Hello @guim31

Thanks for your reply, here is already the result of your question 1:

Answer to question 2:

image

And to question 3:

The Gladys container was restarted after being modified so that the network is indeed of type « host ».

Despite this, the container still cannot connect to the WS:

I remain at your disposal and thank you in advance for your help,

Have a nice end of the morning,

Jean

Thanks, your screenshots confirm everything!

(if you could copy/paste logs next time, it would be easier to exploit than with screenshots :wink: )

Look at your logs: the error is no longer ETIMEDOUT but getaddrinfo ENOTFOUND gladys — the name gladys is no longer resolved.
This makes sense: before, this name was an alias for the Gladys container on the gladys-integrations network; by switching to host network, your Gladys container left this network and the alias disappeared. And the counter (« attempt 753 ») shows that the integration container has not been recreated since your switch: it is still running with the connection configuration generated for the old topology — it is frozen at the creation of the container, a restart does not regenerate it.

So:

  1. In Gladys → Integrations → Android TV Remote → Supervision → « Force update » (this button recreates the container, that’s what we want). Failing that: uninstall/reinstall the integration.
  2. Then check the logs: you should see either the connection being established, or at least a new target (no longer ws://gladys:8082 towards a dead name).
  3. If it still fails, two tests to decide:
    • from the container: docker exec gladys-ext-guim31-gladys-integration-android-tv-remote wget -qO- --timeout=5 http://172.30.0.1:8082 (172.30.0.1 = your host seen from the bridge — this tests reachability by bypassing DNS);
    • on the host: ss -tlnp | grep 8082 (check that Gladys is listening on all interfaces and not just 127.0.0.1).
      If the first fails while the second is good, it’s your firewall that blocks the bridge → host traffic on 8082 (with ufw: sudo ufw allow from 172.30.0.0/24 to any port 8082).

Keep me posted after the « Force update »!

Hi again @guim31

Following all your instructions, everything is now working perfectly in terms of integration: TV connected :heart:

Thanks to you, I will now play with this integration: if possible, add something to control the TV from the Gladys interface (from my smartphone/tablet in the living room) and define scenes to limit its use during the day for mini-me :smiley:

Have a great day,

Jean

Awesome!

I think that as long as we don’t have a « remote control » type widget, the main thing is the scenes :slight_smile:

Hi again @guim31

I’m taking the liberty of providing some more feedback, which may be useful for making corrections and improvements that will benefit everyone :smiling_face_with_sunglasses:

When the TV is turned off, the integration keeps trying to contact it:

Also, if the TV is off and you try to interact with the integration interface, errors appear:

Also, if I add a « TV (Power) » button to a dashboard and try to turn on the TV, the integration again starts a long series of unsuccessful connection attempts…

Have a nice evening,

Jean

Great initiative! I have an Android TV box at home, I’m willing to test.

Analyzed with the help of Claude (AI), reviewed and approved by me.

Hello @jean_bruder!! I’m so sorry, I didn’t see your message!

Thank you so much for these detailed feedbacks, with screenshots — that’s exactly what we need to fix it. :folded_hands:

Good news: the three issues actually came from the same cause, and it’s fixed.

What was happening: the library that manages the Android TV protocol restarts the connection every second, indefinitely, as soon as the TV is unreachable. TV turned off = logs flooded with EHOSTUNREACH (your first screenshot) and network continuously solicited. As a bonus, it masks connection errors, so pressing « Power » from a dashboard remained stuck for long seconds before failing… and restarting the loop behind.

What changes:

  • When the TV is turned off, the integration calms down: it retries in the background with a delay that doubles with each failure (5 s, 10 s, 20 s… capped at 2 minutes). As soon as the TV becomes reachable again (turned back on, network wake-up), it is automatically resumed and the rhythm starts over from zero. No more flood of logs.
  • Pressing « Power » (or any command) with the TV turned off attempts an immediate connection and fails cleanly in 2-3 seconds with a clear message, instead of staying stuck. A quick reminder: the Remote v2 protocol can only wake up a TV in network standby — a TV completely powered off must be turned back on with the remote or via HDMI-CEC.
  • Removing the device in Gladys now also cuts its connection and its retries on the integration side.

Regarding the error « when deleting this device » (your second screenshot): this message comes from the core of Gladys, not from the integration. The fix removes the most likely cause, but if you see it again TV turned on after the update, don’t hesitate to let me know with the logs — it would then need to be investigated on the Gladys side.

The fix is published: update the integration to version 1.0.5 (or :latest) and restart the container.

Have a great day, and thank you again for your feedback :smiling_face_with_sunglasses:

I can’t find this integration on Gladys :sweat_smile:
Did you forget the topic? :thinking::face_savoring_food:

No way to do a network search to see Android TVs?
On LG I use SSDP to search the network

Couldn’t you have a dynamic select like for LG for the apps to launch?

LG side:

Otherwise, no push on the apps so we can’t launch them and the rest I’ll do my tests as I go along :victory_hand:

My mibox is running and the power is at 0 in the interface ^^.
Can’t we get the status? Maybe a simple ping? :thinking: