Newbie: adding a second automation, the first one becomes inactive

Hi, first week of HA and struggling with this. I want to add my LG webos tv manually. Webostv plattform added and working. I have an automation for a drop-down menu to change the source: it works. But when I add a second automation to change the channels, the first one doe snot work anymore. The second automation alone also works. What am I missing?

alias: "Trocar entrada da TV"
id: "trocar_entrada_tv" 
trigger:
  - platform: state
    entity_id: input_select.tv_source
action:
  - service: media_player.select_source
    data:
      entity_id: media_player.lg_webos_tv_oled55b9dla
      source: "{{ states('input_select.tv_source') }}"
mode: restart

alias: "Trocar canal da TV"
id: "trocar_canal_tv"
trigger:
  - platform: state
    entity_id: input_select.tv_channel
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.lg_webos_tv_oled55b9dla
    data:
      media_content_id: "{{ states('input_select.tv_channel') }}"
      media_content_type: "channel"
mode: restart

also tried with all possible automation modes.

Automations are a list not a dictionary. See: Thomas Lovén - YAML for Non-programmers

- alias: "Trocar entrada da TV"
  id: "trocar_entrada_tv" 
  trigger:
    - platform: state
      entity_id: input_select.tv_source
  action:
    - service: media_player.select_source
      data:
        entity_id: media_player.lg_webos_tv_oled55b9dla
        source: "{{ states('input_select.tv_source') }}"
  mode: restart

- alias: "Trocar canal da TV"
  id: "trocar_canal_tv"
  trigger:
    - platform: state
      entity_id: input_select.tv_channel
  action:
    - service: media_player.play_media
      target:
        entity_id: media_player.lg_webos_tv_oled55b9dla
      data:
        media_content_id: "{{ states('input_select.tv_channel') }}"
        media_content_type: "channel"
  mode: restart
2 Likes

Thank for the link @tom_l . I realized now thatwas not the second automation which makes my first not working, but the second input_select. With only the first input_select (sources) it works. With both (sources and channels) the first one does not work anymore. Could you take a look please?

automations:

- alias: "Trocar entrada da TV"
  id: "trocar_entrada_tv" 
  trigger:
    - platform: state
      entity_id: input_select.tv_source
  action:
    - service: media_player.select_source
      data:
        entity_id: media_player.lg_webos_tv_oled55b9dla
        source: "{{ states('input_select.tv_source') }}"
  mode: restart

- alias: "Trocar canal da TV"
  id: "trocar_canal_tv"
  trigger:
    - platform: state
      entity_id: input_select.tv_channel
  action:
    - service: media_player.play_media
      target:
        entity_id: media_player.lg_webos_tv_oled55b9dla
      data:
        media_content_id: "{{ states('input_select.tv_channel') }}"
        media_content_type: "channel"
  mode: restart

configuration:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

input_select:
  tv_source:
    name: Fonte da TV
    options:
      - Apple TV
      - Disney+
      - Foto und Video
      - GALERIE
      - HDMI 1
      - HDMI 2
      - HDMI 3
      - Live TV
      - Moonlight
      - Netflix
      - Plex
      - Prime Video
      
input_select:
  tv_channel:
    name: Canal da TV
    options:
      - "1"
      - "2"
      - "3"
      - "4"
      - "5"
    initial: "1"
    icon: mdi:television

input_select: defines an integration/helper it should only appear once in your configuration.yaml file. If you have multiple input selects then they need to be defined as a dictionary under the single instance of input_select: e.g.


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

input_select:
  tv_source:
    name: Fonte da TV
    options:
      - Apple TV
      - Disney+
      - Foto und Video
      - GALERIE
      - HDMI 1
      - HDMI 2
      - HDMI 3
      - Live TV
      - Moonlight
      - Netflix
      - Plex
      - Prime Video
      
  tv_channel:
    name: Canal da TV
    options:
      - "1"
      - "2"
      - "3"
      - "4"
      - "5"
    initial: "1"
    icon: mdi:television

Or you could use an !include and put all your input selects in a separate file.

1 Like

Perfect. Tks.