summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/home/ham/automation/shutdown_button.nix
blob: ec1a2556730ed98dd8d26a17cf9b0c27b82113e7 (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
let
  btn = "sensor.arbeitszimmer_btn1_action";
  lib = import ../lib;
  say = lib.say.living_room;

  all_lights = [
    # Wohnzimmer
    "light.wled"
    "light.wled_2"
    "light.wohnzimmer_komode_osram"
    "light.wohnzimmer_schrank_osram"
    "light.wohnzimmer_fenster_lichterkette_licht"

    # Arbeitszimmer
    "light.wled_3"
    "light.wled_4"
    "light.arbeitszimmer_schrank_dimmer"
    "light.arbeitszimmer_pflanzenlicht"
    "light.wohnzimmer_stehlampe_osram"

    # Keller
    "light.keller_osram"
  ];
  all_media_player = [
    "media_player.living_room"
    "media_player.office"
    "media_player.bedroom"

  ];
in {
  services.home-assistant.config.automation =
    [
      { alias = "Wohnung shutdown single click";
      trigger = [
        {
          platform = "state";
          entity_id = btn;
          to = "single";
        }
      ];
      condition = [ ];
      action = (say "Alles Aus" )++ [
        {
          service = "light.turn_off";
          target.entity_id = all_lights;
        }
        { service = "media_player.media_stop";
          target.entity_id = all_media_player;
        }
      ];
    }
  ];
}