from ir_helpers import * light_counter = CyclicCounter( lambda v: light.lampe_ersterstock.turn_on(**v), [ {'color_temp': 492}, {'xy_color': [0.5794, 0.3752]}, {'xy_color': [0.5535, 0.4104]}, {'xy_color': [0.4662, 0.3252]}, {'xy_color': [0.3423, 0.2252]}, {'xy_color': [0.346, 0.394]}, {'xy_color': [0.4119, 0.3671]}, {'xy_color': [0.408, 0.517]}, {'color_temp': 202}, ], ) def music_mapping(player): player = {'player': player} return { 'btn_1': radio_f('Bayern 1', **player), 'btn_2': radio_f('Bayern 2', **player), 'btn_3': radio_f('BR Heimat', **player), 'btn_4': radio_f('Bayern+', **player), 'btn_5': radio_f('BR24', **player), 'btn_6': radio_f('BR-Klassik', **player), 'btn_7': playlist_f('Gesammelte Weihnachtslieder', **player), 'btn_8': playlist_f('Harmonic Brass Christmas', **player), 'btn_9': playlist_f('German Brass Christmas', **player), 'key_numeric_star': playlist_f('Weihnachten mit den Wiener Sängerknaben', **player), 'btn_0': playlist_f('Weihnachten mit den Wiener Sängerknaben', **player), 'key_numeric_pound': playlist_f('SammlungGeorg', **player), } def light_mapping(): return { 'key_red': light_counter.next, 'key_green': light_counter.prev, 'key_blue': light.lampe_ersterstock.turn_off, 'key_yellow': light.lampe_ersterstock.turn_off, 'key_channelup': lambda: dimmer.dim(entity_id='light.lampe_ersterstock', offset=+30), 'key_channeldown': lambda: dimmer.dim(entity_id='light.lampe_ersterstock', offset=-30), } # ------------------------------------------------------------------------------------------------- @event_trigger("ir_command_received", "host == 'esszimmerradio.fritz.box' and repeat_counter == 0") def ir_remote_esszimmer_oben(button_name=None, **kwargs): mapping = { **music_mapping('media_player.esszimmer'), **light_mapping(), } buttons_to_switch_on = ['key_play', 'key_power'] + [f'btn_{i}' for i in range(10)] buttons_to_switch_off = ['key_goto', 'key_pause'] if button_name in buttons_to_switch_on: switch.esszimmer_oben_radio_steckdose1.turn_on() elif button_name in buttons_to_switch_off: switch.esszimmer_oben_radio_steckdose1.turn_off() elif button_name == 'key_record': sysdweb.restart(service_name="squeezelite", hostname="esszimmerradio.fritz.box") if button_name in mapping: mapping[button_name]() @event_trigger("ir_command_received", "host == 'musikserverWohnzimmerOben.fritz.box' and repeat_counter==0") def ir_remote_wohnzimmer_oben(button_name=None, **kwargs): mapping = { **music_mapping('media_player.wohnzimmer'), **light_mapping(), } if button_name in mapping: mapping[button_name]()