Hello all,
I’ve been looking for a long time at a way to advance radio stations with my Touch Control 5". The whole thing should run via web radio on VLC.
Here is my final code, in case someone is looking for a similar possibility.
configuration.yaml:
input_select:
radio_stations:
name: Radio Stations
options:
- Sender 1
- Sender 2
- Sender 3
- Sender 4
initial: Sender 1
automations.yaml:
- alias: Radiosender wechseln
trigger:
platform: event
event_type: knx_event
event_data:
destination: '6/0/2'
action:
choose:
# Wenn der Wert "1" empfangen wird, schalte zur nächsten Variable
- conditions: "{{ trigger.event.data.destination == '6/0/2' and trigger.event.data.data == 1 }}"
sequence:
- service: input_select.select_next
target:
entity_id: input_select.radio_stations
- service: media_player.play_media
target:
entity_id: media_player.vlc_telnet
data_template:
media_content_id: >
{% set options = {
'Sender 1': 'media-source://radio_browser/36a6d57a-4d8a-45e3-aad9-7931c6e43c56',
'Sender 2': 'media-source://radio_browser/ca43455f-f027-11e8-a471-52543be04c81',
'Sender 3': 'media-source://radio_browser/c73c63c4-1c84-41f4-bd03-1eb025fb7afe',
'Sender 4': 'media-source://radio_browser/960594a6-0601-11e8-ae97-52543be04c81',
} %}
{{ options[states('input_select.radio_stations')] }}
data:
media_content_type: "audio/mpeg"
# Wenn der Wert "0" empfangen wird, schalte zur vorherigen Variable
- conditions: "{{ trigger.event.data.destination == '6/0/2' and trigger.event.data.data == 0 }}"
sequence:
- service: input_select.select_previous
target:
entity_id: input_select.radio_stations
- service: media_player.play_media
target:
entity_id: media_player.vlc_telnet
data_template:
media_content_id: >
{% set options = {
'Sender 1': 'media-source://radio_browser/36a6d57a-4d8a-45e3-aad9-7931c6e43c56',
'Sender 2': 'media-source://radio_browser/ca43455f-f027-11e8-a471-52543be04c81',
'Sender 3': 'media-source://radio_browser/c73c63c4-1c84-41f4-bd03-1eb025fb7afe',
'Sender 4': 'media-source://radio_browser/960594a6-0601-11e8-ae97-52543be04c81',
} %}
{{ options[states('input_select.radio_stations')] }}
data:
media_content_type: "audio/mpeg"
# Speichere die aktuelle Variable
- conditions: "{{ trigger.event.data.destination == '6/0/2' }}"
sequence:
- service: input_select.select_option
data:
entity_id: input_select.radio_stations
option: "{{ states('input_select.radio_stations') }}"
- service: media_player.play_media
target:
entity_id: media_player.vlc_telnet
Here you can find my desperate attempt to success.
https://community.home-assistant.io/t/using-knx-wall-switch-to-control-homeassistant/243379/40
Here still the possibility to make louder/quieter and to start/stop:
- id: '1677413365306'
alias: Mediensteuerung
description: ''
trigger:
- platform: event
event_type: knx_event
event_data:
destination: 6/0/1
- platform: event
event_type: knx_event
event_data:
destination: 6/0/2
- platform: event
event_type: knx_event
event_data:
destination: 6/0/3
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.destination==''6/0/1'' and trigger.event.data.data
== 1 }}'
sequence:
- service: media_player.media_play
entity_id: media_player.vlc_telnet
- conditions:
- condition: template
value_template: '{{ trigger.event.data.destination==''6/0/1'' and trigger.event.data.data
== 0 }}'
sequence:
- service: media_player.media_stop
entity_id: media_player.vlc_telnet
- conditions:
- condition: template
value_template: '{{ trigger.event.data.destination==''6/0/3'' and trigger.event.data.data
== 1 }}'
sequence:
- repeat:
count: '1'
sequence:
- service: media_player.volume_set
entity_id: media_player.vlc_telnet
data_template:
volume_level: '{{ state_attr(''media_player.vlc_telnet'', ''volume_level'')
| float + 0.01 }}'
- delay: '00:00:00.25'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.destination==''6/0/3'' and trigger.event.data.data
== 0 }}'
sequence:
- repeat:
count: '1'
sequence:
- service: media_player.volume_set
entity_id: media_player.vlc_telnet
data_template:
volume_level: '{{ state_attr(''media_player.vlc_telnet'', ''volume_level'')
| float - 0.01 }}'
- delay: '00:00:00.25'
default: []
mode: restart