summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/automation
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-01-18 15:24:18 +0100
committertv <tv@krebsco.de>2021-01-18 15:24:18 +0100
commitff6f5ef5e1cdbd27b2211c54643fa2754f888cbb (patch)
treeb33763a7ac8040efe988f8bed2fe1c649cc155dd /krebs/2configs/shack/glados/automation
parent7b7ebd8708885633c926c21a4b71d5d4ce8931cf (diff)
parent2a32b7731496615e43a06ec1049f6716c49a1999 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/2configs/shack/glados/automation')
-rw-r--r--krebs/2configs/shack/glados/automation/hass-restart.nix39
-rw-r--r--krebs/2configs/shack/glados/automation/party-time.nix45
-rw-r--r--krebs/2configs/shack/glados/automation/shack-startup.nix165
3 files changed, 129 insertions, 120 deletions
diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix
index 1b380204d..5f61e19f1 100644
--- a/krebs/2configs/shack/glados/automation/hass-restart.nix
+++ b/krebs/2configs/shack/glados/automation/hass-restart.nix
@@ -1,21 +1,24 @@
# needs:
# light.fablab_led
-[
- { alias = "State on HA start-up";
- trigger = {
- platform = "homeassistant";
- event = "start";
- };
- # trigger good/bad air
- action = [
- { service = "light.turn_on";
- data = {
- entity_id = "light.fablab_led";
- effect = "Rainbow";
- color_name = "purple";
- };
- }
- ];
- }
-]
+{
+ services.home-assistant.config.automation =
+ [
+ { alias = "State on HA start-up";
+ trigger = {
+ platform = "homeassistant";
+ event = "start";
+ };
+ # trigger good/bad air
+ action = [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Rainbow";
+ color_name = "purple";
+ };
+ }
+ ];
+ }
+ ];
+}
diff --git a/krebs/2configs/shack/glados/automation/party-time.nix b/krebs/2configs/shack/glados/automation/party-time.nix
index dfa42d05c..9e7fe24cd 100644
--- a/krebs/2configs/shack/glados/automation/party-time.nix
+++ b/krebs/2configs/shack/glados/automation/party-time.nix
@@ -6,24 +6,27 @@ let
disko_schalter = "switch.lounge_diskoschalter_relay";
player = "media_player.lounge";
in
-[
- { alias = "Party um 21 Uhr";
- trigger = {
- platform = "sun";
- event = "sunset";
- };
- action =
- ( glados.say.kiosk "Die Sonne geht unter. Und jetzt geht die Party im shack erst richtig los. Partybeleuchtung, aktiviert!" )
- ++
- [
- {
- service = "homeassistant.turn_on";
- entity_id = disko_schalter;
- }
- {
- service = "media_player.turn_on";
- data.entity_id = player;
- } # TODO: also start playlist if nothing is running?
- ];
- }
-]
+{
+ services.home-assistant.config.automation =
+ [
+ { alias = "Party um 21 Uhr";
+ trigger = {
+ platform = "sun";
+ event = "sunset";
+ };
+ action =
+ ( glados.say.kiosk "Die Sonne geht unter. Und jetzt geht die Party im shack erst richtig los. Partybeleuchtung, aktiviert!" )
+ ++
+ [
+ {
+ service = "homeassistant.turn_on";
+ entity_id = disko_schalter;
+ }
+ {
+ service = "media_player.turn_on";
+ data.entity_id = player;
+ } # TODO: also start playlist if nothing is running?
+ ];
+ }
+ ];
+}
diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix
index ac7dd4f1e..471d817a2 100644
--- a/krebs/2configs/shack/glados/automation/shack-startup.nix
+++ b/krebs/2configs/shack/glados/automation/shack-startup.nix
@@ -13,85 +13,88 @@
let
glados = import ../lib;
in
-[
- {
- alias = "Bedanken bei Übernahme von Key";
- initial_state = true;
- trigger = {
- platform = "state";
- entity_id = "sensor.keyholder";
- };
- condition = {
- condition = "template";
- value_template = "{{ (trigger.from_state.state != 'No Keyholder') and (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 }}";
- }
- {
- alias = "Keyholder Begrüßen wenn MPD hoch fährt";
- initial_state = true;
- trigger = {
- platform = "state";
- from = "unavailable";
- entity_id = "media_player.kiosk";
- };
- action = glados.say.kiosk (builtins.readFile ./announcement.j2);
- }
- {
- alias = "Start Music on portal lock on";
- 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 = {
+{
+ services.home-assistant.config.automation =
+ [
+ {
+ alias = "Bedanken bei Übernahme von Key";
+ initial_state = true;
+ trigger = {
+ platform = "state";
+ entity_id = "sensor.keyholder";
+ };
+ condition = {
+ condition = "template";
+ value_template = "{{ (trigger.from_state.state != 'No Keyholder') and (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 }}";
+ }
+ {
+ alias = "Keyholder Begrüßen wenn MPD hoch fährt";
+ initial_state = true;
+ trigger = {
+ platform = "state";
+ from = "unavailable";
+ entity_id = "media_player.kiosk";
+ };
+ action = glados.say.kiosk (builtins.readFile ./announcement.j2);
+ }
+ {
+ alias = "Start Music on portal lock on";
+ 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";
- 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.5; }
- {
- 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";
- };
- }
- ];
- }
-]
+ 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.5; }
+ {
+ 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";
+ };
+ }
+ ];
+ }
+ ];
+}