Ajuda com template para Canais TV

É o seguinte, devido a minha box da Vodafone não permitir interagir com o HA directamente, comprei um broadlink RM Pro para a mudança de canais.
Mas com isto preciso de ajuda com uma automação que trabalhe juntamente com o “input_select”

A duvida é se é possivel criar uma só automação para fazer o trabalho todo. Já experimentei criando uma automação para cada canal, e assim funciona mas ficaria com muitas automaçoes.

Deixo as configuraçoes.

input_select:

#### 
  canal:  
name: 'Escolhe o Canal'
options:
  - ESCOLHE AQUI O CANAL
  - RTP 1
  - RTP 2
  - CANAL 12
  - CANAL 18
initial: ESCOLHE AQUI O CANAL


script:
  tecla1:
    sequence:
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgBUAAwTFRQVFBYJDBMVFAwJDAkMCQsJCwoVFAwAC1sOEhYTFhMWCQwTFRQMBw4HDQkMCQsKFhMMAAtbDRIWFBUUFgcNFBYTDAkMCQsJDAkLChUUDAANBQAAAAA='
#      - delay:
#          seconds: 0
  tecla2:
    sequence:
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgA0AA4RFhQWExYJDBMVFA4HDAkLCQwJFhMWAAtmDhEYERYUFgkLFBYTDAkLCQwJDAkVFBUADQUAAAAA'
#      - delay:
#          seconds: 0

  canal12:
    sequence:
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgBUAAwTFRQVFBYJDBMVFAwJDAkMCQsJCwoVFAwAC1sOEhYTFhMWCQwTFRQMBw4HDQkMCQsKFhMMAAtbDRIWFBUUFgcNFBYTDAkMCQsJDAkLChUUDAANBQAAAAA='
      - delay:
          seconds: 0
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgA0AA4RFhQWExYJDBMVFA4HDAkLCQwJFhMWAAtmDhEYERYUFgkLFBYTDAkLCQwJDAkVFBUADQUAAAAA'
#      - delay:
#          seconds: 0
  canal18:
    sequence:
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgBUAAwTFRQVFBYJDBMVFAwJDAkMCQsJCwoVFAwAC1sOEhYTFhMWCQwTFRQMBw4HDQkMCQsKFhMMAAtbDRIWFBUUFgcNFBYTDAkMCQsJDAkLChUUDAANBQAAAAA='
      - delay:
          seconds: 0
      - service: switch.broadlink_send_packet_192_168_1_92
        data:
          packet:
          - 'JgA0AA4RFhQVFBYJDBMVFA0HDAkWFAsJDAkWAAtlDxEWExYUFQoLFBUUDQcMCRYTCwoMCRYADQUAAAAA'
      - delay:
          seconds: 0

automation:

  - alias: Escolha de canal box
    #hide_entity: true
    trigger:
      - platform: state
    #- entity_id: input_select.canal
        entity_id: input_select.canal
        from: "ESCOLHE AQUI O CANAL"
    action:
      - service: script.turn_on
        data_template:
          entity_id: >
            {%- if is_state('input_select.canal', 'RTP 1') -%}
              script.tecla1
            {%- elif is_state('input_select.canal', 'RTP 2') -%}
              script.tecla2
            {%- elif is_state('input_select.canal', 'CANAL 12') -%}
              script.canal12
            {%- endif -%}

O erro está aqui no final. Eu se carregar no “CANAL12” na barra do input_select não acontece nada…

Olá,

A solução que utilizo:

broadlink.yaml

media_player:

  • platform: broadlink
    name: Cozinha TV
    host: 192.168.11.242
    mac: ‘B4:43:AA:BB:CC:DD’
    ircodes_ini: ‘broadlink_media_codes/lg.ini’

lg.ini

[general]
turn_off = JgBYAAABKpIUERQRFDUUERQRFBEUERMSEzYUNhMSEzYUNhM2FDYUNhMRFBEUERQ2ExEUERQRFBEUNRQ2FDYTEhM2FDYTNhQ2FAAFJQABKkgUAAxVAAEqSBQADQU=
turn_on = JgBYAAABKpIUERQRFDUUERQRFBEUERMSEzYUNhMSEzYUNhM2FDYUNhMRFBEUERQ2ExEUERQRFBEUNRQ2FDYTEhM2FDYTNhQ2FAAFJQABKkgUAAxVAAEqSBQADQU=
previous_channel = JgBQAAABKJMUERQRFDYTEhMRFBEUERQREzYUNhQREzYUNhQ2EzYUNhQ1FBEUERQRFBETEhMRFBEUERQ2EzYUNhQ1FDYUNhM2FAAFJgABJ0sTAA0FAAAAAAAAAAA=
next_channel = JgBQAAABKJQSExETEjgSExEUERMSExITEjgROBITEjgROBI4EjgROBITEhMRFBETEhMSExITEhMROBI4EjgROBI4ETkROBI4EQAFKAABKEoSAA0FAAAAAAAAAAA=
volume_down = JgBQAAABKJMTEhMSEzcSExISExIUERMSEzcTNhQREzYUNhQ2EzYUNhQ2EzYUERQRExITERQRFBEUERQREzYUNhQ1FDYUNhM2FAAFJgABKEoTAA0FAAAAAAAAAAA=
volume_up = JgBQAAABKZIUERQRFDYTERQRFBEUERQREzYUNhQREzYUNhQ1FDYUNhMSEzYUERQRFBETERQRFBEUNhMSEzYUNhM2FDYUNhM2FAAFJgABKUkUAA0FAAAAAAAAAAA=
mute = JgBQAAABKJQRFBETEjgRFBEUERMSExITEjgROBITEjgROBI4ETkROBI4ERQRExI4EhMRFBEUERMSExI4ETgSExI4ETgSOBE5EQAFKAABKEoSAA0FAAAAAAAAAAA=

[sources]
#Channel 0 = JgBQAAABKpEUERQRFDYTEhMRFBEUERQRFDUUNhQRFDUUNhQ2EzYUNhQRExITERQRFDYUERMRFBEUNhQ1FDYUNhMSEzYUNhQ1FAAFJgABKUkUAA0FAAAAAAAAAAA=
RTP1 = JgBQAAABKpIUERQREzYUERQRFBEUERMSEzYUNhMSEzYUNhM2FDYUNhM2FBEUERQREzYUERQRFBETEhM2FDYUNRQRFDYUNRQ2FAAFJQABKkgUAA0FAAAAAAAAAAA=
RTP2 = JgBQAAABKpIUERQRFDUUERQRFBEUERQREzYUNhQREzYUNhQ1FDYUNhMSEzYUERQRFDUUERQRFBEUNRQRFDYUNRQRFDYUNhM2FAAFJgABKUkTAA0FAAAAAAAAAAA=
SIC = JgBQAAABKpIUERMSEzYUERQRFBETERQRFDYUNRQRFDYUNRQ2FDYTNhQ2FDUUERQRFDYTEhMRFBEUERQRFDUUNhQRFDUUNhQ2EwAFJgABKkgUAA0FAAAAAAAAAAA=
TVI = JgBQAAABKpIUERQREzYUERQRFBETEhMRFDYUNhMRFDYUNhM2FDYUNRQRFBEUNhQREzYUERQRFBETNhQ2FBETNhQRFDYTNhQ2FAAFJQABKkgUAA0FAAAAAAAAAAA=

Espero ter ajudado!

Obrigado @CCPEIXOTO, também já tive esse exemplo. Mas queria algo como este:

https://gyazo.com/d5690ac80835cc799061633908ff11a2
https://gyazo.com/a0185b4facc33bd2d991609691ebad11

E queria juntar o que aparece no “input_select” a uma unica automação.
Senão terei de fazer como neste exemplo se assim nao for possivel:

automation:
  - alias: RTP1 HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "RTP 1 HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal201

  - alias: RTP2
trigger:
  platform: state
  entity_id: input_select.canal
  to: "RTP 2"
action:
  service: script.turn_on
  data:
    entity_id: script.tecla2
  
  - alias: SIC HD
trigger:
  platform: state
  entity_id: input_select.canal
#      to: "SIC HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal303

  - alias: TVI
trigger:
  platform: state
  entity_id: input_select.canal
  to: "TVI"
action:
  service: script.turn_on
  data:
    entity_id: script.tecla4

  - alias: SIC NOTICIAS HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "SIC NOTICIAS HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal305

  - alias: RTP 3
trigger:
  platform: state
  entity_id: input_select.canal
  to: "RTP 3"
action:
  service: script.turn_on
  data:
    entity_id: script.tecla6

  - alias: TVI 24
trigger:
  platform: state
  entity_id: input_select.canal
  to: "TVI 24"
action:
  service: script.turn_on
  data:
    entity_id: script.tecla7

  - alias: CM TV
trigger:
  platform: state
  entity_id: input_select.canal
  to: "CM TV"
action:
  service: script.turn_on
  data:
    entity_id: script.tecla8

  - alias: SIC MULHER HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "SIC MULHER HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal311

  - alias: Porto CANAL HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "PORTO CANAL HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal13

  - alias: SIC CARAS HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "SIC CARAS HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal314

  - alias: SIC RADICAL HD
trigger:
  platform: state
  entity_id: input_select.canal
  to: "SIC RADICAL HD"
action:
  service: script.turn_on
  data:
    entity_id: script.canal315

@CCPEIXOTO só tens para aterar os 4 canais? Não usas para canais com 2 ou 3 numeros pois não?

Consegui resolver este problema. Fica aqui o codigo caso alguem precise:

  - alias: Escolha de canal box
    trigger:
      - platform: state
        entity_id: input_select.canal
        from: "ESCOLHE AQUI O CANAL"
    action:
      - service: script.turn_on
        data_template:
          entity_id: >
           {% if is_state("input_select.canal", "SIC NOTICIAS") %}
                  script.tecla5
                {%-elif is_state("input_select.canal", "RTP 3") %}
                  script.tecla6
                {%-elif is_state("input_select.canal", "TVI 24") %}
                  script.tecla7
                {%-elif is_state("input_select.canal", "CMTV") %}
                  script.tecla8
                {%-elif is_state("input_select.canal", "SPORT TV+") %}
                  script.tecla9
                {%-elif is_state("input_select.canal", "SIC RADICAL") %}
                  script.sicradical
                {%-elif is_state("input_select.canal", "24 KITCHEN") %}
                  script.24kitchen
                {%-elif is_state("input_select.canal", "HOLLYWOOD") %}
                  script.hollywood
                {%-elif is_state("input_select.canal", "CINEMUNDO") %}
                  script.cinemundo
                {%-elif is_state("input_select.canal", "AMC") %}
                  script.amc
                {%-elif is_state("input_select.canal", "VH1") %}
                  script.vh1
                {%-elif is_state("input_select.canal", "DISCOVERY") %}
                  script.discovery
                {%-elif is_state("input_select.canal", "NATIONAL") %}
                  script.national
                {%-elif is_state("input_select.canal", "HISTORIA") %}
                  script.historia
                {%-elif is_state("input_select.canal", "ODISSEIA") %}
                  script.odisseia
                {% else %}
                  none
                {% endif %}

Abraço

Este tópico foi automaticamente fechado 90 dias após a última resposta. Novas respostas não são permitidas.


Copyright © 2017-2020. Todos os direitos reservados
CPHA.pt - info@cpha.pt


FAQ | Termos de Serviço/Regras | Política de Privacidade