summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/home/ham/lib
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs/home/ham/lib')
-rw-r--r--makefu/2configs/home/ham/lib/cheat-sheet.nix42
-rw-r--r--makefu/2configs/home/ham/lib/default.nix50
2 files changed, 74 insertions, 18 deletions
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 000000000..f593ef4ec
--- /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 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";
};
};