summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/home/ham/media
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2022-01-30 23:51:32 +0100
committermakefu <github@syntax-fehler.de>2022-01-30 23:51:32 +0100
commit965a6c96c3b7216bf8ca1b985f8bece6c73213c4 (patch)
tree546b554bb339859a2fb182d4b9df8c21db5fc085 /makefu/2configs/home/ham/media
parenta721b7ad9b605dc90fa731b2f9a176f2238dc82f (diff)
ma ham: commit open changes
Diffstat (limited to 'makefu/2configs/home/ham/media')
-rw-r--r--makefu/2configs/home/ham/media/firetv.nix32
-rw-r--r--makefu/2configs/home/ham/media/remote_sound_wohnzimmer.nix107
-rw-r--r--makefu/2configs/home/ham/media/sonos.nix7
3 files changed, 146 insertions, 0 deletions
diff --git a/makefu/2configs/home/ham/media/firetv.nix b/makefu/2configs/home/ham/media/firetv.nix
new file mode 100644
index 00000000..429688c6
--- /dev/null
+++ b/makefu/2configs/home/ham/media/firetv.nix
@@ -0,0 +1,32 @@
+let
+ firetv_stick = "192.168.111.24";
+in {
+ services.home-assistant.config = {
+ notify = [
+ #{
+ # platform = "kodi";
+ # name = "Kodi Wohnzimmer";
+ # host = firetv_stick;
+ #}
+ {
+ platform = "nfandroidtv";
+ name = "FireTV Wohnzimmer";
+ host = firetv_stick;
+ }
+ ];
+ media_player = [
+ #{
+ # platform = "kodi";
+ # name = "FireTV Stick kodi";
+ # host = firetv_stick;
+ #}
+ { platform = "androidtv";
+ name = "FireTV Stick";
+ device_class = "firetv";
+ # adb_server_ip = firetv_stick;
+ host = firetv_stick;
+ port = 5555;
+ }
+ ];
+ };
+ }
diff --git a/makefu/2configs/home/ham/media/remote_sound_wohnzimmer.nix b/makefu/2configs/home/ham/media/remote_sound_wohnzimmer.nix
new file mode 100644
index 00000000..2091ca94
--- /dev/null
+++ b/makefu/2configs/home/ham/media/remote_sound_wohnzimmer.nix
@@ -0,0 +1,107 @@
+{ lib, ...}:
+let
+ statecond = cond: { # cond must be a list
+ condition = "template";
+ value_template = "{{ trigger.to_state.state in ( " +
+ (lib.concatMapStringsSep "," (x: "'${x}'") cond) + ") }}";
+ };
+ vol_change = 0.030;
+
+ max_repeat = "30"; # max loops to repeat before bailing out
+ remote = "sensor.wohnzimmer_sound1_action";
+ player = "media_player.living_room";
+ last_state_sensor_name = "last_rotation_action";
+ last_state_sensor = "input_text.last_rotation_action";
+ # - service: media_player.volume_set
+ # target:
+ # entity_id: media_player.kitchen
+ # data:
+ # volume_level: {{ state_attr('media_player.kitchen', 'volume_level') + 0.02 }}
+ rotate_stop = "brightness_stop";
+ rotate_right = "brightness_move_up";
+ rotate_left = "brightness_move_down" ;
+
+ single_click = "toggle";
+ double_click = "brightness_step_up";
+ triple_click = "brightness_step_down";
+in {
+ services.home-assistant.config.input_text."${last_state_sensor_name}".name = "Last action of the wohnzimmer";
+ services.home-assistant.config.automation = [
+ {
+ trigger = {
+ platform = "state";
+ entity_id = remote;
+ to = [ rotate_stop ];
+ };
+ action = [
+ { service = "input_text.set_value";
+ target.entity_id = last_state_sensor;
+ data.value = "stop";
+ }
+ ];
+ }
+ {
+ alias = "Perform Actions with ${remote}";
+ trigger = {
+ platform = "state";
+ entity_id = remote;
+ to = [ single_click double_click triple_click rotate_left rotate_right ];
+ };
+ #mode = "queued";
+ #max = 5;
+ mode = "single";
+ #max_exceeded = "silent";
+ action = [
+ {
+ choose = [
+ {
+ conditions = statecond [ single_click ];
+ sequence = [
+ { service = "media_player.media_play_pause";
+ target.entity_id = player;
+ }
+ ];
+ }
+ {
+ conditions = statecond [ rotate_left rotate_right ];
+ sequence = let
+ vol_up = toString vol_change;
+ vol_down = toString (-1 * vol_change);
+ in [
+ {
+ variables.nextvol = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} ${vol_down} {% else -%} ${vol_up} {% endif -%}'';
+ variables.state = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} left {% else -%} right {% endif -%}'';
+ }
+ { service = "input_text.set_value";
+ target.entity_id = last_state_sensor;
+ data.value = ''{{ state }}'';
+ }
+ {
+ repeat = {
+ sequence = [
+ { service = "media_player.volume_set";
+ target.entity_id = player;
+ data.volume_level = ''{{ state_attr("${player}","volume_level") + (nextvol|float) }}'';
+ }
+ { delay.milliseconds = "150"; }
+ ];
+ while = [
+ {
+ condition = "template";
+ value_template = ''{{ states("${last_state_sensor}") == state }}'';
+ }
+ {
+ condition = "template";
+ value_template = "{{ repeat.index <= ${max_repeat}}}";
+ }
+ ];
+ };
+ }
+ ];
+ }
+ ];
+ }
+ ];
+ }
+ ];
+}
diff --git a/makefu/2configs/home/ham/media/sonos.nix b/makefu/2configs/home/ham/media/sonos.nix
new file mode 100644
index 00000000..5b969451
--- /dev/null
+++ b/makefu/2configs/home/ham/media/sonos.nix
@@ -0,0 +1,7 @@
+{
+ services.home-assistant.config.sonos.media_player.hosts = [
+ "192.168.111.30"
+ "192.168.111.31"
+ ];
+
+ }