summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/bureautomation/automation/bureau-shutdown.nix
blob: 9e6574300e6fa4272fd42c2057cb01d4c575950d (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
[
  { alias = "Turn on Fernseher on movement";
    trigger = {
      platform = "state";
      entity_id = "binary_sensor.motion";
      to = "on";
    };
    action = {
      service = "homeassistant.turn_on";
      entity_id =  [
        "switch.fernseher"
        "switch.feuer"
      ];
    };
  }
  { alias = "Turn off Fernseher 10 minutes after last movement";
    trigger = [
    { # trigger when movement was detected at the time
      platform = "state";
      entity_id = "binary_sensor.motion";
      to = "off";
      for.minutes = 10;
    }
    { # trigger at 20:00 no matter what
      # to avoid 'everybody left before 18:00:00'
      platform = "time";
      at = "18:00:00";
    }
  ];
    action = {
      service = "homeassistant.turn_off";
      entity_id =  [
        "switch.fernseher"
        "switch.feuer"
        "light.status_felix"
      ];
    };
    condition =
    { condition = "and";
      conditions = [
        {
          condition = "time";
          before = "06:30:00"; #only turn off between 6:30 and 18:00
          after  = "18:00:00";
          # weekday = [ "mon" "tue" "wed" "thu" "fri" ];
        }
        {
          condition = "state";
          entity_id = "binary_sensor.motion";
          state = "off";
        }
      ];
    };
  }
]