From 6474210927d1dd79e86dffaf01df78f3a6a67430 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 22 Dec 2019 20:39:08 +0100 Subject: [PATCH] Fixes in IR remote rules --- config_creation/ir_automations.py | 55 ++++++++++++-------- custom_components/squeezebox_telnet/radio.py | 1 - start_dev.sh | 5 ++ 3 files changed, 39 insertions(+), 22 deletions(-) create mode 100755 start_dev.sh diff --git a/config_creation/ir_automations.py b/config_creation/ir_automations.py index f4e0f6e..2d90d77 100644 --- a/config_creation/ir_automations.py +++ b/config_creation/ir_automations.py @@ -15,20 +15,20 @@ def get_config(): 'group': 'group.bedroom', 'mapping': { - 'key_1': '[playlist] Good Morning', - 'key_2': '[playlist] Good Night Long', - 'key_3': '[playlist] Good Night', + 'btn_1': '[playlist] Good Morning', + 'btn_2': '[playlist] Good Night Long', + 'btn_3': '[playlist] Good Night', - 'key_4': '[playlist] Bar Classics', - 'key_5': '[playlist] Sentimental Moods', - 'key_6': '[playlist] Pop', + 'btn_4': '[playlist] Bar Classics', + 'btn_5': '[playlist] Sentimental Moods', + 'btn_6': '[playlist] Pop', - 'key_7': '[radio] B 5 aktuell', - 'key_8': '[radio] BR-Klassik', - 'key_9': '[playlist] http://opml.radiotime.com/Tune.ashx?id=s25028', # Klassik Radio + 'btn_7': '[radio] B 5 aktuell', + 'btn_8': '[radio] BR-Klassik', + 'btn_9': '[playlist] http://opml.radiotime.com/Tune.ashx?id=s25028', # Klassik Radio 'key_numeric_star': '[radio] Antenne Bayern', - 'key_0': '[radio] Bayern 3', + 'btn_0': '[radio] Bayern 3', 'key_numeric_pound': '[radio] Bayern 2', 'key_red': '[scene] schlafzimmer_orange', @@ -59,16 +59,16 @@ def get_config(): 'group': 'group.living_area', 'mapping': { - 'key_4': '[playlist] Bar Classics', - 'key_5': '[playlist] Sentimental Moods', - 'key_6': '[playlist] Pop', + 'btn_4': '[playlist] Bar Classics', + 'btn_5': '[playlist] Sentimental Moods', + 'btn_6': '[playlist] Pop', - 'key_7': '[radio] B 5 aktuell', - 'key_8': '[radio] BR-Klassik', - 'key_9': '[playlist] http://opml.radiotime.com/Tune.ashx?id=s25028', # Klassik Radio + 'btn_7': '[radio] B 5 aktuell', + 'btn_8': '[radio] BR-Klassik', + 'btn_9': '[playlist] http://opml.radiotime.com/Tune.ashx?id=s25028', # Klassik Radio 'key_numeric_star': '[radio] Antenne Bayern', - 'key_0': '[radio] Bayern 3', + 'btn_0': '[radio] Bayern 3', 'key_numeric_pound': '[radio] Bayern 2', 'key_red': '[scene] wohnbereich_orange', @@ -105,7 +105,8 @@ def automation_from_config(ir_description): elif isinstance(description, str): function, value = split_description(description) if function == 'playlist': - action = service('media_player.play_media', media_player, media_content_id=value) + action = service('media_player.play_media', media_player, + media_content_id=value, media_content_type='music') elif function == 'radio': action = service('media_player.play_media', media_player, media_content_id=value, media_content_type='channel') @@ -127,9 +128,11 @@ def ir_trigger(ir_host, button_name): return { 'platform': 'event', 'event_type': 'ir_command_received', - 'button_name': button_name, - 'repeat_counter': 0, - 'host': ir_host, + 'event_data': { + 'button_name': button_name, + 'repeat_counter': 0, + 'host': ir_host, + } } @@ -211,6 +214,16 @@ def default_music_controls(device_group, ir_host): 'trigger': [ir_trigger(ir_host, 'key_previous'), ir_trigger(ir_host, 'key_rewind')], 'action': service('media_player.media_next_track', device_group), }, + { + 'alias': f'IR {ir_host} Vol Up', + 'trigger': ir_trigger(ir_host, 'key_volumeup'), + 'action': service('media_player.volume_up', device_group), + }, + { + 'alias': f'IR {ir_host} Vol Down', + 'trigger': ir_trigger(ir_host, 'key_volumedown'), + 'action': service('media_player.volume_down', device_group), + }, ] diff --git a/custom_components/squeezebox_telnet/radio.py b/custom_components/squeezebox_telnet/radio.py index bf4cd26..579913a 100644 --- a/custom_components/squeezebox_telnet/radio.py +++ b/custom_components/squeezebox_telnet/radio.py @@ -48,7 +48,6 @@ def get_local_radio_stations(): # goto ompl.radiotime with parameter ?c=local and look for your city there then paste id here query_url = ompl_radio_browse_url + '?id=r100765' result = get_sender_information(query_url) - print(result) return result diff --git a/start_dev.sh b/start_dev.sh new file mode 100755 index 0000000..ec347b3 --- /dev/null +++ b/start_dev.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +./make_config_dev.sh +hass --config ~/code/homeassistant/config/ +