summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/bureautomation/automation
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2021-03-19 09:19:25 +0100
committerlassulus <lassulus@lassul.us>2021-03-19 09:19:25 +0100
commit86b458d5d3aaac94d51b0a860376725c0a70b6fb (patch)
tree82407d4e8454b3abfbb8288f8bc6765c64bf036b /makefu/2configs/bureautomation/automation
parent3bbbc82ae9ab9f0ac737b2ff0b55b50ae9c77b8a (diff)
parent758660945c712b645e755e9101a9fd3d8a325c91 (diff)
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs/bureautomation/automation')
-rw-r--r--makefu/2configs/bureautomation/automation/philosophische-tuer.nix128
1 files changed, 59 insertions, 69 deletions
diff --git a/makefu/2configs/bureautomation/automation/philosophische-tuer.nix b/makefu/2configs/bureautomation/automation/philosophische-tuer.nix
index 9ccb81348..8c3fed6de 100644
--- a/makefu/2configs/bureautomation/automation/philosophische-tuer.nix
+++ b/makefu/2configs/bureautomation/automation/philosophische-tuer.nix
@@ -16,93 +16,83 @@ let
sha256 = "0bm0697fyf6s05c6yw6y25cyck04rlxj1dgazkq8mfqk6756v2bq";
};
samples = user: lib.mapAttrsToList
- (file: _: ''"${prefix}/${name}/${user}/${file}"'')
+ (file: _: ''"${prefix}/${user}/${file}"'')
(builtins.readDir (toString ( recordrepo+ "/recordings/${user}")));
random_tuerspruch = ''{{'' + (lib.concatStringsSep "," ((samples "Felix") ++ (samples "Sofia") ++ (samples "Markus"))) + ''| random}}''; # TODO read from derivation
in
{
- systemd.tmpfiles.rules = [
- "d ${audiodir} - hass hass - -"
- ];
-
systemd.services.copy-philosophische-tuersounds = {
description = "copy philosophische tuer";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
- User = "hass";
- WorkingDirectory = audiodir;
ExecStart = pkgs.writeDash "update-samples" ''
- cp -vr ${recordrepo} ${audiodir}
+ rm -rf "${audiodir}"
+ cp -vr "${recordrepo}/recordings" "${audiodir}"
'';
};
};
-
- services.home-assistant.config.media_extractor = { };
- services.home-assistant.config.script."philosophische_tuer" = {
- alias = "Durchsage der philosophischen Tür";
- sequence = [
- { service = "media_player.play_media";
- data = {
- entity_id = "media_player.mpd";
- media_content_type = "playlist";
- media_content_id = "ansage";
+ services.home-assistant.config = {
+ media_extractor = { };
+ script."philosophische_tuer" = {
+ alias = "Durchsage der philosophischen Tür";
+ sequence = [
+ { service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.mpd";
+ media_content_type = "playlist";
+ media_content_id = "ansage";
+ };
+ }
+ { delay.seconds = 5; }
+ { service = "media_extractor.play_media";
+ entity_id = "media_player.mpd";
+ data_template = {
+ media_content_id = random_tuerspruch;
+ media_content_type = "MUSIC";
+ };
+ }
+ ];
+ };
+ automation =
+ [
+ {
+ alias = "Tür offen seit ${toString short_threshold} sekunden";
+ trigger =
+ { platform = "state";
+ entity_id = sensor;
+ to = "on";
+ for.seconds = 60;
};
+ action = [
+ { service = "homeassistant.turn_on";
+ entity_id = "script.philosophische_tuer";
+ }
+ ];
}
- { delay.seconds = 5; }
- { service = "media_extractor.play_media";
- entity_id = "media_player.mpd";
- data_template = {
- media_content_id = random_tuerspruch;
- media_content_type = "MUSIC";
+ {
+ alias = "Tür offen seit ${toString long_threshold} minuten";
+ trigger =
+ { platform = "state";
+ entity_id = sensor;
+ to = "on";
+ for.minutes = long_threshold;
};
+
+ action = [
+ { service = "homeassistant.turn_on";
+ entity_id = "script.philosophische_tuer" ;
+ }
+ { service = "tts.google_say";
+ entity_id = "media_player.mpd";
+ data_template = {
+ message = "BEEP BOOP - Die Tür ist schon seit ${toString long_threshold} Minuten offen! Student Nummer {{ range(1,500) | random }}, bitte schliesse die Tür";
+ language = "de";
+ };
+ }
+ ];
}
];
};
- services.home-assistant.config.automation =
- [
- {
- alias = "Tür offen seit ${toString short_threshold} sekunden";
- trigger =
- { platform = "state";
- entity_id = sensor;
- to = "on";
- for.seconds = 60;
- };
- condition = { };
- action = [
- { service = "homeassistant.turn_on";
- entity_id = [
- "script.philosophische_tuer"
- ];
- }
- ];
- }
- {
- alias = "Tür offen seit ${toString long_threshold} minuten";
- trigger =
- { platform = "state";
- entity_id = sensor;
- to = "on";
- for.minutes = long_threshold;
- };
- condition = { };
-
- action = [
- { service = "homeassistant.turn_on";
- entity_id = [
- "script.philosophische_tuer"
- ];
- }
- { service = "tts.google_say";
- entity_id = "media_player.mpd";
- data_template = {
- message = "BEEP BOOP - Die Tür ist schon seit ${toString long_threshold} Minuten offen! Student Nummer {{ range(1,500) | random }}, bitte schliesse die Tür";
- language = "de";
- };
- }
- ];
- }
- ];
}