Change input select from TV source

Hello how are you?
I wanted to consult you with two things that I don’t know how to solve.
The first is when I turn on the TV and it starts a certain source and has to change the input.
Second case when I change the input
I’m a little lost with this
I use a broadlink to change the source of the tv
Could you guide me a bit to know how I can do it? Thanks
I do not pretend that they do it but that they guide me. Thank you

input_select:
name: source samsung tv
options:
- hdmi1
- hdmi2
- av

First case

  change_input_tv_samsung:
    sequence:
      - choose:
          - conditions: "{{ state_attib('media_player.samsung.title_source' is 'hdm1' }}"
            sequence:
              - service: remote.send_command
                target:
                  entity_id: input_select.hmd_samsung
                data: change input select

Second case when I change the input

          - conditions: "{{ states('input._select.hdmi_samsung_tv' }}"
            sequence:
              - service: remote.send_command
                target:
                  entity_id: remote.broadlink_m3_remote_living
                data:
                  command: b64:JgBYAAABKpITExMTFBITNhMTExMTEhMTEzcTExQ1ExMTNxMSFRETExQRFREVERQ1ExMTExMTExITExQSExIUEhM3ExMTEhURFBITEhQ2EzcTExMSExMTExQADQU=
        default: []

Please state your model of Samsung TV.
I do not self own a Samsung TV anymore, but I believe that many TVs that can be pulled as media players in HA also can be controlled the same way, so maybe there is no need for the Broadlink.

Thanks. The television that I have has no integration because it is a few years old. That’s why I handle it with a broadlink.

ok, I thought you got the state_attrib values in the first case directly from the TV.

This is what I get but I can’t modify anything

volume_level: 0.67
is_volume_muted: false
media_title: TV
friendly_name: SamsungTv

As I stated I do not have a Samsung TV, but if a TV is having an interface to present values, then it usually also have a way to change those values.
Sometimes it might require an integration or some extra configuration, but the ones that can help you probably have to know the TV model to give you the best way to do it.

Make sure you are checking for things like input._select shown above, small errors like that will just make everything more difficult.


You can’t just piece together service calls like this. Check Developer ToolsServices to see what services are available and how to use them. To change what an input_select has currently selected, use something like this:

service: input_select.select_option
data:
  option: hdm1
target:
  entity_id: input_select.hmd_samsung

For your second case, what is it not doing that you expect it to do? I don’t have a remote to check the service call for you, can you do it how I described above?

1 Like

This is perfect. The only thing is to replace HDMI 1 by an attribute value

service: input_select.select_option
data:
  option: {{ state_attr('media_player.bdv_n9200w', 'media_title') }}  ????
target:
  entity_id: input_select.bdv_n9200w

I don’t know if something like this can be done

My other question was how to do so that when an input_select changes, a broadlink remote control executes several actions to get to the source I chose. For example if I select hdm2 and I am in 1 I have to change once but if it is before several times. I do not know if you understand.

Thank you

You should not change your entity_id.
The entity_id is the entity you want to call the service on, which should be your TV.
The line {{ state_attr(‘media_player.bdv_n9200w’, ‘media_title’) }} is the one that gets replaced with the output from it, so if it outputs hdm1, then the TV changes to that.

You can test the output by opening Developer Tools in the Left sidebar and then choose Template in the top.
Delete the demo template text and paste in

{{ state_attr('media_player.bdv_n9200w', 'media_title') }}

then the result will be shown in the right side.

Hi
I used the developer template and this {{state_attr (‘media_player.bdv_n9200w’, ‘media_title’)}} at a certain point brought me back TV. So this value is correct but not how I am writing it since it tells me that it is not correct

  - alias: bdv_n9200w_input_select
    service: input_select.select_option
    data:
      option: {{ state_attr('media_player.bdv_n9200w', 'media_title') }}
    target:
      entity_id: input_select.home  

Check the media player in developer tools

I tried various things but couldn’t get it to work. Obviously I am erring in the way to configure it

  - alias: bdv_n9200w_input_select
    service: input_select.select_option
    data_template:   
      option: "{{ state_attr('media_player.bdv_n9200w','media_title') }}"
    target:
      entity_id: input_select.home  

What is the error message?

You are trying to change the value of the HA input_select variable with your script and the value you change want to change it to needs to be defined as an option in the imput_select definition.

What I want is for you to change the selection from the source list when you turn on the computer or change it from a remote control.

Logger: homeassistant.config
Source: config.py:464
First occurred: 18:17:45 (2 occurrences)
Last logged: 21:38:08

Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->service. (See ?, line ?).

It describes the problem for you: This is an invalid config. You can’t just throw service calls into an automation, they must be in the action list. I’d recommend reading through the docs here and the ones linked at the end, as well as the docs for service calls.

I put the solution to this post. Thank you very much everyone for the help

  - alias: bdv_n9200w_input_select
    description: "Set input select to value of media title whenever media content id changes"
    trigger:
      - platform: state
        entity_id: media_player.bdv_n9200w
        attribute: media_content_id
    condition: []
    action:
      - service: input_select.select_option
        data:   
          option: "{{ state_attr('media_player.bdv_n9200w','media_content_id')[7:] }}"
        target:
          entity_id: input_select.home 
1 Like