Help to setup channels in LG TV

Hi
I am trying to change channels in my LG TV in HA.
I have the following code which works

wake_on_lan: # enables `wake_on_lan` domain

# LG TV
webostv:
  host: 192.168.1.xx
  name: LG TV Webos
  #other settings
  turn_on_action:
    service: wake_on_lan.send_magic_packet
    data:
      mac: 'A8:xx:xx:B4:49:xx'
  customize:
    sources:
      - livetv
      - netflix
      - hdmi1
      - hdmi3
      - youtube
        
media_player:

Now I would like to add the channels but I don’t know where to add to the code
I tried various combinations (after the above code,inside the above code but it doesn’t work.
Can someone explain what I have to do ?

wake_on_lan: # enables `wake_on_lan` domain

# LG TV
webostv:
  host: 192.168.1.xx
  name: LG TV Webos
  #other settings
  turn_on_action:
    service: wake_on_lan.send_magic_packet
    data:
      mac: 'A8:xx:xx:B4:49:xx'
  customize:
    sources:
      - livetv
      - netflix
      - hdmi1
      - hdmi3
      - youtube
  action: 
    service: media_player.play_media
    data:
      entity_id: media_player.lg_webos_smart_tv
      media_content_id: 1
      media_content_type: "channel"
        
media_player:

The part under action: goes in the action section of an automation or in a script.

I read this, but again I don’t know what exactly means.
I just tried to add an automation
But again it doesn’t work.
Can you help a little more please?

## Change channels      
- id: change channels  
  alias: TV change channels
  action: 
    service: media_player.play_media
    data:
      entity_id: media_player.lg_webos_smart_tv
      media_content_id: 1
      media_content_type: "channel"

You’re missing a trigger and (optional) conditions. What you have there is closer to a script, but you aren’t quite there. See below for the relevant docs sections on automations and scripts:


Do you know how I can define a trigger that will work if I push the next button of the card? because I don’t
Capture20

To configure channels on LG webOS TV, I use input_number and if - then conditions. Below is my working example of automation that switches channels. We have our own voice assistant Yandex Alice and I can switch channels with my voice. I call the channel number, and according to the conditions, the desired channel is put on TV.

alias: 'We switch TV channels through the voice assistant Alice'
description: ''
trigger:
  - platform: state
    entity_id: input_number.tv_channels
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.tv_bedroom
    data:
      media_content_type: channel
      media_content_id: >
        {% if is_state('input_number.tv_channels', '1.0') %} S 02
        {% elif is_state('input_number.tv_channels', '2.0') %} S 03
        {% elif is_state('input_number.tv_channels', '3.0') %} S 04
        {% elif is_state('input_number.tv_channels', '4.0') %} S 05
        {% elif is_state('input_number.tv_channels', '5.0') %} S 06
        {% elif is_state('input_number.tv_channels', '6.0') %} S 07
        {% elif is_state('input_number.tv_channels', '7.0') %} S 08
        {% elif is_state('input_number.tv_channels', '8.0') %} S 09
        {% elif is_state('input_number.tv_channels', '9.0') %} S 10
        {% elif is_state('input_number.tv_channels', '10.0') %} C 06
        {% elif is_state('input_number.tv_channels', '11.0') %} C 07
        {% elif is_state('input_number.tv_channels', '12.0') %} C 08
        {% elif is_state('input_number.tv_channels', '13.0') %} C 09
        {% elif is_state('input_number.tv_channels', '14.0') %} C 10
        {% elif is_state('input_number.tv_channels', '15.0') %} C 11
        {% elif is_state('input_number.tv_channels', '16.0') %} C 12
        {% elif is_state('input_number.tv_channels', '17.0') %} S 11
        {% elif is_state('input_number.tv_channels', '18.0') %} S 12
        {% elif is_state('input_number.tv_channels', '19.0') %} S 13
        {% elif is_state('input_number.tv_channels', '20.0') %} S 14
        {% elif is_state('input_number.tv_channels', '21.0') %} S 16
        {% elif is_state('input_number.tv_channels', '22.0') %} S 17
        {% elif is_state('input_number.tv_channels', '23.0') %} S 18
        {% elif is_state('input_number.tv_channels', '24.0') %} S 19
        {% elif is_state('input_number.tv_channels', '25.0') %} S 20
        {% endif %}
mode: single
Текст на русском (Text in Russian)

Для настройки каналов на ТВ LG Web OS я использую input_number и условия если - то. Ниже мой рабочий пример автоматики который переключает каналы. У нас есть свой голосовой помощник яндекс алиса и я могу переключать каналы голосом. Называю номер канала, а согласно условиям выставляется на ТВ нужный канал.

alias: 'Переключаем ТВ каналы через голосовой помощник Алиса'
description: ''
trigger:
  - platform: state
    entity_id: input_number.tv_channels
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.tv_bedroom
    data:
      media_content_type: channel
      media_content_id: >
        {% if is_state('input_number.tv_channels', '1.0') %} S 02
        {% elif is_state('input_number.tv_channels', '2.0') %} S 03
        {% elif is_state('input_number.tv_channels', '3.0') %} S 04
        {% elif is_state('input_number.tv_channels', '4.0') %} S 05
        {% elif is_state('input_number.tv_channels', '5.0') %} S 06
        {% elif is_state('input_number.tv_channels', '6.0') %} S 07
        {% elif is_state('input_number.tv_channels', '7.0') %} S 08
        {% elif is_state('input_number.tv_channels', '8.0') %} S 09
        {% elif is_state('input_number.tv_channels', '9.0') %} S 10
        {% elif is_state('input_number.tv_channels', '10.0') %} C 06
        {% elif is_state('input_number.tv_channels', '11.0') %} C 07
        {% elif is_state('input_number.tv_channels', '12.0') %} C 08
        {% elif is_state('input_number.tv_channels', '13.0') %} C 09
        {% elif is_state('input_number.tv_channels', '14.0') %} C 10
        {% elif is_state('input_number.tv_channels', '15.0') %} C 11
        {% elif is_state('input_number.tv_channels', '16.0') %} C 12
        {% elif is_state('input_number.tv_channels', '17.0') %} S 11
        {% elif is_state('input_number.tv_channels', '18.0') %} S 12
        {% elif is_state('input_number.tv_channels', '19.0') %} S 13
        {% elif is_state('input_number.tv_channels', '20.0') %} S 14
        {% elif is_state('input_number.tv_channels', '21.0') %} S 16
        {% elif is_state('input_number.tv_channels', '22.0') %} S 17
        {% elif is_state('input_number.tv_channels', '23.0') %} S 18
        {% elif is_state('input_number.tv_channels', '24.0') %} S 19
        {% elif is_state('input_number.tv_channels', '25.0') %} S 20
        {% endif %}
mode: single