summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2019-07-04 08:05:54 +0200
committermakefu <github@syntax-fehler.de>2019-07-04 08:05:54 +0200
commitb3b2dd65211fa7bcdb2f5e507895ce5edde45160 (patch)
tree6745f8e24413677172732db7e1bbb2fabc435fae
parentc2230d30c5d75622eb25f3e0df977691cbf01058 (diff)
ma bureautomation: stream-line 10h timers
-rw-r--r--makefu/2configs/bureautomation/combination/10h_timers.nix202
1 files changed, 18 insertions, 184 deletions
diff --git a/makefu/2configs/bureautomation/combination/10h_timers.nix b/makefu/2configs/bureautomation/combination/10h_timers.nix
index d398e8a34..4bbae0dda 100644
--- a/makefu/2configs/bureautomation/combination/10h_timers.nix
+++ b/makefu/2configs/bureautomation/combination/10h_timers.nix
@@ -1,14 +1,15 @@
{lib, ... }:
let
- persons = [ "frank" "daniel" "thorsten" "carsten" "thierry" "ecki"
- # "felix" # custom actions
+ persons = [ "frank" "daniel" "thorsten" "carsten" "thierry" "ecki" "felix"
+ "anthony" # antony
+ "thierry" # tjeri
];
random_zu_lange = name: ''{{ [
"Du musst jetzt endlich nach Hause gehen ${name}!",
"10 Stunden sind rum, bald schenkst du den Franzosen deine Lebenszeit",
"Nur eine Minute über 10 Stunden kann zu einer Stunde Arbeit für Thorsten werden, ${name}.",
"In 10 Minuten kommt dich der Security Mann holen, ${name}",
- "Zu lange, ${name}!" ] | random }}'' ;
+ "Zu lange, ${name}!" ] | random }}'' ;
random_announce = name: ''{{ [
@@ -94,8 +95,9 @@ let
};
zu_lange_user = name:
- { "announce_${name}" = {
+ { "zu_lange_${name}" = {
alias = "Random Zu Lange ${name}";
+
sequence = [
{ service = "media_player.play_media";
data = {
@@ -176,14 +178,21 @@ let
];
}
- {
- alias = "Zu lange ${name}!";
+ { alias = "Zu lange ${name}!";
trigger =
{
platform = "event";
event_type = "timer.finished";
event_data.entity_id = "timer.${name}_10h";
};
+
+ condition =
+ {
+ condition = "state";
+ entity_id = "device_tracker.${name}_phone";
+ state = "home";
+ };
+
action =
[
{ service = "homeassistant.turn_on";
@@ -198,186 +207,11 @@ let
in
{
timer =lib.fold lib.recursiveUpdate {}
- ([
- (tmr_10h "felix")
- { felix_8_30h = {
- name = "Felix 8_30h Timer";
- duration = "08:30:00";
- };
- felix_7h = {
- name = "Felix 7h Timer";
- duration = "07:00:00";
- };
- }
- ] ++ (map tmr_10h persons));
- automation = lib.flatten (map automation_10h persons) ++
- [
- { alias = "start Felix 10h";
- trigger = {
- platform = "state";
- entity_id = [ "device_tracker.felix_phone" "device_tracker.felix_laptop" ];
- from = "not_home";
- to = "home";
- };
- condition = {
- condition = "and";
- conditions = [
- {
- condition = "state";
- entity_id = "timer.felix_10h";
- state = "idle";
- }
- {
- condition = "time";
- after = "06:00:00";
- before = "12:00:00";
- }
- ];
- };
- action = [
- { service = "timer.start";
- entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ] ;
- }
- { service = "homeassistant.turn_on";
- entity_id = [
- # "script.buzz_felix"
- "script.blitz_10s"
- ];
- }
- {
- service = "tts.google_say";
- entity_id = "media_player.mpd";
- data_template = {
- message = "Willkommen, Felix!";
- language = "de";
- };
- }
- { service = "light.turn_on";
- data = {
- effect = "2";
- entity_id = [ "light.status_felix" ];
- };
- }
- ];
- }
-
- { alias = "Disable Felix timer at button press";
- trigger = {
- platform = "state";
- entity_id = "binary_sensor.redbutton";
- to = "on";
- };
- condition = {
- condition = "and";
- conditions = [
- {
- condition = "state";
- entity_id = "timer.felix_10h";
- state = "active";
- }
- {
- condition = "time";
- after = "12:00:00";
- before = "22:00:00";
- }
- ];
- };
- action =
- [
- {
- service = "timer.cancel";
- entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ];
- }
- {
- service = "homeassistant.turn_on";
- entity_id = [ "script.buzz_red_led_fast" ];
- }
- {
- service = "homeassistant.turn_off";
- entity_id = [ "light.status_felix" ];
- }
- ];
- }
-
- {
- alias = "Genug gearbeitet Felix";
- trigger =
- {
- platform = "event";
- event_type = "timer.finished";
- event_data.entity_id = "timer.felix_7h";
- };
- action =
- [
- { service = "light.turn_on";
- data = {
- rgb_color= [0 255 0];
- # effect = "0";
- entity_id = [ "light.status_felix" ];
- };
- }
- ];
- }
-
- {
- alias = "nun aber nach hause";
- trigger =
- {
- platform = "event";
- event_type = "timer.finished";
- event_data.entity_id = "timer.felix_8_30h";
- };
- action =
- [
- { service = "light.turn_on";
- data = {
- rgb_color= [255 255 0];
- # effect = "0";
- entity_id = [ "light.status_felix" ];
- };
- }
- ];
- }
-
- {
- alias = "Zu lange Felix!";
- trigger =
- {
- platform = "event";
- event_type = "timer.finished";
- event_data.entity_id = "timer.felix_10h";
- };
- action =
- [
- {
- service = "notify.telegrambot";
- data = {
- title = "Zu lange Felix!";
- message = "Du bist schon 10 Stunden auf Arbeit, geh jetzt gefälligst nach Hause!";
- };
- }
- {
- service = "homeassistant.turn_on";
- entity_id = [
- # "script.buzz_felix"
- "script.blitz_10s"
- ];
- }
- { service = "light.turn_on";
- data = {
- rgb_color= [255 0 0];
- effect = "0";
- entity_id = [ "light.status_felix" ];
- };
- }
- ];
- }
- ]
- ;
+ (map tmr_10h persons);
+ automation = (lib.flatten (map automation_10h persons));
script = lib.fold lib.recursiveUpdate {} (
(map (ab: buzz_user ab.fst ab.snd) (lib.zipLists persons patterns)) ++
(map (p: announce_user p) persons) ++
- (map (p: zu_lange_user p) persons) ++
- [ (announce_user "felix" ) (buzz_user "felix" [125 250 500] ) ]
+ (map (p: zu_lange_user p) persons)
);
}