ma bureautomation: prototype philosophische-tuer

This commit is contained in:
makefu 2021-03-17 20:03:16 +01:00
parent 53351c8944
commit 7351675feb
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -16,30 +16,25 @@ let
sha256 = "0bm0697fyf6s05c6yw6y25cyck04rlxj1dgazkq8mfqk6756v2bq"; sha256 = "0bm0697fyf6s05c6yw6y25cyck04rlxj1dgazkq8mfqk6756v2bq";
}; };
samples = user: lib.mapAttrsToList samples = user: lib.mapAttrsToList
(file: _: ''"${prefix}/${name}/${user}/${file}"'') (file: _: ''"${prefix}/${user}/${file}"'')
(builtins.readDir (toString ( recordrepo+ "/recordings/${user}"))); (builtins.readDir (toString ( recordrepo+ "/recordings/${user}")));
random_tuerspruch = ''{{'' + (lib.concatStringsSep "," ((samples "Felix") ++ (samples "Sofia") ++ (samples "Markus"))) + ''| random}}''; # TODO read from derivation random_tuerspruch = ''{{'' + (lib.concatStringsSep "," ((samples "Felix") ++ (samples "Sofia") ++ (samples "Markus"))) + ''| random}}''; # TODO read from derivation
in in
{ {
systemd.tmpfiles.rules = [
"d ${audiodir} - hass hass - -"
];
systemd.services.copy-philosophische-tuersounds = { systemd.services.copy-philosophische-tuersounds = {
description = "copy philosophische tuer"; description = "copy philosophische tuer";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
User = "hass";
WorkingDirectory = audiodir;
ExecStart = pkgs.writeDash "update-samples" '' ExecStart = pkgs.writeDash "update-samples" ''
cp -vr ${recordrepo} ${audiodir} rm -rf "${audiodir}"
cp -vr "${recordrepo}/recordings" "${audiodir}"
''; '';
}; };
}; };
services.home-assistant.config = {
services.home-assistant.config.media_extractor = { }; media_extractor = { };
services.home-assistant.config.script."philosophische_tuer" = { script."philosophische_tuer" = {
alias = "Durchsage der philosophischen Tür"; alias = "Durchsage der philosophischen Tür";
sequence = [ sequence = [
{ service = "media_player.play_media"; { service = "media_player.play_media";
@ -59,7 +54,7 @@ in
} }
]; ];
}; };
services.home-assistant.config.automation = automation =
[ [
{ {
alias = "Tür offen seit ${toString short_threshold} sekunden"; alias = "Tür offen seit ${toString short_threshold} sekunden";
@ -69,13 +64,9 @@ in
to = "on"; to = "on";
for.seconds = 60; for.seconds = 60;
}; };
condition = { };
action = [ action = [
{ service = "homeassistant.turn_on"; { service = "homeassistant.turn_on";
entity_id = [ entity_id = "script.philosophische_tuer";
"script.philosophische_tuer"
];
} }
]; ];
} }
@ -87,13 +78,10 @@ in
to = "on"; to = "on";
for.minutes = long_threshold; for.minutes = long_threshold;
}; };
condition = { };
action = [ action = [
{ service = "homeassistant.turn_on"; { service = "homeassistant.turn_on";
entity_id = [ entity_id = "script.philosophische_tuer" ;
"script.philosophische_tuer"
];
} }
{ service = "tts.google_say"; { service = "tts.google_say";
entity_id = "media_player.mpd"; entity_id = "media_player.mpd";
@ -105,4 +93,6 @@ in
]; ];
} }
]; ];
};
} }