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/default.nix | 50 ++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'makefu/2configs/home/ham/lib/default.nix') diff --git a/makefu/2configs/home/ham/lib/default.nix b/makefu/2configs/home/ham/lib/default.nix index 75be52737..67e8e902d 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