From 965a6c96c3b7216bf8ca1b985f8bece6c73213c4 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 30 Jan 2022 23:51:32 +0100 Subject: ma ham: commit open changes --- makefu/2configs/home/ham/lib/cheat-sheet.nix | 42 +++++++++++++++++++++++ makefu/2configs/home/ham/lib/default.nix | 50 ++++++++++++++++++---------- 2 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 makefu/2configs/home/ham/lib/cheat-sheet.nix (limited to 'makefu/2configs/home/ham/lib') diff --git a/makefu/2configs/home/ham/lib/cheat-sheet.nix b/makefu/2configs/home/ham/lib/cheat-sheet.nix new file mode 100644 index 00000000..f593ef4e --- /dev/null +++ b/makefu/2configs/home/ham/lib/cheat-sheet.nix @@ -0,0 +1,42 @@ +# Begin +let +in { + services.home-assistant.config.automation = + [ + ]; +} + +# example automation + { alias = ""; + trigger = [ + { + platform = "state"; + entity_id = ""; + to = "on"; + for.seconds = 0; + } + ]; + condition = [ + { condition = "state"; + entity_id = ""; + state = "off"; + } + ]; + action = + [ + { choose = [ + { + conditions = { + condition = "state"; + entity_id = ""; + state = "on"; + }; + sequence = [{ + service = "home_assistant.turn_on"; + target.entity_id = ""; + }]; + }]; + default = { }; + } + ]; + } diff --git a/makefu/2configs/home/ham/lib/default.nix b/makefu/2configs/home/ham/lib/default.nix index 75be5273..67e8e902 100644 --- a/makefu/2configs/home/ham/lib/default.nix +++ b/makefu/2configs/home/ham/lib/default.nix @@ -8,36 +8,50 @@ in tts = { message, entity }: [ { - service = "media_player.turn_on"; - data.entity_id = entity; + service = "sonos.snapshot"; + target.entity_id = entity; } { - service = "media_player.play_media"; + service = "tts.google_say"; data = { - entity_id = entity; - media_content_type = "playlist"; - media_content_id = "ansage"; + entity_id = entity; + inherit message; + language = "de"; }; } - { - service = "media_player.turn_on"; - data.entity_id = entity; + #{ wait_template = "{{ is_state('${entity}' , 'playing') }}"; + # timeout = "00:00:02"; + #} + #{ wait_template = "{{ not is_state('${entity}' , 'playing') }}"; + # timeout = "00:01:00"; + #} + { delay.seconds = 1; } + { delay = '' + {% set duration = states.${entity}.attributes.media_duration %} + {% if duration > 0 %} + {% set duration = duration - 1 %} + {% endif %} + {% set seconds = duration % 60 %} + {% set minutes = (duration / 60)|int % 60 %} + {% set hours = (duration / 3600)|int %} + {{ "%02i:%02i:%02i"|format(hours, minutes, seconds)}} + + ''; } - { delay.seconds = 8; } { - service = "tts.say"; - entity_id = entity; - data_template = { - inherit message; - language = "de"; - }; + service = "sonos.restore"; + target.entity_id = entity; } ]; in { - firetv = message: tts { + living_room = message: tts { + inherit message; + entity = "media_player.living_room"; + }; + office = message: tts { inherit message; - entity = "firetv"; + entity = "media_player.office"; }; }; -- cgit v1.2.3