Android TV trigger on remote button press event

I would like to use the spare buttons on my Sony Android TV remote (Bluetooth) to trigger automations

I can not find the key press events in home assistant to use as triggers?

All the posts on the forum is for sending commands. All I want do to do is trigger an automation

I know that there is and ‘adb_response’ attribute. What is triggering the Android TV: Learn sendevent service?

1 Like

I was just about to ask this question and I saw your post. My Sony remote has four color buttons that do nothing (usually) and I was able to get them to do stuff with the Button Mapper app (like launch a channel) but I’d like to trigger an automation with one or more buttons. Has anyone cracked this?

1 Like

I actually did figure this out! Similar useless color buttons on my Android TV and everything.

You can set up button mapper to push a webhook to HA that can trigger an automation. I had it set to change an input_select option in HA which I thne use to trigger a number of other things. The automation looks something like this

alias: TV Remote
description: ""
trigger:
  - platform: webhook
    webhook_id: tv_remote_last_pressed
condition: []
action:
  - service: input_select.select_option
    data:
      option: "{{ trigger.data.button }}"
    target:
      entity_id: input_select.tv_remote_last_pressed
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: input_select.select_option
    data:
      option: none
    target:
      entity_id: input_select.tv_remote_last_pressed
mode: single

Let me know if that doesn’t work for ya :grinning:

1 Like

Hi. I just wanted to add my thanks because this post helped me achieve this in October 2024.
I paid $5 for the Button Mapper Android app to install on my Google TV.
The 4 colour buttons now send HTTP POST events to http://MYIP:8123/api/webhook/tv-red or similar.
HA has automations with webhook triggers to do things on those button presses.
Nice :slight_smile:

1 Like

Can you share more info on this please, I have a sony tv
I want to use the yellow button to trigger my lighting scene in my space.
How do I go about this?

There are two steps:

  1. Set your TV to send an HTTP POST request to your Home Assistant API
  2. Set Home Assistant to trigger an automation on the corresponding webhook

If you haven’t done this before, you might like to mimic step 1 with a tool like Postman to send the HTTP request while you’re testing.

As in my post, the request should be something like, http://MYIP:8123/api/webhook/tv-red
I made up tv-red so use whatever you want. I used tv-red2 for pressing the button twice quickly and tv-red3 for holding the button because Button Mapper allows those 3 different button-press types.

The automation trigger is then “webhook” and use the ID, like tv-red.
Screenshot 2024-11-25 at 8.27.09 am

Button Mapper is reasonably easy to setup, but the HTTP POST option was a paid feature.
Also, I had to enable some security settings to allow it to work fully, but the app guided me on what to select.
You run the app from the TV menu, select “Add Buttons”, press the button you want to edit, then select “single press”, then select “HTTP POST”, then enter the URL with your IP.
It might look different on your TV, but that’s probably enough to get you there :slight_smile:

I hope that helps!