diff --git a/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix new file mode 100644 index 000000000..bd36f02cd --- /dev/null +++ b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix @@ -0,0 +1,108 @@ +{ lib, ... }: +let + remote = "sensor.schlafzimmer_music_remote_action"; + hlib = import ../lib; + step = 0.02; + #room = "bedroom"; + room = "office"; + + player = "media_player.${room}"; + say = hlib.say."${room}"; + + remote_action = key: actions: { + conditions = ''{{ trigger.entity_id == 'binary_sensor.matrix_button_${toString key}' }}''; + sequence = actions; + }; + all_buttons = map (key: "binary_sensor.matrix_button_${toString key}") [ + 0 1 2 3 4 5 6 7 8 9 + "b9" "b10" "b11" "b12" "b13" "b14" + ]; +in + { + services.home-assistant.config.rest_command = { + good_song = { + url = "http://prism.r:8001/good"; + method = "POST"; + }; + bad_song = { + url = "http://prism.r:8001/skip"; + method = "POST"; + }; + }; + services.home-assistant.config.automation = + [ + { alias = "Arbeitszimmer Matrix music action"; + trigger = [ + { + platform = "state"; + entity_id = all_buttons; + } + ]; + action = + [ + { choose = [ + (remote_action "9" { + service = "media_player.media_play"; + target.entity_id = player; + }) + (remote_action "7" + { + service = "media_player.media_mute"; + target.entity_id = player; + data.is_volume_muted = ''{{ not state_attr('${player}' , 'is_volume_muted') }}''; + } + ) + (remote_action "2" + { + service = "media_player.media_stop"; + target.entity_id = player; + } + ) + + (remote_action "b9" + ((say "Guter Song {{ states.sensor.the_playlist_song.state }}") ++ [ + { service = "rest_command.good_song"; } + ])) + + (remote_action "b10" + ((say "Schlechter Song {{ states.sensor.the_playlist_song.state }}") ++ [ + { service = "rest_command.bad_song"; } + ])) + (remote_action "3" + ((say "Starte Lassulus Super Radio") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://radio.lassul.us:8000/radio.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "1" + ((say "Starte Groovesalad") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://ice2.somafm.com/groovesalad-128.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "8" { + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") + (${toString step}|float) }}''; + }) + (remote_action "5"{ + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") - (${toString step}|float) }}''; + }) + ]; + #default = { }; + } + ]; + } + ]; + +} diff --git a/makefu/2configs/home/ham/media/firetv.nix b/makefu/2configs/home/ham/media/firetv.nix index 429688c6a..fc33346cd 100644 --- a/makefu/2configs/home/ham/media/firetv.nix +++ b/makefu/2configs/home/ham/media/firetv.nix @@ -3,14 +3,9 @@ let in { services.home-assistant.config = { notify = [ - #{ - # platform = "kodi"; - # name = "Kodi Wohnzimmer"; - # host = firetv_stick; - #} { platform = "nfandroidtv"; - name = "FireTV Wohnzimmer"; + name = "FireTV Wohnzimmer Notification"; host = firetv_stick; } ]; @@ -20,10 +15,10 @@ in { # name = "FireTV Stick kodi"; # host = firetv_stick; #} + # Configuration needs to be done by hand via web interface "integration" { platform = "androidtv"; - name = "FireTV Stick"; - device_class = "firetv"; - # adb_server_ip = firetv_stick; + name = "FireTV Stick Android"; + device_class = "firetv"; host = firetv_stick; port = 5555; } diff --git a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix index f59f022f4..cfa1da44e 100644 --- a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix +++ b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix @@ -1,5 +1,10 @@ { lib, ...}: let + # https://www.radiotheque.de/stream/4744806739035994/ABC-Lounge-Music-Radio/pls/ + # http://listen.radionomy.com/ABC-Lounge + # https://str1.openstream.co/589 + # https://listen.openstream.co/3139/audio + # https://str1.openstream.co/589?aw_0_1st.collectionid%3D3139%26stationId%3D3139%26publisherId%3D613%26k%3D1659381767%26aw_0_azn.pcountry%3D%5B%22FR%22%2C%22IT%22%2C%22DE%22%2C%22ES%22%2C%22GB%22%2C%22CH%22%2C%22CA%22%2C%22AT%22%2C%22US%22%5D%26aw_0_azn.planguage%3D%5B%22en%22%2C%22fr%22%2C%22de%22%5D%26aw_0_azn.pgenre%3D%5B%22Jazz%22%2C%22Easy+Listening%22%2C%22Music%22%5D statecond = cond: { # cond must be a list condition = "template"; value_template = "{{ trigger.to_state.state in ( " + diff --git a/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix new file mode 100644 index 000000000..55b1fd8f5 --- /dev/null +++ b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix @@ -0,0 +1,160 @@ +{ lib, ... }: +let + remote = "sensor.schlafzimmer_music_remote_action"; + hlib = import ../lib; + step = 0.03; + room = "bedroom"; + #room = "office"; + + player = "media_player.${room}"; + say = hlib.say."${room}"; + + remote_action = state: actions: { + conditions = ''{{ trigger.to_state.attributes.action == '${state}' }}''; + sequence = actions; + }; + album_list = [ +# Wieso Weshalb Warum Junior +"Doris%20R%c3%bcbel,%20JUMBO%20Neue%20Medien%20%26%20Verlag%20GmbH/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Helfen,%20teilen,%20sich%20vertragen" +"Wieso%3f%20Weshalb%3f%20Warum%3f%20junior/Mein%20Kindergarten" +"Wieso%3f%20Weshalb%3f%20Warum%3f%20junior/Unser%20Werkzeug" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Am%20Meer" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Ampel,%20Stra%c3%9fe%20und%20Verkehr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Autos%20und%20Laster" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Bagger" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Bauernhof" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Flughafen" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Pinguin" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Traktor" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Baustelle" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Eisenbahn" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Feuerwehr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Jahreszeiten" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20M%c3%bcllabfuhr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Polizei" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Rettungsfahrzeuge" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Ritterburg" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Heute,%20morgen,%20jetzt%20und%20gleich" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Im%20Streichelzoo" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20In%20den%20Bergen" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Mama,%20Papa,%20Oma,%20Opa" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Mein%20Hund" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Tanken,%20waschen,%20reparieren" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Tiere%20in%20Afrika" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Unsere%20Tierkinder" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Unterwegs%20mit%20Bus%20und%20Bahn" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20ich%20alles%20kann" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20kriecht%20und%20krabbelt%20da%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20an%20Weihnachten%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Fr%c3%bchling%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Herbst%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Sommer%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Winter%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20der%20Fu%c3%9fballer%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20der%20Polizist" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20die%20Prinzessin%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20w%c3%a4chst%20da%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wenn%20es%20dunkel%20wird" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wer%20arbeitet%20auf%20der%20Baustelle%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wir%20feiern%20Geburtstag" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wir%20gehen%20in%20den%20Zoo" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Z%c3%a4hne%20putzen,%20Pipi%20machen" + + ]; + albums = lib.concatMapStringsSep ", " (x: ''"A:ALBUMARTIST/${x}"'') + album_list; +in +{ + services.home-assistant.config.automation = + [ + { alias = "Schlafzimmer music action"; + trigger = [ + { + platform = "state"; + entity_id = remote; + attribute = "action"; + not_to = ""; + } + ]; + action = + [ + { choose = [ + (remote_action "on" { #also called by hold right and left + service = "media_player.media_play"; + target.entity_id = player; + }) + (remote_action "off" + { + service = "media_player.volume_mute"; + target.entity_id = player; + data.is_volume_muted = ''{{ not state_attr('${player}' , 'is_volume_muted') }}''; + } + ) + + (remote_action "arrow_right_hold" + ((say "Starte Lassulus Super Radio") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://radio.lassul.us:8000/radio.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "arrow_left_hold" + ((say "Starte Deep House Music") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://live.dancemusic.ro:7000/stream.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + #(remote_action "arrow_left_release" { + + #}) + #(remote_action "arrow_left_release" { + + #}) + # TODO: choose random kindermusik? + (remote_action "brightness_move_up" + ((say "Starte Liam Album") ++ [ + { + service = "media_player.play_media"; + target.entity_id = player; + data = { + media_content_id = "{{ [${albums}]|random }}"; + media_content_type = "album"; + }; + } + ]) + ) + (remote_action "brightness_move_down" + ((say "Stoppe Musik") ++ [ + { + service = "media_player.media_stop"; + target.entity_id = player; + } + ]) + ) + (remote_action "arrow_right_click" { + + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") + (${toString step}|float) }}''; + }) + #(remote_action "brightness_move_down" { + (remote_action "arrow_left_click"{ + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") - (${toString step}|float) }}''; + }) + ]; + #default = { }; + } + ]; + } + ]; + +} \ No newline at end of file diff --git a/makefu/2configs/home/ham/media/sonos.nix b/makefu/2configs/home/ham/media/sonos.nix index 40dcfc3ca..c9cf1a510 100644 --- a/makefu/2configs/home/ham/media/sonos.nix +++ b/makefu/2configs/home/ham/media/sonos.nix @@ -4,5 +4,4 @@ "192.168.111.31" "192.168.111.32" ]; - - } +}