Automation - remember current channel

Hi guys. I have a dumb tv controlled by broadlink rm mini. Is there a way to make home assistant remember which HDMI input it is in? some kind of a tracker

If the boardlink doesn’t report a state, then your only option is to attempt to sync the two up. But that won’t work if you use the physical remote to change the input.

Hi. I am interested in knowing how to sync it.

how are you currently changing the input?

Im using the broadlink platform in HA with smart ir addon

are they separately called services for each input?

Hi. Its the same service. I call it multiple times to change source

So, lets say you have 5 inputs, each having a different service. You would then create an input_select that has 5 different names that match your inputs. You then create 5 different scripts. Each script calls 2 services. The first service being input_select.select_option, and you’d select the appropriate input. The second service would be sending the RF command to change the source/input.

Then when you want to know what input is being used, just look at the input_select.

The problem with this method is that if you change the input outside the home assistant app, you’ll be out of sync with the input_select.

If you post the services, I can help you tailor this whole setup.

Hi. thanks you for your help.

This is the relevant configuration.yaml

switch:
  - platform: broadlink
    host: 192.168.1.101
    mac: '24:df:a7:de:f8:fc'
    type: rm_mini3_redbean
media_player:
  - platform: smartir
    name: Living room TV
    unique_id: living_room_tv
    device_code: 1020
    controller_data: 192.168.1.101
    power_sensor: switch.sonoff_100090867f

This is the service called to change the input:-

data:
  source: Input
entity_id: media_player.living_room_tv
service: media_player.select_source

My inputs are

  1. TV
  2. HDMI 1
  3. HDMI 2
  4. HDMI 3
  5. PC

I looked at the input_select integration.

can it remember the value after a restart?

the documentation says i need a initial value. Does it mean i have to sync everytime I restart HA?

So the service call just Cycles the input?

yes. This is the script i currently use to change between 2 of the HDMI inputs.

'1592989684785':
  alias: Kodi to Chromecast
  sequence:
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
  - delay: 00:00:01
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
  - delay: 00:00:01
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
  - delay: 00:00:01
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
  - delay: 00:00:01
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
'1592990100766':
  alias: Chromecast to kodi
  sequence:
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source
  - delay: 00:00:01
  - data:
      source: Input
    entity_id: media_player.living_room_tv
    service: media_player.select_source

Hi @petro,

With your guidance, i managed to solve it with a few scripts and automation. Input select was the key.

1 Like