summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/automation/shack-startup.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-04-17 19:21:16 +0200
committertv <tv@krebsco.de>2020-04-17 19:21:16 +0200
commite1bfdd8d839929538d36e421908a96407b3aa0ab (patch)
tree557bf9a711f06997e846a5ef14a4105248f1da8c /krebs/2configs/shack/glados/automation/shack-startup.nix
parent6ace0f7b6941c1c9476d84944cdba8bedf98d95d (diff)
parent07f18d851a974ee594c92e3332f167ef3b1d259f (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/2configs/shack/glados/automation/shack-startup.nix')
-rw-r--r--krebs/2configs/shack/glados/automation/shack-startup.nix82
1 files changed, 82 insertions, 0 deletions
diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix
new file mode 100644
index 000000000..35314923b
--- /dev/null
+++ b/krebs/2configs/shack/glados/automation/shack-startup.nix
@@ -0,0 +1,82 @@
+# needs:
+# binary_sensor.portal_lock
+# sensor.keyholder
+# media_player.lounge
+let
+ glados = import ../lib;
+in
+[
+ {
+ alias = "Greet new keyholder for key exchange";
+ initial_state = true;
+ trigger = {
+ platform = "state";
+ entity_id = "sensor.keyholder";
+ };
+ condition = {
+ condition = "template";
+ value_template = "{{ trigger.from_state.state != 'No Keyholder' }}";
+ };
+ action = glados.say.kiosk "Danke {{trigger.to_state.state}} für das Übernehmen des Keys von {{trigger.from_state.state}}";
+ # action = [];
+ }
+
+ {
+ alias = "Start Music on portal lock on";
+ # TODO: use "power" trigger
+ trigger = {
+ platform = "state";
+ entity_id = "binary_sensor.portal_lock";
+ to = "on";
+ for.seconds = 30;
+ };
+ condition = {
+ condition = "and";
+ conditions =
+ [
+ { # only start if a keyholder opened the door and if the lounge mpd is currently not playing anything
+ condition = "template";
+ value_template = "{{ state('sensor.keyholder') != 'No Keyholder' }}";
+ }
+ {
+ condition = "state";
+ entity_id = "media_player.lounge";
+ state = "idle";
+ }
+ ];
+ };
+ action = [
+ {
+ service = "media_player.volume_set";
+ data = {
+ entity_id = "media_player.lounge";
+ volume_level = 1.0;
+ };
+ }
+ {
+ service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.lounge";
+ media_content_type = "playlist";
+ media_content_id = "ansage";
+ };
+ }
+ { delay.seconds = 8; }
+ {
+ service = "media_player.volume_set";
+ data = {
+ entity_id = "media_player.lounge";
+ volume_level = 0.6;
+ };
+ }
+ {
+ service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.lounge";
+ media_content_type = "playlist";
+ media_content_id = "lassulus superradio";
+ };
+ }
+ ];
+ }
+]