How to use androidtv.learn_sendevent when deploying Python ADB

Originally this post was a question, but now I actually figured out how to utilize the androidtv.learn_sendevent command to have more specific codes that trigger the fireTV giving quicker response times than the standard ones. I was having a hard time finding the location mentioned in documentation of adb response section to find the sent code. I will be saying FireTV a lot as that is the device I setup but this should be same for AndroidTV devices as well.

first create a media player for the androidtv/firetv


platform: androidtv
host: 192.x.x.x 
name: FireTV

remember host is going to be the IP address to access your fireTV going forward so set a static IP or a DHCP reservation in your network router or gateway for that device. Name of device can be anything you want.

restart HA to get FireTV to appear as an entity.

Then go to developer tools then services Select androidtv.learn_sendevent as the call service . select your FireTV as an entity. Then run. within 8 secs press the button on your FireTV remote. After another 8 seconds, still in developer tools section click the states tab at top.then scroll down till you find the persistent notification in that list from the Android tv. there will be a spot that says

adb response:

copy the code after the semi colon then you can paste the code to the command on the script you are trying to right or directly to the command section of the button your creating.

I hope this helps as I really struggled with this.


Are you getting a persistent notification with a command after using the service?
You would use that with the adb_command service. Although I have noticed sometimes the event in the notification is duplicated slightly a second time, so try to make sure you only copy and paste the lines up to where it repeats again.

1 Like

Thanks for the response I actually edited the post because I had figured this out a little while ago. My issue was I couldn’t find out where to locate the persistent response or the adb_response section. but I finally found them. so I edited with my findings to help out any others that might be struggling with this.

1 Like

Thank you very much! I the think the official documentation should be updated to include this information as it is not apparent.