From 4ce32d170826360f577624323d94a4c5432764f7 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 9 Jul 2019 13:35:47 +0200 Subject: ma bureautomation: split schlechteluft in 2 automations (long and short) --- .../bureautomation/automation/schlechteluft.nix | 45 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'makefu') diff --git a/makefu/2configs/bureautomation/automation/schlechteluft.nix b/makefu/2configs/bureautomation/automation/schlechteluft.nix index 4a5fb17c..8787ee28 100644 --- a/makefu/2configs/bureautomation/automation/schlechteluft.nix +++ b/makefu/2configs/bureautomation/automation/schlechteluft.nix @@ -1,13 +1,13 @@ let -secs = 60; + long_threshold = 30; in [ { - alias = "Bad Air Alarm"; + alias = "Bad Air Alarm 60 seconds"; trigger = { platform = "numeric_state"; entity_id = "sensor.air_quality"; above = 1523; - for.seconds = secs; + for.seconds = 60; }; condition = { condition = "and"; @@ -29,8 +29,45 @@ in [ "script.schlechteluft" ]; } + ]; + } + { + alias = "Bad Air Alarm ${toString long_threshold} Minutes"; + trigger = + { platform = "numeric_state"; + entity_id = "sensor.air_quality"; + above = 1523; + for.minutes = long_threshold; + }; + condition = { + condition = "and"; + conditions = [ + { condition = "state"; + entity_id = "group.team"; + state = "home"; + } + { condition = "time"; + after = "06:00:00"; + before = "20:00:00"; + } + ]; + }; + + action = [ + { service = "homeassistant.turn_on"; + entity_id = [ + "script.schlechteluft" + ]; + } + { service = "tts.google_say"; + entity_id = "media_player.mpd"; + data_template = { + message = "BEEP BEEP - Die luft ist schon ${toString long_threshold} Minuten schlecht! Student Nummer {{ range(1,500) | random }}, öffne ein Fenster."; + language = "de"; + }; + } { service = "notify.matrix_notify"; - data_template.message = "Bad Air Alarm! VOC above threshold for ${toString secs} seconds ({{states.sensor.air_quality.state_with_unit}})"; + data_template.message = "Schlechte Luft Alarm seit ${toString long_threshold} Minuten ({{states.sensor.air_quality.state_with_unit}})!"; } ]; } -- cgit v1.2.3