summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/home/ham/automation/check-in.nix
blob: 21040b4094d58c6541f94d92e8b07f4a16a32f07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
let
  button = "binary_sensor.arbeitszimmer_onebutton_button";
  light = "light.arbeitszimmer_onebutton_led";
  at_work = "input_boolean.felix_at_work";
  lib = import ../lib;
  say = lib.say.living_room;
in
{
  services.home-assistant.config.input_boolean.felix_at_work.name = "Felix auf Arbeit";
  services.home-assistant.config.automation =
    [
      { alias = "Push Check-in Button Felix with button";
        trigger = [
            {
              platform = "state";
              entity_id = button;
              to = "on";
              for.seconds = 1;
            }
        ];
        condition = [
        ];
        action =
          [
            { choose = [
                {
                  conditions = {
                    condition = "state";
                    entity_id = at_work;
                    state =  "off";
                  };
                  sequence = [
                    { service = "light.turn_on";
                      target.entity_id = light;
                      data.brightness = 200;
                    }
                    { service = "homeassistant.turn_on";
                      entity_id = at_work;
                    }
                  ] ++ (say "Willkommen auf Arbeit");
                }
                {
                  conditions = {
                    condition = "state";
                    entity_id = at_work;
                    state =  "on";
                  };
                  sequence = [
                    { service = "light.turn_off";
                      target.entity_id = light;
                    }
                    { service = "homeassistant.turn_off";
                      entity_id = at_work;
                    }
                  ] ++ (say "Endlich ist Pappa fertig mit arbeit!");
                }
              ];
            }
          ];
      }
    ];
}