Android TV (magenta TV Box) CHANNEL_UP

hi,
I am struggling with finding the correct command to switch channels of my Android TV Box:

  • generally it works eg. the “MUTE” command works
  • but the (as written in HA documentation) “CHANNEL_UP” command does not work
  • googled a bit and eg “CHUP” is also not working
  • and this remote learning feature … I yet do not get how to use this … would be the right way to unveil the correct command code

anyone with some advice?
thanx

if you have a working physical remote, the best thing is to use the adb debug bridge. The learn command is super easy. In Dev tools services do androidtv.learn_sendevent with your entity. Then hit the remote button. And look in the notification. You will see the right sendevent command to use. super easy

could you be even a bit more specific how to use the adb debug bridge ? is this something i have to enable on the tvbox ?

ok… i’ll try… going from memory so i’ll do my best.

  1. get the ip address of your tv. how to do this varies from tv to tv, but looks like you’ve connected it to another integration so hopefully you know how…
  2. go to integrations-> add integration-> choose android debug bridge (it might be auto-detected already)
  3. hit add device or configure (it might put you automatically in)
  4. fill out the dialog. i think you only really need the host (ip address). can leave for auto detect on type if you don’t know. leave the rest as is.
  5. follow the instructions on home assistant and on your tv.

that sets it up.

then to get the command, go to dev tools services. do this:

once the “call service button” turns green, you have 8 seconds to press a button on the remote control button you have for android. you will get a push notificatoin to home assistant (button left). open that up and you should see the command you need to send.

if you don’t know what to do with that, bring it back here and paste in the command you got.

1 Like

ok thanx man for the nice “tutorial” … tried it already but:

  • looks like that on the magenta android tvbox adb is somehow deactivated
  • i get a connect error on the IP of the box

looks like I have to further investigate whether something needs to be sideloaded on the tvbox

or do you have nay more ideas ?

thanx


ok - got it … Magenta TV Box (Android): Infos, Tipps und Tricks | LTE-Forum Österreich helped me to activate USB debugging / developer mode on my magenta box

  • now my ADB integration in HA is connected
  • will continue with your instructions and report back soon

cheerz

ok now we are close I think … managed to execute the send.learn service and got the mentioned HA notification as seen in attachement

  • but now WHAT is the according command i have to use in my android remote automation ?
  • im looking for CHANNEL_UP and CHANNEL_DOWN
  • the screenshot is the result when i pressed the CHANNEL_UP button on my physical remote
    thanx in advance

great!!

that whole long blob is what you need to send. if you’re putting it in a lovelace card where you’re doing service_data, this is an example from my card (replace the send event data with your sendevent data:

    service: androidtv.adb_command
    service_data:
      entity_id: media_player.great_room_fire_tv
      command: >-
        sendevent /dev/input/event5 1 14 1 && sendevent /dev/input/event5 0 0 0
        && sendevent /dev/input/event5 1 14 0 && sendevent /dev/input/event5 0 0
        0  

if you’re putting it in automation or a script, you do this:

service: androidtv.adb_command
target:
  entity_id: media_player.great_room_fire_tv
data:
  command: >
   sendevent /dev/input/event5 1 14 1 && sendevent /dev/input/event5 0 0 0         
   && sendevent /dev/input/event5 1 14 0 && sendevent /dev/input/event5 0 0 0  

notice that my 1 button is sending 4 sendevent commands. the first pair is the button press down. the second pair is the button press up. so a click requires all 4 for my android tv. yours has 6 sendevents. i don’t know why… but that’s what you got back… give it a try.

ok we are very close:

  • tried it and called the service under HA->Development Tools
  • it is accepted and confirmed after some seconds with a green checkmark
  • BUT no reaction on my TV
  • tried with two separate learned command strings (channel up and down)

what could be missing here ?


hmmm… ugh. I gotta admit I don’t see anything obviously wrong. what i’d if it were me is to try a couple other “simpler” commands to see if I can get any send event commands working. like try doing the exact thing for mute or volume (if your android TV does it’s own muting)

the other thing is maybe look at

Nerwyn knows this stuff super well. Maybe he knows your android box

not necessarily recommending you abandon what you’ve done. But maybe try that and see if that does channel up/down. If it does, he’s got it cracked. And either the code or his head has the answers

1 Like

I wouldn’t say I know it super well :grimacing:. Armedad knows way more about sending remote keys via adb.

Android TV Card’s default channel up/down just uses the remote.send_command service.

service: remote.send_command
data:
  command: CHANNEL_UP
target:
  entity_id: remote.lounge_google_tv

But it sounds like you tried that and it isn’t working. Have you tried this service call using the remote entity ID instead of the device ID?

I did find this section of the HA adb integration page that mentions this list of useful adb commands, but I don’t see channel up/down there.

I can confirm that the remote.send_command CHANNEL_UP/DOWN method works for me on Google TV channels. Possibly dumb question - are you trying to change channels within Android TV’s live streams or cable/satellite channels?

thats indeed a valid question:

  • its a magenta android TV box which is connected over IP

  • so its a yes and no => it must internally be streamed but appears as a cable TV - this smells like it could be the problem

  • other remote commands like VOLUME_UP and MUTE work fine

  • all the sendevent commands i ecorded/learned via the adb bridge are NOT causing any effect when sent over the adb bridge

  • and yez i tried both the entity and the device

  • and all my recorded sendevents are a chained of 6 sendevents

eg even simple things like VOLUME_DOWN button on the physical android remote

sendevent /dev/input/event10 4 4 786666 && sendevent /dev/input/event10 1 114 1 && sendevent /dev/input/event10 0 0 0 && sendevent /dev/input/event10 4 4 786666 && sendevent /dev/input/event10 1 114 0 && sendevent /dev/input/event10 0 0 0

very strange

Just a question about sending the events via adb (as i tried it on my android tv), what does the adb_response in the developer tools say after sending?
Mine says:

adb_response: sendevent: /dev/input/event1: Permission denied

A quick internet search reports that this may be a security feature of android 10 or higher and it is not possible to do the sendevent command, anyone can confirm?