ma bureautomation: move to 20.09 style imports

This commit is contained in:
makefu 2020-11-18 20:50:43 +01:00
parent f66309f028
commit a549744127
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
29 changed files with 795 additions and 752 deletions

View File

@ -1,84 +1,87 @@
[ {
{ alias = "Turn on Fernseher on group home"; services.home-assistant.config.automation =
trigger = { [
platform = "state"; { alias = "Turn on Fernseher on group home";
entity_id = "group.team"; trigger = {
from = "not_home";
to = "home";
for.seconds = 30;
};
action = [
{
service = "homeassistant.turn_on";
entity_id = [
"switch.fernseher"
"switch.feuer"
];
}
{
service = "media_player.kodi_call_method";
data = {
entity_id = "media_player.kodi";
method = "Player.Open";
item.partymode = "music";
};
}
{
service = "notify.telegrambot";
data = {
title = "Bureau Startup";
message = "Das Büro wurde eröffnet";
};
}
];
}
{ alias = "Turn off Fernseher after last in group left";
trigger = [
{ # trigger when movement was detected at the time
platform = "state"; platform = "state";
entity_id = "group.team"; entity_id = "group.team";
from = "home"; from = "not_home";
to = "not_home"; to = "home";
} for.seconds = 30;
{ # trigger at 18:00 no matter what };
# to avoid 'everybody left before 18:00:00' action = [
platform = "time";
at = "18:00:00";
}
];
action = [
{
service = "homeassistant.turn_off";
entity_id = [
"switch.fernseher"
"switch.feuer"
"light.status_felix"
"light.status_daniel"
];
}
{
service = "notify.telegrambot";
data_template = {
title = "Bureau Shutdown";
message = "All devices are turned off due to {{ trigger.platform }}";
};
}
];
condition =
{ condition = "and";
conditions = [
{ {
condition = "time"; service = "homeassistant.turn_on";
before = "06:30:00"; #only turn off between 6:30 and 18:00 entity_id = [
after = "18:00:00"; "switch.fernseher"
# weekday = [ "mon" "tue" "wed" "thu" "fri" ]; "switch.feuer"
];
} }
{ # if anybody is still there {
condition = "state"; service = "media_player.kodi_call_method";
entity_id = "group.team"; data = {
state = "not_home"; entity_id = "media_player.kodi";
method = "Player.Open";
item.partymode = "music";
};
}
{
service = "notify.telegrambot";
data = {
title = "Bureau Startup";
message = "Das Büro wurde eröffnet";
};
} }
]; ];
}; }
} { alias = "Turn off Fernseher after last in group left";
] trigger = [
{ # trigger when movement was detected at the time
platform = "state";
entity_id = "group.team";
from = "home";
to = "not_home";
}
{ # trigger at 18: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"
"light.status_daniel"
];
}
{
service = "notify.telegrambot";
data_template = {
title = "Bureau Shutdown";
message = "All devices are turned off due to {{ trigger.platform }}";
};
}
];
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" ];
}
{ # if anybody is still there
condition = "state";
entity_id = "group.team";
state = "not_home";
}
];
};
}
];
}

View File

@ -1,31 +1,34 @@
[ {
{ alias = "State on HA start-up"; services.home-assistant.config.automation =
trigger = { [
platform = "homeassistant"; { alias = "State on HA start-up";
event = "start"; trigger = {
}; platform = "homeassistant";
action = [ event = "start";
# Startup State };
{ service = "mqtt.publish"; action = [
data = { # Startup State
topic = "/bam/sonoffs/cmnd/state"; { service = "mqtt.publish";
payload = ""; data = {
}; topic = "/bam/sonoffs/cmnd/state";
} payload = "";
# Firmware Version };
{ service = "mqtt.publish"; }
data = { # Firmware Version
topic = "/bam/sonoffs/cmnd/status"; { service = "mqtt.publish";
payload = "2"; data = {
}; topic = "/bam/sonoffs/cmnd/status";
} payload = "2";
# Will trigger restart of all devices! };
#{ service = "mqtt.publish"; }
# data = { # Will trigger restart of all devices!
# topic = "sonoffs/cmnd/SetOption59"; # configure sending state on power change #{ service = "mqtt.publish";
# payload = "1"; # data = {
# }; # topic = "sonoffs/cmnd/SetOption59"; # configure sending state on power change
#} # payload = "1";
]; # };
} #}
] ];
}
];
}

View File

@ -1,35 +1,38 @@
[ {
# TODO: trigger if it is before dusk and somebody arives but nachtlichter are services.home-assistant.config.automation =
# off from last day [
# TODO: do not have nachtlicht turned on at night # TODO: trigger if it is before dusk and somebody arives but nachtlichter are
{ # off from last day
alias = "Turn on Nachtlicht at dusk"; # when it gets dim # TODO: do not have nachtlicht turned on at night
trigger = {
{ platform = "numeric_state"; alias = "Turn on Nachtlicht at dusk"; # when it gets dim
entity_id = "sun.sun"; trigger =
value_template = "{{ state.attributes.elevation }}"; { platform = "numeric_state";
below = 10; entity_id = "sun.sun";
value_template = "{{ state.attributes.elevation }}";
below = 10;
}; };
action = action =
{ service = "homeassistant.turn_on"; { service = "homeassistant.turn_on";
entity_id = [ "group.nachtlicht" ]; entity_id = [ "group.nachtlicht" ];
}; };
} }
{ {
alias = "Turn off Nachtlicht at dawn"; alias = "Turn off Nachtlicht at dawn";
trigger = trigger =
{ platform = "sun"; { platform = "sun";
event = "sunrise"; event = "sunrise";
offset = "01:30:00"; # on dawn offset = "01:30:00"; # on dawn
}; };
# TODO: when somebody is still in the buero # TODO: when somebody is still in the buero
# condition = # condition =
#{ #{
#}; #};
action = action =
{ service = "homeassistant.turn_off"; { service = "homeassistant.turn_off";
entity_id = [ "group.nachtlicht" ]; entity_id = [ "group.nachtlicht" ];
}; };
} }
] ];
}

View File

@ -1,71 +1,75 @@
let let
long_threshold = 30; long_threshold = 30;
in [ in
{ {
alias = "Bad Air Alarm 60 seconds"; services.home-assistant.config.automation =
trigger = [
{ platform = "numeric_state"; {
entity_id = "sensor.air_quality"; alias = "Bad Air Alarm 60 seconds";
above = 1523; trigger =
for.seconds = 60; { platform = "numeric_state";
}; entity_id = "sensor.air_quality";
condition = { above = 1523;
condition = "and"; for.seconds = 60;
conditions = [ };
{ condition = "state"; condition = {
entity_id = "group.team"; condition = "and";
state = "home"; conditions = [
} { condition = "state";
{ condition = "time"; entity_id = "group.team";
after = "06:00:00"; state = "home";
before = "20:00:00"; }
{ condition = "time";
after = "06:00:00";
before = "20:00:00";
}
];
};
action = [
{ service = "homeassistant.turn_on";
entity_id = [
"script.schlechteluft"
];
} }
]; ];
}; }
{
action = [ alias = "Bad Air Alarm ${toString long_threshold} Minutes";
{ service = "homeassistant.turn_on"; trigger =
entity_id = [ { platform = "numeric_state";
"script.schlechteluft" 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";
alias = "Bad Air Alarm ${toString long_threshold} Minutes"; entity_id = [
trigger = "script.schlechteluft"
{ 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"; { service = "tts.google_say";
after = "06:00:00"; entity_id = "media_player.mpd";
before = "20:00:00"; 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";
};
} }
]; ];
}; }
];
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";
};
}
];
}
]

View File

@ -12,6 +12,9 @@ let
# expire_after = "5"; #expire after 5 seconds # expire_after = "5"; #expire after 5 seconds
qos = 1; qos = 1;
}; };
in [ in {
(tasmota_button "RedButton" "redbutton") services.home-assistant.config.binary_sensor =
] [
(tasmota_button "RedButton" "redbutton")
];
}

View File

@ -1,12 +1,15 @@
[ {
{ platform = "mqtt"; services.home-assistant.config.binary_sensor =
device_class = "motion"; [
name = "Motion"; { platform = "mqtt";
state_topic = "/bam/easy2/movement/Switch"; device_class = "motion";
payload_on = "1"; name = "Motion";
payload_off = "0"; state_topic = "/bam/easy2/movement/Switch";
availability_topic = "/bam/easy2/tele/LWT"; payload_on = "1";
payload_available = "Online"; payload_off = "0";
payload_not_available = "Offline"; availability_topic = "/bam/easy2/tele/LWT";
} payload_available = "Online";
] payload_not_available = "Offline";
}
];
}

View File

@ -1,10 +1,13 @@
[ {
{ name = "Poorly Drawn Lines"; services.home-assistant.config.camera =
platform = "generic"; [
still_image_url = http://127.0.0.1:8123/local/lines.png ; { name = "Poorly Drawn Lines";
} platform = "generic";
{ name = "XKCD"; still_image_url = http://127.0.0.1:8123/local/lines.png ;
platform = "generic"; }
still_image_url = http://127.0.0.1:8123/local/xkcd.png ; { name = "XKCD";
} platform = "generic";
] still_image_url = http://127.0.0.1:8123/local/xkcd.png ;
}
];
}

View File

@ -5,22 +5,26 @@ let
inherit name still_image_url; inherit name still_image_url;
platform = "generic"; platform = "generic";
}; };
in [ in
( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg ) {
( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) services.home-assistant.config.camera =
( cam "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg ) [
( cam "Schoch Areal" https://webcam.stuttgart.de/wcam004/current.jpg ) ( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg )
( cam "Leuze" https://webcam.stuttgart.de/wcam005/current.jpg ) ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg )
( cam "Straße Wilhelma" https://webcam.stuttgart.de/wcam006/current.jpg ) ( cam "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg )
( cam "Fernsehturm 1" http://webcam.fernsehturmstuttgart.com/current.jpg ) ( cam "Schoch Areal" https://webcam.stuttgart.de/wcam004/current.jpg )
( cam "Fernsehturm 2" http://webcam.fernsehturmstuttgart.com/current2.jpg ) ( cam "Leuze" https://webcam.stuttgart.de/wcam005/current.jpg )
( cam "Feuerbach Lemberg" http://www.regio7.de/handy/current.jpg ) ( cam "Straße Wilhelma" https://webcam.stuttgart.de/wcam006/current.jpg )
( cam "Flughafen Stuttgart 1" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam2.jpg ) ( cam "Fernsehturm 1" http://webcam.fernsehturmstuttgart.com/current.jpg )
( cam "Flughafen Stuttgart 2" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam5.jpg ) ( cam "Fernsehturm 2" http://webcam.fernsehturmstuttgart.com/current2.jpg )
( cam "Flughafen Stuttgart 3" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam7.jpg ) ( cam "Feuerbach Lemberg" http://www.regio7.de/handy/current.jpg )
( cam "S21 1" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-03/s21-turm03.jpg ) ( cam "Flughafen Stuttgart 1" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam2.jpg )
( cam "S21 2" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-02/s21-turm-02.jpg ) ( cam "Flughafen Stuttgart 2" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam5.jpg )
( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.jpg ) ( cam "Flughafen Stuttgart 3" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam7.jpg )
( cam "S21 4" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Jaegerstrasse-Nordkopf/s21-jaegerstrassse-nordkopf.jpg ) ( cam "S21 1" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-03/s21-turm03.jpg )
( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg ) ( cam "S21 2" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-02/s21-turm-02.jpg )
] ( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.jpg )
( cam "S21 4" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Jaegerstrasse-Nordkopf/s21-jaegerstrassse-nordkopf.jpg )
( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg )
];
}

View File

@ -1,14 +1,17 @@
[ {
{ name = "Baumarkt"; services.home-assistant.config.camera =
platform = "generic"; [
still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt { name = "Baumarkt";
} platform = "generic";
{ name = "Autobahn Heilbronn"; still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt
platform = "generic"; }
still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ; { name = "Autobahn Heilbronn";
} platform = "generic";
{ name = "Autobahn Singen"; still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ;
platform = "generic"; }
still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ; { name = "Autobahn Singen";
} platform = "generic";
] still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ;
}
];
}

View File

@ -1,20 +1,51 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
kodi-host = "192.168.8.11"; kodi-host = "192.168.8.11";
ten_hours = import ./multi/10h_timers.nix { inherit lib; }; # provides: timer automation script
mittagessen = import ./multi/mittagessen.nix { inherit lib; }; # provides: automation script
matrix = import ./multi/matrix.nix { inherit lib; }; # provides: matrix automation
frosch = import ./multi/frosch.nix { inherit lib; }; # provides: sensor binary_sensor switch light script automation
aramark = import ./multi/aramark.nix { inherit lib; }; # provides: sensor binary_sensor
standup = import ./multi/daily-standup.nix { inherit lib; }; # provides: automation script
in { in {
imports = [ imports = [
./ota.nix ./ota.nix
./comic-updater.nix ./comic-updater.nix
./puppy-proxy.nix ./puppy-proxy.nix
# hass config
## complex configs
./multi/daily-standup.nix
./multi/aramark.nix
./multi/matrix.nix
./multi/frosch.nix
./multi/mittagessen.nix
./multi/10h_timers.nix
./switch/tasmota_switch.nix
./switch/rfbridge.nix
./light/statuslight.nix
./light/buzzer.nix
./script/multi_blink.nix
./binary_sensor/buttons.nix
./binary_sensor/motion.nix
# ./sensor/pollen.nix requires dwd_pollen
./sensor/espeasy.nix
./sensor/airquality.nix
./sensor/outside.nix
./sensor/tasmota_firmware.nix
./camera/verkehrskamera.nix
./camera/comic.nix
./camera/stuttgart.nix
./automation/bureau-shutdown.nix
./automation/nachtlicht.nix
./automation/schlechteluft.nix
./automation/hass-restart.nix
./device_tracker/openwrt.nix
./person/team.nix
]; ];
networking.firewall.allowedTCPPorts = [ 8123 ]; networking.firewall.allowedTCPPorts = [ 8123 ];
state = [ "/var/lib/hass/known_devices.yaml" ]; state = [ "/var/lib/hass/known_devices.yaml" ];
services.home-assistant = { services.home-assistant = {
enable = true; enable = true;
autoExtraComponents = true; autoExtraComponents = true;
@ -51,7 +82,6 @@ in {
source = "hass"; source = "hass";
}; };
}; };
matrix = matrix.matrix;
mqtt = { mqtt = {
discovery = true; discovery = true;
discovery_prefix = "homeassistant"; discovery_prefix = "homeassistant";
@ -73,13 +103,6 @@ in {
retain = true; retain = true;
}; };
}; };
switch = (import ./switch/tasmota_switch.nix)
++ frosch.switch
++ (import ./switch/rfbridge.nix);
light = (import ./light/statuslight.nix)
++ (import ./light/buzzer.nix)
++ frosch.light;
timer = ten_hours.timer;
notify = [ notify = [
{ {
platform = "kodi"; platform = "kodi";
@ -93,7 +116,7 @@ in {
(builtins.fromJSON (builtins.readFile (builtins.fromJSON (builtins.readFile
<secrets/hass/telegram-bot.json>)).allowed_chat_ids 0; <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0;
} }
] ++ matrix.notify; ];
media_player = [ media_player = [
{ platform = "kodi"; { platform = "kodi";
host = kodi-host; host = kodi-host;
@ -102,37 +125,10 @@ in {
host = "127.0.0.1"; host = "127.0.0.1";
} }
]; ];
script = lib.fold lib.recursiveUpdate {} [
((import ./script/multi_blink.nix) {inherit lib;})
frosch.script
ten_hours.script
mittagessen.script
# standup.script
];
binary_sensor =
(import ./binary_sensor/buttons.nix)
++ (import ./binary_sensor/motion.nix)
++ frosch.binary_sensor
++ aramark.binary_sensor;
sensor = [] sensor = [{ platform = "version"; }]; # pyhaversion
++ [{ platform = "version"; }] # pyhaversion
# ++ (import ./sensor/pollen.nix)
++ (import ./sensor/espeasy.nix)
++ (import ./sensor/airquality.nix)
++ ((import ./sensor/outside.nix) {inherit lib;})
++ (import ./sensor/influxdb.nix)
++ (import ./sensor/tasmota_firmware.nix)
++ frosch.sensor
++ aramark.sensor;
camera =
(import ./camera/verkehrskamera.nix)
++ (import ./camera/comic.nix)
++ (import ./camera/stuttgart.nix);
person =
(import ./person/team.nix );
frontend = { }; frontend = { };
http = { http = {
@ -263,16 +259,6 @@ in {
# feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ]; # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ];
# we don't use imports because the expressions do not merge in # we don't use imports because the expressions do not merge in
# home-assistant # home-assistant
automation = (import ./automation/bureau-shutdown.nix)
++ (import ./automation/nachtlicht.nix)
++ (import ./automation/schlechteluft.nix)
++ (import ./automation/hass-restart.nix)
++ ten_hours.automation
++ matrix.automation
# ++ standup.automation
++ frosch.automation
++ mittagessen.automation;
device_tracker = (import ./device_tracker/openwrt.nix );
}; };
}; };
} }

View File

@ -1,16 +1,19 @@
# requires `opkg install luci-mod-rpc` on router # requires `opkg install luci-mod-rpc` on router
# see https://www.home-assistant.io/components/luci/ # see https://www.home-assistant.io/components/luci/
[ {
{ platform = "luci"; services.home-assistant.config.device_tracker =
host = "192.168.8.1"; [
username = "root"; { platform = "luci";
password = import <secrets/hass/router.nix>; host = "192.168.8.1";
interval_seconds = 30; # instead of 12seconds username = "root";
consider_home = 300; # 5 minutes timeout password = import <secrets/hass/router.nix>;
new_device_defaults = { interval_seconds = 30; # instead of 12seconds
track_new_devices = true; consider_home = 300; # 5 minutes timeout
hide_if_away = false; new_device_defaults = {
}; track_new_devices = true;
} hide_if_away = false;
] };
}
];
}

View File

@ -21,8 +21,10 @@ let
optimistic = false; optimistic = false;
qos = 0; qos = 0;
}; };
in in {
[ services.home-assistant.config.light =
# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1 [
(tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2 # (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1
] (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2
];
}

View File

@ -48,9 +48,11 @@ let
12 # fire pattern 12 # fire pattern
]; ];
}; };
in in {
[ services.home-assistant.config.light =
(tasmota_rgb "Status Felix" "status1") [
(tasmota_rgb "Status Daniel" "status2") (tasmota_rgb "Status Felix" "status1")
(tasmota_rgb "Buslicht" "buslicht") (tasmota_rgb "Status Daniel" "status2")
] (tasmota_rgb "Buslicht" "buslicht")
];
}

View File

@ -198,11 +198,13 @@ let
]; ];
in in
{ {
timer =lib.fold lib.recursiveUpdate {} services.home-assistant.config = {
(map tmr_10h persons); timer =lib.fold lib.recursiveUpdate {}
automation = (lib.flatten (map automation_10h persons)); (map tmr_10h persons);
script = lib.fold lib.recursiveUpdate {} ( automation = (lib.flatten (map automation_10h persons));
(map announce_user persons) ++ script = lib.fold lib.recursiveUpdate {} (
(map zu_lange_user persons) (map announce_user persons) ++
); (map zu_lange_user persons)
);
};
} }

View File

@ -1,3 +0,0 @@
# Combination Folder
files return a dictionary of different types used in home-assistant instead of
a single thing.

View File

@ -12,13 +12,16 @@ let
((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = ""; }) ((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = ""; })
]; ];
in in
{ {
sensor = (aramark_menue "Menü 1") services.home-assistant.config =
++ (aramark_menue "Menü 2") {
++ (aramark_menue "Mercato") sensor = (aramark_menue "Menü 1")
++ (aramark_menue "Aktion"); ++ (aramark_menue "Menü 2")
binary_sensor = ++ (aramark_menue "Mercato")
[ ++ (aramark_menue "Aktion");
((aramark "pommes" "Pommes" ) // { payload_on = "True"; payload_off = "False"; }) binary_sensor =
]; [
((aramark "pommes" "Pommes" ) // { payload_on = "True"; payload_off = "False"; })
];
};
} }

View File

@ -1,4 +1,4 @@
{ lib }: {lib, ... }:
let let
random_daily_text = ''{{ [ random_daily_text = ''{{ [
"Es ist so weit, es ist Standup Zeit!", "Es ist so weit, es ist Standup Zeit!",
@ -9,46 +9,49 @@ let
"Morgens, halb elf in Deutschland - das Standupchen" ] | random }}''; "Morgens, halb elf in Deutschland - das Standupchen" ] | random }}'';
in { in {
script = services.home-assistant.config =
{ "random_daily" = { {
alias = "Random Daily Introduction"; script =
{ "random_daily" = {
alias = "Random Daily Introduction";
sequence = [ sequence = [
{ service = "media_player.play_media"; { service = "media_player.play_media";
data = { data = {
entity_id = "media_player.mpd"; entity_id = "media_player.mpd";
media_content_type = "playlist"; media_content_type = "playlist";
media_content_id = "ansage"; media_content_id = "ansage";
}; };
} }
{ delay.seconds = 5; } { delay.seconds = 5; }
{ service = "tts.google_say"; { service = "tts.google_say";
entity_id = "media_player.mpd"; entity_id = "media_player.mpd";
data_template = { data_template = {
message = random_daily_text; message = random_daily_text;
language = "de"; language = "de";
}; };
} }
]; ];
};
};
automation = [
{
alias = "Daily Standup";
trigger = {
platform = "time";
at = "10:35:00";
}; };
action = };
[ automation = [
{ service = "homeassistant.turn_on"; {
entity_id = [ alias = "Daily Standup";
"script.blitz_10s" trigger = {
"script.random_daily" platform = "time";
]; at = "10:35:00";
} };
]; action =
[
{ service = "homeassistant.turn_on";
entity_id = [
"script.blitz_10s"
"script.random_daily"
];
}
];
} }
]; ];
};
} }

View File

@ -1,4 +1,4 @@
{ lib }: {lib, ... }:
# needs: binary_sensor.pommes # needs: binary_sensor.pommes
# notify.matrix_notify # notify.matrix_notify
let let
@ -17,83 +17,87 @@ let
"Der Weltmarktpreis von Pommes ist durch verschiedene Weltkrisen leider so hoch, dass Aramark den Verkaufspreis verdoppeln musste.", "Der Weltmarktpreis von Pommes ist durch verschiedene Weltkrisen leider so hoch, dass Aramark den Verkaufspreis verdoppeln musste.",
"Vorfreude, schönste Freude, Freude bei Aramark. Pommes in die Schale rein, alle Kunden werden glücklich sein.", "Vorfreude, schönste Freude, Freude bei Aramark. Pommes in die Schale rein, alle Kunden werden glücklich sein.",
"In 15 Minuten ist es wieder so weit, es ist Pommes Zeit!"] | random }}''; "In 15 Minuten ist es wieder so weit, es ist Pommes Zeit!"] | random }}'';
in { in
sensor = [ {
{ platform = "mqtt"; services.home-assistant.config =
name = "frosch brightness"; {
device_class = "illuminance"; sensor = [
state_topic = "/bam/frosch/sensor/brightness/state"; { platform = "mqtt";
availability_topic = "/bam/frosch/status"; name = "frosch brightness";
payload_available = "online"; device_class = "illuminance";
payload_not_available = "offline"; state_topic = "/bam/frosch/sensor/brightness/state";
} availability_topic = "/bam/frosch/status";
]; payload_available = "online";
binary_sensor = [ payload_not_available = "offline";
{ platform = "mqtt"; }
name = "frosch auge"; ];
state_topic = "/bam/frosch/binary_sensor/froschauge/state"; binary_sensor = [
availability_topic = "/bam/frosch/status"; { platform = "mqtt";
payload_available = "online"; name = "frosch auge";
payload_not_available = "offline"; state_topic = "/bam/frosch/binary_sensor/froschauge/state";
} availability_topic = "/bam/frosch/status";
]; payload_available = "online";
switch = [ payload_not_available = "offline";
{ platform = "mqtt"; }
name = "frosch blasen"; ];
state_topic = "/bam/frosch/switch/blasen/state"; switch = [
command_topic = "/bam/frosch/switch/blasen/command"; { platform = "mqtt";
availability_topic = "/bam/frosch/status"; name = "frosch blasen";
payload_available = "online"; state_topic = "/bam/frosch/switch/blasen/state";
payload_not_available = "offline"; command_topic = "/bam/frosch/switch/blasen/command";
} availability_topic = "/bam/frosch/status";
]; payload_available = "online";
light = []; payload_not_available = "offline";
automation = [ }
{ alias = "Pommeszeit"; ];
trigger = { light = [];
platform = "time"; automation = [
at = "11:00:00"; { alias = "Pommeszeit";
trigger = {
platform = "time";
at = "11:00:00";
};
condition = {
condition = "state";
entity_id = "binary_sensor.pommes"; # from multi/aramark.nix
state = "on";
};
action = [
{ service = "homeassistant.turn_on";
entity_id = [
"script.pommes_announce"
"script.seifenblasen_30s" # from script/multi_blink.nix
];
}
];
}
];
script = {
pommes_announce = {
alias = "Random Pommes announce";
sequence = [
{
service = "media_player.play_media";
data = {
entity_id = "media_player.mpd";
media_content_type = "playlist";
media_content_id = "ansage";
};
}
{ delay.seconds = 5; }
{
service = "tts.google_say";
entity_id = "media_player.mpd";
data_template = {
message = random_pommes;
language = "de";
};
}
{ service = "notify.matrix_notify";
data_template.message = random_pommes;
}
];
}; };
condition = {
condition = "state";
entity_id = "binary_sensor.pommes"; # from multi/aramark.nix
state = "on";
};
action = [
{ service = "homeassistant.turn_on";
entity_id = [
"script.pommes_announce"
"script.seifenblasen_30s" # from script/multi_blink.nix
];
}
];
}
];
script = {
pommes_announce = {
alias = "Random Pommes announce";
sequence = [
{
service = "media_player.play_media";
data = {
entity_id = "media_player.mpd";
media_content_type = "playlist";
media_content_id = "ansage";
};
}
{ delay.seconds = 5; }
{
service = "tts.google_say";
entity_id = "media_player.mpd";
data_template = {
message = random_pommes;
language = "de";
};
}
{ service = "notify.matrix_notify";
data_template.message = random_pommes;
}
];
}; };
}; };
} }

View File

@ -8,58 +8,62 @@
# name: my_command # name: my_command
let let
mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team"; mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team";
in { in
matrix = {
services.home-assistant.config =
{ {
# secrets: matrix =
# homeserver, username, password {
homeserver = "https://ext01.citadel.team"; # secrets:
rooms = [ # homeserver, username, password
mom_room homeserver = "https://ext01.citadel.team";
rooms = [
mom_room
];
commands = [
{
# alternative: expression for regexp
word = "version";
name = "version";
}
{
word = "luftqualität";
name = "luftqualitaet";
}
]; ];
commands = [ } // (builtins.fromJSON (builtins.readFile
{ <secrets/hass/citadel-bot.json>));
# alternative: expression for regexp automation = [
word = "version"; {
name = "version"; alias = "React to !version";
} trigger = {
{ platform = "event";
word = "luftqualität"; event_type = "matrix_command";
name = "luftqualitaet"; event_data.command = "version";
} };
]; action = {
} // (builtins.fromJSON (builtins.readFile service = "notify.matrix_notify";
<secrets/hass/citadel-bot.json>)); data_template.message = "Running home-assistant {{states.sensor.current_version.state}}";
automation = [ };
{ }
alias = "React to !version"; {
trigger = { alias = "React to !luftqualität";
platform = "event"; trigger = {
event_type = "matrix_command"; platform = "event";
event_data.command = "version"; event_type = "matrix_command";
}; event_data.command = "luftqualitaet";
action = { };
service = "notify.matrix_notify"; action = {
data_template.message = "Running home-assistant {{states.sensor.current_version.state}}"; service = "notify.matrix_notify";
}; data_template.message = ''Temp: {{states.sensor.notizen_temperature.state_with_unit | replace (" ","")}}, Hum:{{states.sensor.notizen_humidity.state_with_unit | replace (" ","")}}, airquality:{{states.sensor.air_quality.state_with_unit}}'';
} };
{ }
alias = "React to !luftqualität";
trigger = {
platform = "event";
event_type = "matrix_command";
event_data.command = "luftqualitaet";
};
action = {
service = "notify.matrix_notify";
data_template.message = ''Temp: {{states.sensor.notizen_temperature.state_with_unit | replace (" ","")}}, Hum:{{states.sensor.notizen_humidity.state_with_unit | replace (" ","")}}, airquality:{{states.sensor.air_quality.state_with_unit}}'';
};
}
]; ];
notify = [{ notify = [{
name = "matrix_notify"; name = "matrix_notify";
platform = "matrix"; platform = "matrix";
default_room = mom_room; default_room = mom_room;
}]; }];
};
} }

View File

@ -38,52 +38,55 @@ let
"Jetzt nur noch kurz die Mail fertig schreiben und schon kann es los gehen.", "Jetzt nur noch kurz die Mail fertig schreiben und schon kann es los gehen.",
"Es ist 13 Uhr und die Mittagspause ist bald vorbei .... Kleiner Scherz, es ist erst 12:30, aber Ihr hättet auch nicht wirklich etwas verpasst.", "Es ist 13 Uhr und die Mittagspause ist bald vorbei .... Kleiner Scherz, es ist erst 12:30, aber Ihr hättet auch nicht wirklich etwas verpasst.",
"Hallo, es ist nun 12 Uhr 30! Dies entspricht der Essenszeit aller Büroinsassen. Bitte begebt euch zur Aramark Essensausgabe um euren menschlichen Bedürfnissen nachzukommen."] | random }}''; "Hallo, es ist nun 12 Uhr 30! Dies entspricht der Essenszeit aller Büroinsassen. Bitte begebt euch zur Aramark Essensausgabe um euren menschlichen Bedürfnissen nachzukommen."] | random }}'';
in { in
automation = [ {
{ alias = "Mittagessen"; services.home-assistant.config = {
trigger = { automation = [
platform = "time"; { alias = "Mittagessen";
at = "12:30:00"; trigger = {
platform = "time";
at = "12:30:00";
};
action = [
{ service = "homeassistant.turn_on";
entity_id = [
"script.mittagessen_announce"
"script.blitz_10s"
"script.mittagessenlicht"
];
}
];
}
];
script = {
mittagessenlicht = (flash_entity {
entity = "switch.bauarbeiterlampe";
alias = "Bauarbeiterlampe Mittagessenlicht";
delay = 1000;
count = 5;
});
mittagessen_announce = {
alias = "Random Mittagessen announce";
sequence = [
{
service = "media_player.play_media";
data = {
entity_id = "media_player.mpd";
media_content_type = "playlist";
media_content_id = "ansage";
};
}
{ delay.seconds = 5; }
{
service = "tts.google_say";
entity_id = "media_player.mpd";
data_template = {
message = random_mittagessen;
language = "de";
};
}
];
}; };
action = [
{ service = "homeassistant.turn_on";
entity_id = [
"script.mittagessen_announce"
"script.blitz_10s"
"script.mittagessenlicht"
];
}
];
}
];
script = {
mittagessenlicht = (flash_entity {
entity = "switch.bauarbeiterlampe";
alias = "Bauarbeiterlampe Mittagessenlicht";
delay = 1000;
count = 5;
});
mittagessen_announce = {
alias = "Random Mittagessen announce";
sequence = [
{
service = "media_player.play_media";
data = {
entity_id = "media_player.mpd";
media_content_type = "playlist";
media_content_id = "ansage";
};
}
{ delay.seconds = 5; }
{
service = "tts.google_say";
entity_id = "media_player.mpd";
data_template = {
message = random_mittagessen;
language = "de";
};
}
];
}; };
}; };
} }

View File

@ -1,72 +1,75 @@
[ {
{ name = "Thorsten"; services.home-assistant.config.person =
id = 1; [
device_trackers = [ { name = "Thorsten";
"device_tracker.thorsten_phone" id = 1;
#"device_tracker.thorsten_arbeitphone" device_trackers = [
]; "device_tracker.thorsten_phone"
} #"device_tracker.thorsten_arbeitphone"
{ name = "Felix"; ];
id = 2; }
device_trackers = [ { name = "Felix";
"device_tracker.felix_phone" id = 2;
"device_tracker.felix_laptop" device_trackers = [
]; "device_tracker.felix_phone"
} "device_tracker.felix_laptop"
{ name = "Ecki"; ];
id = 3; }
device_trackers = [ { name = "Ecki";
"device_tracker.ecki_phone" id = 3;
"device_tracker.ecki_tablet" device_trackers = [
]; "device_tracker.ecki_phone"
} "device_tracker.ecki_tablet"
{ name = "Daniel"; ];
id = 4; }
device_trackers = [ { name = "Daniel";
"device_tracker.daniel_phone" id = 4;
]; device_trackers = [
} "device_tracker.daniel_phone"
{ name = "Thierry"; ];
id = 5; }
device_trackers = [ { name = "Thierry";
"device_tracker.thierry_phone" id = 5;
]; device_trackers = [
} "device_tracker.thierry_phone"
{ name = "Frank"; ];
id = 6; }
device_trackers = [ { name = "Frank";
"device_tracker.frank_phone" id = 6;
]; device_trackers = [
} "device_tracker.frank_phone"
{ name = "Carsten"; ];
id = 7; }
device_trackers = [ { name = "Carsten";
"device_tracker.carsten_phone" id = 7;
]; device_trackers = [
} "device_tracker.carsten_phone"
{ name = "Emeka"; ];
id = 8; }
device_trackers = [ { name = "Emeka";
"device_tracker.emeka_phone" id = 8;
]; device_trackers = [
} "device_tracker.emeka_phone"
{ name = "Sabine"; ];
id = 9; }
device_trackers = [ { name = "Sabine";
"device_tracker.sabine_phone" id = 9;
]; device_trackers = [
} "device_tracker.sabine_phone"
{ name = "Tobias"; ];
id = 10; }
device_trackers = [ { name = "Tobias";
"device_tracker.tobias_phone" id = 10;
]; device_trackers = [
} "device_tracker.tobias_phone"
{ name = "Tancrede"; ];
id = 11; }
device_trackers = [ { name = "Tancrede";
"device_tracker.tancrede_phone" id = 11;
"device_tracker.tancrede_laptop" device_trackers = [
]; "device_tracker.tancrede_phone"
} "device_tracker.tancrede_laptop"
] ];
}
];
}

View File

@ -19,39 +19,42 @@ let
) count); ) count);
}; };
in { in {
buzz_red_led = (flash_entity { services.home-assistant.config.script =
entity = "light.redbutton_buzzer"; {
alias = "Red Button Buzz"; buzz_red_led = (flash_entity {
count = 4; entity = "light.redbutton_buzzer";
}); alias = "Red Button Buzz";
buzz_red_led_fast = (flash_entity { count = 4;
entity = "light.redbutton_buzzer"; });
delay = 250; buzz_red_led_fast = (flash_entity {
count = 2; entity = "light.redbutton_buzzer";
alias = "Red Button Buzz fast"; delay = 250;
}); count = 2;
blitz_10s = (flash_entity { alias = "Red Button Buzz fast";
entity = "switch.blitzdings"; });
delay = 10000; blitz_10s = (flash_entity {
count = 1; entity = "switch.blitzdings";
alias = "blitz for 10 seconds"; delay = 10000;
}); count = 1;
blasen_10s = (flash_entity { alias = "blitz for 10 seconds";
entity = "switch.frosch_blasen"; });
delay = 10000; blasen_10s = (flash_entity {
count = 1; entity = "switch.frosch_blasen";
alias = "blasen for 10 seconds"; delay = 10000;
}); count = 1;
blasen_30s = (flash_entity { alias = "blasen for 10 seconds";
entity = "switch.frosch_blasen"; });
delay = 30000; blasen_30s = (flash_entity {
count = 1; entity = "switch.frosch_blasen";
alias = "blasen for 30 seconds"; delay = 30000;
}); count = 1;
schlechteluft = (flash_entity { alias = "blasen for 30 seconds";
entity = "switch.bauarbeiterlampe"; });
alias = "Schlechte Luft Lampe 5 secs"; schlechteluft = (flash_entity {
delay = 5000; entity = "switch.bauarbeiterlampe";
count = 1; alias = "Schlechte Luft Lampe 5 secs";
}); delay = 5000;
count = 1;
});
};
} }

View File

@ -1,9 +1,12 @@
[ {
# coming from 2configs/stats/telegraf/ services.home-assistant.config.sensor =
{ platform = "mqtt"; [
name = "Air Quality"; # coming from 2configs/stats/telegraf/
state_topic = "/telegraf/wbob/airquality"; { platform = "mqtt";
value_template = "{{ value_json.fields.value }}"; name = "Air Quality";
unit_of_measurement = "VOC"; state_topic = "/telegraf/wbob/airquality";
} value_template = "{{ value_json.fields.value }}";
] unit_of_measurement = "VOC";
}
];
}

View File

@ -24,8 +24,10 @@ let
payload_available = "Online"; payload_available = "Online";
payload_not_available = "Offline"; payload_not_available = "Offline";
}; };
in in {
(espeasy_dht22 "easy1") ++ services.home-assistant.config.sensor =
(espeasy_dht22 "easy2") ++ [ (espeasy_dht22 "easy1") ++
(espeasy_ds18 "easy3" ) (espeasy_dht22 "easy2") ++ [
] (espeasy_ds18 "easy3" )
];
}

View File

@ -1,18 +0,0 @@
[
#{ platform = "influxdb";
# queries = [
# { name = "mean value of feinstaub P1";
# where = '' "node" = 'esp8266-1355142' '';
# measurement = "feinstaub";
# database = "telegraf";
# field = "P1";
# }
# { name = "mean value of feinstaub P2";
# where = '' "node" = 'esp8266-1355142' '';
# measurement = "feinstaub";
# database = "telegraf";
# field = "P2";
# }
# ];
#}
]

View File

@ -1,25 +1,29 @@
{lib,...}: [ {lib,...}:
{ platform = "darksky"; {
api_key = lib.removeSuffix "\n" services.home-assistant.config.sensor =
(builtins.readFile <secrets/hass/darksky.apikey>); [
language = "de"; { platform = "darksky";
monitored_conditions = [ api_key = lib.removeSuffix "\n"
"summary" "icon" (builtins.readFile <secrets/hass/darksky.apikey>);
"nearest_storm_distance" "precip_probability" language = "de";
"precip_intensity" monitored_conditions = [
"temperature" # "temperature_high" "temperature_low" "summary" "icon"
"apparent_temperature" "nearest_storm_distance" "precip_probability"
"hourly_summary" # next 24 hours text "precip_intensity"
"humidity" "temperature" # "temperature_high" "temperature_low"
"pressure" "apparent_temperature"
"uv_index" "hourly_summary" # next 24 hours text
]; "humidity"
units = "si" ; "pressure"
scan_interval = "00:30:00"; "uv_index"
} ];
{ platform = "luftdaten"; units = "si" ;
name = "Ditzingen"; scan_interval = "00:30:00";
sensorid = "5341"; }
monitored_conditions = [ "P1" "P2" ]; { platform = "luftdaten";
} name = "Ditzingen";
] sensorid = "5341";
monitored_conditions = [ "P1" "P2" ];
}
];
}

View File

@ -9,8 +9,11 @@ let
payload_not_available= "Offline"; payload_not_available= "Offline";
}; };
in in
{
services.home-assistant.config.sensor =
map tasmota_firmware [ map tasmota_firmware [
"plug" "plug2" "plug3" "plug4" "plug5" "plug" "plug2" "plug3" "plug4" "plug5"
"status1" "status2" "buslicht" "status1" "status2" "buslicht"
"rfbridge" "rfbridge"
] ];
}

View File

@ -8,10 +8,12 @@ let
payload_available= "Online"; payload_available= "Online";
payload_not_available= "Offline"; payload_not_available= "Offline";
}; };
in in {
[ services.home-assistant.config.switch =
(bridge "Nachtlicht A" "#414551" "#414554") [
(bridge "Nachtlicht B" "#415151" "#415154") (bridge "Nachtlicht A" "#414551" "#414554")
(bridge "Nachtlicht C" "#415451" "#415454") (bridge "Nachtlicht B" "#415151" "#415154")
(bridge "Nachtlicht D" "#41551F" "#415514") (bridge "Nachtlicht C" "#415451" "#415454")
] (bridge "Nachtlicht D" "#41551F" "#415514")
];
}

View File

@ -13,10 +13,13 @@ let
retain = false; retain = false;
qos = 1; qos = 1;
}; };
in [ in {
(tasmota_plug "Bauarbeiterlampe" "plug") services.home-assistant.config.switch =
(tasmota_plug "Blitzdings" "plug2") [
(tasmota_plug "Fernseher" "plug3") (tasmota_plug "Bauarbeiterlampe" "plug")
(tasmota_plug "Feuer" "plug4") (tasmota_plug "Blitzdings" "plug2")
(tasmota_plug "Blaulicht" "plug5") (tasmota_plug "Fernseher" "plug3")
] (tasmota_plug "Feuer" "plug4")
(tasmota_plug "Blaulicht" "plug5")
];
}