Broadlink rm-pro - change channels on the TV

I have a Broadlink RM-Pro and I want to use Alexa to change the channels on the TV.
Thanks to your very good tutorial, NightRang3r’s github and a lot of trial and error I can now turn on and off all my A/V equipment with Alexa and HA.

Now I’m a little lost. Basically, I want to create a “switch” for each channel I want to watch. Then I’ll have an easy way to say “Alexa, turn on TBS”

What I don’t know how to do is have the “switch” send out three ir signals to punch in the channel number.

I was able to make a script that can change the channel but when I try to add more scripts I start to break things… Also couldn’t find a way for Alexa to call that script.

I also need to add a little pause in between the packets and I don’t know how to do that either…

Here’s the code for the script. Any help is appreciated.

script:
  tv_select_source:
    alias: FX
    sequence:
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "JgCwAA7KDlwOWw5cDjcOWw5cDlwOWw5cDlsOXA5bDlwOXA5bDlwOyg5bDlwOWw43DlwOWw5cDlsOXA5cDlsOXA5bDlwOXA5bDssNXA9bDlsONw5cDlsPWw9aDlwOXA5bDlwPWg5cD1sOWw/JDlsOXA5cDjcNXA5cDlsOXA5bDlwOXA5bDlwOWw5cDlwOyQ5cD1oOXA82DlsOXA5cDlsOXA9aD1sOWw9bD1sPWg9bD8kPAA0FAAAAAAAAAAA="          
            - "JgAWAQ3LDV0MXQ1dDDkMOQxdDV0MXQ1dDF4MXQ1dDF0NXQxdDV0MzAxdDV0MXgw4DTgNXQxdDV0MXgxdDV0MXQ1dDF4MXQxeDMwMXg1cDV0MOQw5DF0MXg1cDV0MXQ1dDF4MXQ1dDF0NXQ7KDF0NXQxdDTgNOA1dDF0NXQxeDF0MXgxdDV0MXQ1dDF4Myw1dDF4MXQw5DDkMXQ1dDF4MXQ1dDF0NXQxdDV0MXgxdDcsMXgxdDV0MOQw4DV0MXgxdDV0MXQ1dDF4MXQ1dDF0NXQzMDlsPWw5bDzYPNg9bDlsPWw5cDlsPWw5bD1sOWw9bD1sOyg5bDlwOXA03DjcOXA5cDVwOXA5bDlwOWw5cDlwOWw5cDsoOAA0FAAA="        
            - "JgA4AQ7JDlwOXA42DlwONw5aEFsOXA5bDlwOWw5cDlwOWw5cDlsOyg5cDlsONw5cDjcNXA5cDlsOXA5bDlwOXA1cDlwOWw5cDsoOXA5bDjcOXA43DlsOXA5bDlwOXA5bDlwOWw5cDlwNXA7KDF0NXQw5DF0NOA1dDF4MXQ1dDF0NXQxdDV0MXg1cDV0MzAxdDV0MOQxdDTgMXgxdDV0MXQ1dDF4MXQxeDF0NXQxdDcsNXQxdDTgNXQw5DF0NXQxdDV0MXgxdDV0MXQ1dDF0NXQzMDlsPWw43DlsPNg9bDlsPWw9bDlsPWw9aD1sPWw5bD1sOyg5cDlsONw5cDjYOXA5cDlsPWw9aD1sPWw5bD1sPWg9bD8kPWg9bDzYPWg82D1sPWg9bD1oPWw9bD1oPWw9aD1sPWw/IDwANBQ=="

There is a bit of a discussion in the following link that might be of assistance to you:

1 Like

Thank you. That kinda helped. I wound up doing scripts with groups to get my channels to change.

Script for remote buttons 0 - 9 for Dish Vip722

script:
  tv_channel_1:
    alias: Channel 1
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA1cDzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
            
  tv_channel_2:
    alias: Channel 2
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA1cDzQNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwNXA80DVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_3:
    alias: Channel 3
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA1cDzQPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwNXA80DzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_4:
    alias: Channel 4
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_5:
    alias: Channel 5
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DVwNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA1cDVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_6:
    alias: Channel 6
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA1cDzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_7:
    alias: Channel 7
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA80DVwNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_8:
    alias: Channel 8
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DzQNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA80DVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_9:
    alias: Channel 9
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwNXA80DzQPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwPNA80DzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="          
 
  tv_channel_0:
    alias: Channel 0
    sequence:
      - delay:
          milliseconds: 400
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: 
            - "OABIAA7IDVwPNA1cDVwNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDzQNXA1cDVwPNA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="         

Then to get Alexa to see the script I grouped them for each channel

group:
  TBS:
    name: TBS
    entities:
      - script.tv_channel_1
      - script.tv_channel_3
      - script.tv_channel_9
  F_X:
    name: F X
    entities:
      - script.tv_channel_1
      - script.tv_channel_3
      - script.tv_channel_6
  Adult_Swim:
    name: Adult Swim
    entities:
      - script.tv_channel_1
      - script.tv_channel_7
      - script.tv_channel_6  

Hi

How have you set up the following in your configuration.yaml:

switch youtube:
  - platform: broadlink
    host: 192.168.0.5
    mac: '34:ea:34:e0:ac:e5'
    switches:
      youtube_on:
        friendly_name: Youtube
        command_on: ‘JgDSAJSTEzcSNxM3EhMSEhMSExISExI3EjcTNxISExITEhITEhITNxITEhITNxI3EzcSNxMSEhMSNxI3ExITEhITEhITNxIABf6VkxM2EzcTNhMSExISExISExITNhM3Ez'

Because I have copied your script and group in my configuration.yaml and was wondering if I have set up broadlink correctly? i.e. the above code?

Also how have you managed to link this with alexa? as I have tried to search the channels I have set up in my alexa app but it did not discover any?

Why not using scripts for each channel?

  channel_1:
    sequence:
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: "code for first button to press"
      - delay: "00:00:05"
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: "code for second button to press"
      - delay: "00:00:05"
      - service: broadlink.send_packet_192_168_13_142
        data:
          packet: "code for third button to press"

I am using scripts but how can alexa activate a script for each channel? as I thought the emulated_hue component on alexa only sees switches and not scripts?!

You can use emulated_hue also for script. If you have more then 49 devices use this

Can you show me on how to setup scripts for emulated_hue, as I cannot set it up for alexa to discover the device? I have less than 49 devices

I am using a phone now. It’s easy, follow the link and add - script

here. Remember to add the custom_components of the link

emulated_hue:
  hue1:
    type: alexa
    listen_port: 8301
    target_ip: 192.168.1.92
    exposed_domains:
      - switch
      - script
      - light

sorry what do you mean by “add the custom_components of the link"

Download the git repository and copy the files intoe the Home Assistant configuration directory adding this directory
/custom_components/emulated_hue/

3 files into the new directory. Then reboot

EDIT, here if you used AIO installer:

\Raspberrypi\home assistant\custom_components\emulated_hue

My echo was only seeing one script for some reason.
Also, since there is only 10 buttons to send it makes cleaner code to use groups.

Try it without the “youtube” after “switch”

Here’s how I turn on an off my av components. Alexa sees all of them as switches

switch:      
  - platform: broadlink
    host: 192.168.13.142
    mac: 'b4430DFBDD71'
    switches:
      tv:
        friendly_name: "TV Power"
        command_on: 'JgAYAZWSFDYUNRQ1FREUERQRFBEUERQ1FTUUNRQRFREUERQRFBEUERQ1FBIUERQRFBEUERQRFDYUERQ1FDUVNRQ1FDYTNhQABfqVkhQ1FTUUNRQRFREUERQRFBETNhQ2FDUUERQRFBITEhQRExIUNRQRFBIUERQRFBEUERQ1FBIUNRQ1FDYUNRQ1FTUUAAX6lZIUNRU1FDUUERURFBETEhQRFDUUNhQ1FBEUERMTFBETEhQRFDUUERQSFBEUERQRFBEUNRQSFDUUNRQ2FDUUNRQ2FAAF+pOUFDUTNxM2ExITEhMTExITEhM2EzYUNhMSExITEhMSExMTEhM2ExITEhMSExMTEhMSEzYTEhM3EzYTNhQ2EzYTNxMADQU='
        command_off: 'JgAYAZWSFDYUNRQ1FREUERQRFBEUERQ1FTUUNRQRFREUERQRFBEUERQ1FBIUERQRFBEUERQRFDYUERQ1FDUVNRQ1FDYTNhQABfqVkhQ1FTUUNRQRFREUERQRFBETNhQ2FDUUERQRFBITEhQRExIUNRQRFBIUERQRFBEUERQ1FBIUNRQ1FDYUNRQ1FTUUAAX6lZIUNRU1FDUUERURFBETEhQRFDUUNhQ1FBEUERMTFBETEhQRFDUUERQSFBEUERQRFBEUNRQSFDUUNRQ2FDUUNRQ2FAAF+pOUFDUTNxM2ExITEhMTExITEhM2EzYUNhMSExITEhMSExMTEhM2ExITEhMSExMTEhMSEzYTEhM3EzYTNhQ2EzYTNxMADQU='     
      audio:
        friendly_name: "Receiver"
        command_on: 'JgBYAAABJ5AVEBU0FRAUEBU1FBAVNBU1FBAVEBU0FTQVEBU0FTQVEBU0FTQVEBU0FRAVEBQ1FTQVEBQQFTQVEBU0FTQVEBUQFAAFFAABJkgVAAw5AAEnSBUADQU='
        command_off: 'JgBYAAABJ5AVEBU0FRAUEBU1FBAVNBU1FBAVEBU0FTQVEBU0FTQVEBU0FTQVEBU0FRAVEBQ1FTQVEBQQFTQVEBU0FTQVEBUQFAAFFAABJkgVAAw5AAEnSBUADQU='  
      satellite:
        friendly_name: "Satellite"
        command_on: 'JgCOAA3LDV0MXQ1dDF0NOA1dDF0NXQxeDF0NXQxdDV0MXgxdDV0Myw1dDF4MXQ1dDDkMXQ1dDF0NXQxeDF0NXQxdDV0MXQ1dDMwNXQxeDF0NXQw5DF0NXQxdDV0MXgxdDF4MXQ1dDF0NXQ7KDF0NXQxeDF0NOAxeDF0NXQxdDV0MXQ1dDF4MXQ5cDF0Oyg4ADQUAAAAAAAAAAAAA='
        command_off: 'JgCOAA3LDV0MXQ1dDF0NOA1dDF0NXQxeDF0NXQxdDV0MXgxdDV0Myw1dDF4MXQ1dDDkMXQ1dDF0NXQxeDF0NXQxdDV0MXQ1dDMwNXQxeDF0NXQw5DF0NXQxdDV0MXgxdDF4MXQ1dDF0NXQ7KDF0NXQxeDF0NOAxeDF0NXQxdDV0MXQ1dDF4MXQ5cDF0Oyg4ADQUAAAAAAAAAAAAA=' 

what is the purpose of this code below that you have used?:

My script can be seen by Alexa now but it does not see it as a group so for example it sees each channel like 1, 3 and 9 instead of channel 139.

This is what I have in my configuration.yaml:

script:
  tv_smart_hub:
    alias: Smart Hub
    sequence:
      - service: broadlink.send_packet_192_168_0_5
        data:
          packet:
            - "OABIAA7IDVwNXA1cDzQNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDVwOyA1cDVwNXA80DVwNXA1cDVwNXA1cDVwNXA1cDVwNXA1cDwAMyw=="

  tv_right:
    alias: Right
    sequence:
      - service: broadlink.send_packet_192_168_0_5
        data:
          packet:
            - "JgDgAFERFhEWERYRFhEWERYRFxAqERYRFhEWERcAA4JRERYRFhEWERYRFhEWERYRKhEWERYRFhEWAAOCUBIWERYRFhEWEhUSFhEWESkRFhIVEhUSF"

  tv_select:
    alias: Select
    sequence:
      - service: broadlink.send_packet_192_168_0_5
        data:
          packet:
            - "JgDgAFEQKhEWERcQFxAXEBcRFhEqEBcQFxAXERYAA29RECoRFhEXEBcQFxAXERYRKREXEBcQFxAXAANuUREqEBcRFhEWERYRFhEWESoRFhEWERYRF"

and I have grouped the scripts as follows:

group:     
  Sky:
  name: Sky News
  entities:
   - script.tv_smart_hub
   - script.tv_right
   - script.tv_select

Sorry, the default view is unnecessary. It just puts the groups together on the homepage.

Try indenting.

group:     
  Sky:
    name: Sky News
    entities:
      - script.tv_smart_hub
      - script.tv_right
      - script.tv_select

Nope it doesnt like it. Alexa cannot detect the group but detects the individual scripts. Can I see how you have set up your Alexa (emulated hue)?

Not much to my emulated hue. All it is, is

emulated_hue:

If your Alexa is seeing individual scripts you can group them in Alexa.
My Alexa only saw one script so setting up groups in HA worked for me.

thank you everything working fine now. I setup emulated hue as:

emulate_hue:

can I ask you the delays that you have put, does it delay in changing from channel 1 to 2 or is it the duration of which the channel 1 is pressed for on the screen?