summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-06-02 23:35:17 +0200
committertv <tv@krebsco.de>2020-06-02 23:35:17 +0200
commit09c9f8f7fb04be39390b6f65966789c1bf6333e5 (patch)
treeb0cb0f718b40517b0645a38169e67b1088566f64 /lass
parent09e620c79b70e495e9651e8e5c1b160dd1b5fb8d (diff)
parent211e2ca6b9a1d8b4dd92071065b0b595123fe282 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'lass')
-rw-r--r--lass/1systems/icarus/config.nix11
-rw-r--r--lass/1systems/icarus/physical.nix9
-rw-r--r--lass/1systems/mors/config.nix11
-rw-r--r--lass/1systems/prism/config.nix32
-rw-r--r--lass/1systems/shodan/config.nix15
-rw-r--r--lass/1systems/uriel/config.nix1
-rw-r--r--lass/2configs/baseX.nix4
-rw-r--r--lass/2configs/blue.nix1
-rw-r--r--lass/2configs/exim-smarthost.nix2
-rw-r--r--lass/2configs/gg23.nix77
-rw-r--r--lass/2configs/hass/default.nix106
-rw-r--r--lass/2configs/hass/lib.nix263
-rw-r--r--lass/2configs/hass/rooms/bett.nix8
-rw-r--r--lass/2configs/hass/rooms/essen.nix9
-rw-r--r--lass/2configs/hass/rooms/nass.nix10
-rw-r--r--lass/2configs/hass/zigbee.nix151
-rw-r--r--lass/2configs/home-media.nix23
-rw-r--r--lass/2configs/network-manager.nix18
-rw-r--r--lass/2configs/ppp.nix32
-rw-r--r--lass/2configs/radio.nix77
-rw-r--r--lass/2configs/websites/lassulus.nix7
-rw-r--r--lass/3modules/default.nix2
-rw-r--r--lass/3modules/hass.nix34
-rw-r--r--lass/3modules/umts.nix112
-rw-r--r--lass/3modules/xjail.nix10
-rw-r--r--lass/5pkgs/custom/xmonad-lass/default.nix29
-rw-r--r--lass/5pkgs/emot-menu/default.nix3
-rw-r--r--lass/5pkgs/nm-dmenu/default.nix6
-rw-r--r--lass/5pkgs/review-mail-queue/default.nix39
29 files changed, 808 insertions, 294 deletions
diff --git a/lass/1systems/icarus/config.nix b/lass/1systems/icarus/config.nix
index 5e16052ad..8332e7c53 100644
--- a/lass/1systems/icarus/config.nix
+++ b/lass/1systems/icarus/config.nix
@@ -21,20 +21,15 @@ with import <stockholm/lib>;
#<stockholm/lass/2configs/prism-share.nix>
<stockholm/lass/2configs/ssh-cryptsetup.nix>
<stockholm/lass/2configs/network-manager.nix>
+ <stockholm/lass/2configs/home-media.nix>
];
- #media center
- users.users.media = {
- isNormalUser = true;
- uid = genid_uint31 "media";
- extraGroups = [ "video" "audio" ];
- };
+ krebs.build.host = config.krebs.hosts.icarus;
services.xserver.displayManager.lightdm.autoLogin = {
enable = true;
user = "media";
};
- krebs.build.host = config.krebs.hosts.icarus;
- programs.adb.enable = true;
+ environment.systemPackages = [ pkgs.chromium ];
}
diff --git a/lass/1systems/icarus/physical.nix b/lass/1systems/icarus/physical.nix
index 861bd8b0b..bd74c29f3 100644
--- a/lass/1systems/icarus/physical.nix
+++ b/lass/1systems/icarus/physical.nix
@@ -46,6 +46,15 @@
'';
services.thinkfan.enable = true;
+ services.thinkfan.levels = ''
+ (0, 0, 55)
+ (1, 48, 60)
+ (2, 50, 61)
+ (3, 52, 63)
+ (6, 60, 65)
+ (7, 80, 85)
+ (127, 90, 32767)
+ '';
services.logind.lidSwitch = "ignore";
services.logind.lidSwitchDocked = "ignore";
diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix
index fe0b6d85b..c1ceb0633 100644
--- a/lass/1systems/mors/config.nix
+++ b/lass/1systems/mors/config.nix
@@ -39,6 +39,7 @@ with import <stockholm/lib>;
<stockholm/lass/2configs/network-manager.nix>
<stockholm/lass/2configs/nfs-dl.nix>
#<stockholm/lass/2configs/hardening.nix>
+ <stockholm/lass/2configs/ppp.nix>
{
krebs.iptables.tables.filter.INPUT.rules = [
#risk of rain
@@ -77,16 +78,6 @@ with import <stockholm/lib>;
};
}
{
- lass.umts = {
- enable = true;
- modem = "/dev/serial/by-id/usb-Lenovo_F5521gw_2C7D8D7C35FC7040-if09";
- initstrings = ''
- Init1 = AT+CFUN=1
- Init2 = AT+CGDCONT=1,"IP","pinternet.interkom.de","",0,0
- '';
- };
- }
- {
services.nginx = {
enable = true;
virtualHosts.default = {
diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix
index c6e0400bf..f1f14e791 100644
--- a/lass/1systems/prism/config.nix
+++ b/lass/1systems/prism/config.nix
@@ -65,13 +65,6 @@ with import <stockholm/lib>;
config.krebs.users.makefu.pubkey
];
};
- users.users.nin = {
- uid = genid "nin";
- isNormalUser = true;
- openssh.authorizedKeys.keys = [
- config.krebs.users.nin.pubkey
- ];
- };
users.extraUsers.dritter = {
uid = genid_uint31 "dritter";
isNormalUser = true;
@@ -123,26 +116,6 @@ with import <stockholm/lib>;
localAddress = "10.233.2.2";
};
}
- {
- #onondaga
- systemd.services."container@onondaga".reloadIfChanged = mkForce false;
- containers.onondaga = {
- config = { ... }: {
- imports = [ <stockholm/lass/2configs/rebuild-on-boot.nix> ];
- environment.systemPackages = [ pkgs.git ];
- services.openssh.enable = true;
- users.users.root.openssh.authorizedKeys.keys = [
- config.krebs.users.lass.pubkey
- config.krebs.users.nin.pubkey
- ];
- };
- autoStart = true;
- enableTun = true;
- privateNetwork = true;
- hostAddress = "10.233.2.5";
- localAddress = "10.233.2.6";
- };
- }
<stockholm/lass/2configs/exim-smarthost.nix>
<stockholm/lass/2configs/ts3.nix>
<stockholm/lass/2configs/privoxy-retiolum.nix>
@@ -263,8 +236,6 @@ with import <stockholm/lib>;
}
{
users.users.download.openssh.authorizedKeys.keys = [
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDB0d0JA20Vqn7I4lCte6Ne2EOmLZyMJyS9yIKJYXNLjbLwkQ4AYoQKantPBkTxR75M09E7d3j5heuWnCjWH45TrfQfe1EOSSC3ppCI6C6aIVlaNs+KhAYZS0m2Y8WkKn+TT5JLEa8yybYVN/RlZPOilpj/1QgjU6CQK+eJ1k/kK+QFXcwN82GDVh5kbTVcKUNp2tiyxFA+z9LY0xFDg/JHif2ROpjJVLQBJ+YPuOXZN5LDnVcuyLWKThjxy5srQ8iDjoxBg7dwLHjby5Mv41K4W61Gq6xM53gDEgfXk4cQhJnmx7jA/pUnsn2ZQDeww3hcc7vRf8soogXXz2KC9maiq0M/svaATsa9Ul4hrKnqPZP9Q8ScSEAUX+VI+x54iWrnW0p/yqBiRAzwsczdPzaQroUFTBxrq8R/n5TFdSHRMX7fYNOeVMjhfNca/gtfw9dYBVquCvuqUuFiRc0I7yK44rrMjjVQRcAbw6F8O7+04qWCmaJ8MPlmApwu2c05VMv9hiJo5p6PnzterRSLCqF6rIdhSnuOwrUIt1s/V+EEZXHCwSaNLaQJnYL0H9YjaIuGz4c8kVzxw4c0B6nl+hqW5y5/B2cuHiumnlRIDKOIzlv8ufhh21iN7QpIsPizahPezGoT1XqvzeXfH4qryo8O4yTN/PWoA+f7o9POU7L6hQ== lhebendanz@nixos"
- config.krebs.users.palo.pubkey
];
}
{
@@ -382,6 +353,9 @@ with import <stockholm/lib>;
lass.pubkey
lass-android.pubkey
makefu.pubkey
+ palo.pubkey
+ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDB0d0JA20Vqn7I4lCte6Ne2EOmLZyMJyS9yIKJYXNLjbLwkQ4AYoQKantPBkTxR75M09E7d3j5heuWnCjWH45TrfQfe1EOSSC3ppCI6C6aIVlaNs+KhAYZS0m2Y8WkKn+TT5JLEa8yybYVN/RlZPOilpj/1QgjU6CQK+eJ1k/kK+QFXcwN82GDVh5kbTVcKUNp2tiyxFA+z9LY0xFDg/JHif2ROpjJVLQBJ+YPuOXZN5LDnVcuyLWKThjxy5srQ8iDjoxBg7dwLHjby5Mv41K4W61Gq6xM53gDEgfXk4cQhJnmx7jA/pUnsn2ZQDeww3hcc7vRf8soogXXz2KC9maiq0M/svaATsa9Ul4hrKnqPZP9Q8ScSEAUX+VI+x54iWrnW0p/yqBiRAzwsczdPzaQroUFTBxrq8R/n5TFdSHRMX7fYNOeVMjhfNca/gtfw9dYBVquCvuqUuFiRc0I7yK44rrMjjVQRcAbw6F8O7+04qWCmaJ8MPlmApwu2c05VMv9hiJo5p6PnzterRSLCqF6rIdhSnuOwrUIt1s/V+EEZXHCwSaNLaQJnYL0H9YjaIuGz4c8kVzxw4c0B6nl+hqW5y5/B2cuHiumnlRIDKOIzlv8ufhh21iN7QpIsPizahPezGoT1XqvzeXfH4qryo8O4yTN/PWoA+f7o9POU7L6hQ== lhebendanz@nixos"
+ "AAAAB3NzaC1yc2EAAAADAQABAAABgQC4ECL9NSCWqs4KVe+FF+2BPtl5Bv5aQPHqnXllCyiESZykwRKLx6/AbF5SbUAUMVZtp9oDSdp28m3BvVeWJ/q7hAbIxUtfd/jp+JBRZ8Kj6K5GzUO7Bhgl/o0A7xEjAeOKHiYuLjdPMcFUyl6Ah4ey/mcQYf6AdU0+hYUDeUlKe/YxxYD6202W0GJq2xGdIqs/TbopT9iaX+sv0wdXDVfFY72nFqOUwJW3u6O2viKKRugrz/eo50Eo3ts7pYz/FpDXExrUvV9Vu/bQ34pa8nKgF3/AKQHgmzljNQSVZKyAV8OY0UFonjBMXCBg2tXtwfnlzdx2SyuQVv55x+0AuRKsi85G2xLpXu1A3921pseBTW6Q6kbYK9eqxAay2c/kNbwNqFnO+nCvQ6Ier/hvGddOtItMu96IuU2E7mPN6WgvM8/3fjJRFWnZxFxqu/k7iH+yYT8qwRgdiSqZc76qvkYEuabdk2itstTRY0A3SpI3hFMZDw/7bxgMZtqpfyoRk5s= philip@shiki11:15 <Profpatsch> AAAAB3NzaC1yc2EAAAADAQABAAABgQC4ECL9NSCWqs4KVe+FF+2BPtl5Bv5aQPHqnXllCyiESZykwRKLx6/AbF5SbUAUMVZtp9oDSdp28m3BvVeWJ/q7hAbIxUtfd/jp+JBRZ8Kj6K5GzUO7Bhgl/o0A7xEjAeOKHiYuLjdPMcFUyl6Ah4ey/mcQYf6AdU0+hYUDeUlKe/YxxYD6202W0GJq2xGdIqs/TbopT9iaX+sv0wdXDVfFY72nFqOUwJW3u6O2viKKRugrz/eo50Eo3ts7pYz/FpDXExrUvV9Vu/bQ34pa8nKgF3/AKQHgmzljNQSVZKyAV8OY0UFonjBMXCBg2tXtwfnlzdx2SyuQVv55x+0AuRKsi85G2xLpXu1A3921pseBTW6Q6kbYK9eqxAay2c/kNbwNqFnO+nCvQ6Ier/hvGddOtItMu96IuU2E7mPN6WgvM8/3fjJRFWnZxFxqu/k7iH+yYT8qwRgdiSqZc76qvkYEuabdk2itstTRY0A3SpI3hFMZDw/7bxgMZtqpfyoRk5s= philip@shiki"
];
};
};
diff --git a/lass/1systems/shodan/config.nix b/lass/1systems/shodan/config.nix
index 9bb31191c..e41c9bd1e 100644
--- a/lass/1systems/shodan/config.nix
+++ b/lass/1systems/shodan/config.nix
@@ -19,23 +19,14 @@ with import <stockholm/lib>;
<stockholm/lass/2configs/ssh-cryptsetup.nix>
<stockholm/lass/2configs/nfs-dl.nix>
<stockholm/lass/2configs/gg23.nix>
+ <stockholm/lass/2configs/hass>
<stockholm/lass/2configs/br.nix>
+ <stockholm/lass/2configs/fetchWallpaper.nix>
+ <stockholm/lass/2configs/home-media.nix>
];
krebs.build.host = config.krebs.hosts.shodan;
- #media center
- users.users.media = {
- isNormalUser = true;
- uid = genid_uint31 "media";
- extraGroups = [ "video" "audio" ];
- };
-
- services.xserver.displayManager.lightdm.autoLogin = {
- enable = true;
- user = "media";
- };
-
services.logind.lidSwitch = "ignore";
services.logind.lidSwitchDocked = "ignore";
diff --git a/lass/1systems/uriel/config.nix b/lass/1systems/uriel/config.nix
index 3eddcfc52..b50dc63f5 100644
--- a/lass/1systems/uriel/config.nix
+++ b/lass/1systems/uriel/config.nix
@@ -12,6 +12,7 @@ with import <stockholm/lib>;
i18n.defaultLocale ="de_DE.UTF-8";
time.timeZone = "Europe/Berlin";
services.xserver.enable = true;
+ services.xserver.libinput.enable = false;
users.users.locke = {
uid = genid "locke";
home = "/home/locke";
diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix
index 52d694c46..1185be9d4 100644
--- a/lass/2configs/baseX.nix
+++ b/lass/2configs/baseX.nix
@@ -71,12 +71,14 @@ in {
gitAndTools.qgit
git-preview
gnome3.dconf
+ iodine
lm_sensors
ncdu
nix-index
nix-review
nmap
pavucontrol
+ ponymix
powertop
rxvt_unicode-with-plugins
sxiv
@@ -112,7 +114,7 @@ in {
xkbOptions = "caps:escape";
libinput.enable = true;
displayManager.lightdm.enable = true;
- windowManager.default = "xmonad";
+ displayManager.defaultSession = "none+xmonad";
windowManager.session = [{
name = "xmonad";
start = ''
diff --git a/lass/2configs/blue.nix b/lass/2configs/blue.nix
index aad8411b1..a4000cada 100644
--- a/lass/2configs/blue.nix
+++ b/lass/2configs/blue.nix
@@ -19,6 +19,7 @@ with (import <stockholm/lib>);
];
services.tor.enable = true;
+ services.tor.client.enable = true;
krebs.iptables.tables.filter.INPUT.rules = [
{ predicate = "-i retiolum -p udp --dport 60000:61000"; target = "ACCEPT";}
diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix
index 08a226e6d..82839beba 100644
--- a/lass/2configs/exim-smarthost.nix
+++ b/lass/2configs/exim-smarthost.nix
@@ -113,6 +113,8 @@
];
in {
+ environment.systemPackages = [ pkgs.review-mail-queue ];
+
krebs.exim-smarthost = {
enable = true;
dkim = [
diff --git a/lass/2configs/gg23.nix b/lass/2configs/gg23.nix
index b23494b28..3d4c1e306 100644
--- a/lass/2configs/gg23.nix
+++ b/lass/2configs/gg23.nix
@@ -20,12 +20,13 @@ with import <stockholm/lib>;
}
'';
machines = [
- { ethernetAddress = "c8:3d:d4:2c:40:ae"; hostName = "tv"; ipAddress = "10.42.0.3"; }
+ { ethernetAddress = "a8:a6:48:65:ce:4c"; hostName = "tv"; ipAddress = "10.42.0.3"; }
{ ethernetAddress = "3c:2a:f4:22:28:37"; hostName = "drucker"; ipAddress = "10.42.0.4"; }
- { ethernetAddress = "80:7d:3a:67:b7:01"; hostName = "s20-bett"; ipAddress = "10.42.0.10"; }
+ { ethernetAddress = "80:7d:3a:67:b7:01"; hostName = "s20-tv"; ipAddress = "10.42.0.10"; }
{ ethernetAddress = "80:7d:3a:68:04:f0"; hostName = "s20-drucker"; ipAddress = "10.42.0.11"; }
- { ethernetAddress = "80:7d:3a:68:11:a5"; hostName = "s20-kueche"; ipAddress = "10.42.0.12"; }
+ { ethernetAddress = "80:7d:3a:68:11:a5"; hostName = "s20-wasch"; ipAddress = "10.42.0.12"; }
{ ethernetAddress = "80:7d:3a:67:bb:69"; hostName = "s20-stereo"; ipAddress = "10.42.0.13"; }
+ { ethernetAddress = "ec:b5:fa:07:78:16"; hostName = "hue-bridge"; ipAddress = "10.42.0.21"; }
{ ethernetAddress = "80:8d:b7:c5:80:dc"; hostName = "arubaAP"; ipAddress = "10.42.0.99"; }
];
};
@@ -45,9 +46,6 @@ with import <stockholm/lib>;
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
krebs.iptables.tables.filter.INPUT.rules = [
- { predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass
- { predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass
- { predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
{ predicate = "-i int0 -p udp --dport 53"; target = "ACCEPT"; } # dns
];
krebs.iptables.tables.filter.FORWARD.rules = [
@@ -62,72 +60,5 @@ with import <stockholm/lib>;
krebs.iptables.tables.nat.POSTROUTING.rules = [
{ v6 = false; predicate = "-s 10.42.0.0/24 ! -d 10.42.0.0/24"; target = "MASQUERADE"; }
];
-
- services.home-assistant = let
- tasmota_s20 = name: topic: {
- platform = "mqtt";
- inherit name;
- state_topic = "stat/${topic}/POWER";
- command_topic = "cmnd/${topic}/POWER";
- payload_on = "ON";
- payload_off = "OFF";
- };
- in {
- enable = true;
- package = pkgs.home-assistant.override {
- #extraComponents = [
- # (pkgs.fetchgit {
- # url = "https://github.com/marcschumacher/dwd_pollen";
- # rev = "0.1";
- # sha256 = "12vldwsds27c9l15ffc6svk9mj17jhypcz736pvpmpqbsymllz2p";
- # })
- #];
- };
- config = {
- homeassistant = {
- name = "Home"; time_zone = "Europe/Berlin";
- latitude = "48.7687";
- longitude = "9.2478";
- elevation = 247;
- };
- sun.elevation = 66;
- discovery = {};
- frontend = { };
- mqtt = {
- broker = "localhost";
- port = 1883;
- client_id = "home-assistant";
- username = "gg23";
- password = "gg23-mqtt";
- keepalive = 60;
- protocol = 3.1;
- };
- sensor = [
- ];
- switch = [
- (tasmota_s20 "Drucker Strom" "drucker")
- (tasmota_s20 "Bett Licht" "bett")
- (tasmota_s20 "Kueche Licht" "kueche")
- ];
- device_tracker = [
- {
- platform = "luci";
- }
- ];
- };
- };
-
- services.mosquitto = {
- enable = true;
- host = "0.0.0.0";
- allowAnonymous = false;
- checkPasswords = true;
- users.gg23 = {
- password = "gg23-mqtt";
- acl = [ "topic readwrite #" ];
- };
- };
- environment.systemPackages = [ pkgs.mosquitto ];
-
}
diff --git a/lass/2configs/hass/default.nix b/lass/2configs/hass/default.nix
new file mode 100644
index 000000000..639ba3d3f
--- /dev/null
+++ b/lass/2configs/hass/default.nix
@@ -0,0 +1,106 @@
+{ config, lib, pkgs, ... }:
+with import ./lib.nix { inherit lib; };
+
+{
+ imports = [
+ ./zigbee.nix
+ ./rooms/bett.nix
+ ./rooms/essen.nix
+ ./rooms/nass.nix
+ ];
+
+ krebs.iptables.tables.filter.INPUT.rules = [
+ { predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
+ { predicate = "-i docker0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
+ { predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass
+ { predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass
+ ];
+
+ services.home-assistant = {
+ enable = true;
+ package = pkgs.home-assistant.override {
+ # extraComponents = [ "hue" ];
+ };
+ configWritable = true;
+ };
+
+ lass.hass.config = let
+ tasmota_s20 = name: topic: {
+ platform = "mqtt";
+ inherit name;
+ state_topic = "stat/${topic}/POWER";
+ command_topic = "cmnd/${topic}/POWER";
+ payload_on = "ON";
+ payload_off = "OFF";
+ };
+ in {
+ homeassistant = {
+ name = "Home";
+ time_zone = "Europe/Berlin";
+ latitude = "52.46187";
+ longitude = "13.41489";
+ elevation = 90;
+ unit_system = "metric";
+ customize = friendly_names;
+ };
+ config = {};
+ sun.elevation = 66;
+ discovery = {};
+ frontend = {};
+ mqtt = {
+ broker = "localhost";
+ port = 1883;
+ client_id = "home-assistant";
+ username = "gg23";
+ password = "gg23-mqtt";
+ keepalive = 60;
+ protocol = 3.1;
+
+ discovery = true;
+ birth_message = {
+ topic = "/hass/status";
+ payload = "online";
+ };
+ will_message = {
+ topic = "/hass/status";
+ payload = "offline";
+ };
+ };
+ sensor = [
+ {
+ platform = "dwd_weather_warnings";
+ region_name = "Berlin";
+ }
+ ];
+ switch = [
+ (tasmota_s20 "TV" "tv")
+ (tasmota_s20 "Drucker Strom" "drucker")
+ (tasmota_s20 "Waschmaschine" "wasch")
+ (tasmota_s20 "Stereo Anlage" "stereo")
+ ];
+ mobile_app = {};
+ hue = {};
+ weather = [
+ {
+ platform = "openweathermap";
+ api_key = "xxx"; # TODO put into secrets
+ }
+ ];
+ system_health = {};
+ history = {};
+ shopping_list = {};
+ };
+
+ services.mosquitto = {
+ enable = true;
+ host = "0.0.0.0";
+ allowAnonymous = false;
+ checkPasswords = true;
+ users.gg23 = {
+ password = "gg23-mqtt";
+ acl = [ "topic readwrite #" ];
+ };
+ };
+
+ environment.systemPackages = [ pkgs.mosquitto ];
+}
diff --git a/lass/2configs/hass/lib.nix b/lass/2configs/hass/lib.nix
new file mode 100644
index 000000000..555cfae28
--- /dev/null
+++ b/lass/2configs/hass/lib.nix
@@ -0,0 +1,263 @@
+{ lib, ... }:
+rec {
+ lights = {
+ bett = "0x0017880106ed3bd8";
+ essen = "0x0017880108327622";
+ arbeit = "0x0017880106ee2865";
+ nass = "0x00178801082e9f2f";
+ };
+
+ switches = {
+ dimmer = {
+ bett = "0x00178801086ac38c";
+ essen = "0x00178801086ad1fb";
+ nass = "0x00178801086ac373";
+ };
+ };
+
+ sensors = {
+ movement = {
+ essen = "0x0017880106f772f2";
+ nass = "0x0017880106f77f30";
+ };
+ };
+
+ friendly_names =
+ lib.mapAttrs' (n: v: lib.nameValuePair "light.${v}_light" { friendly_name = "l.${n}"; }) lights //
+ lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "s.${n}_up"; }) switches.dimmer //
+ lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "i.${n}_up"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "l.${n}_up"; }) lights //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "s.${n}_link"; }) switches.dimmer //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "i.${n}_link"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "l.${n}_link"; }) lights //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_battery" { friendly_name = "s.${n}_bat"; }) switches.dimmer //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_battery" { friendly_name = "i.${n}_bat"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_action" { friendly_name = "s.${n}_act"; }) switches.dimmer //
+ lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_occupancy" { friendly_name = "i.${n}_move"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_occupancy" { friendly_name = "i.${n}_move"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_temperature" { friendly_name = "i.${n}_heat"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_temperature" { friendly_name = "i.${n}_heat"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_illuminance" { friendly_name = "i.${n}_lux"; }) sensors.movement //
+ lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_illuminance" { friendly_name = "i.${n}_lux"; }) sensors.movement //
+ {};
+
+ detect_movement = sensor: light: delay:
+ let
+ id = "${sensor}_${light}";
+ sensor_ = "binary_sensor.${sensor}_occupancy";
+ light_ = "light.${light}_light";
+ in {
+ input_boolean."${id}" = {
+ };
+ timer."${id}" = {
+ duration = delay;
+ };
+ automation = [
+ # {
+ # alias = "debug detect_movement";
+ # trigger = {
+ # platform = "state";
+ # entity_id = sensor_;
+ # };
+ # action = [
+ # {
+ # service = "system_log.write";
+ # data_template = {
+ # message = "XXXXXXXXXXXXXXXXXXXXXX {{ states('input_boolean.${sensor}_${light}_triggered') == 'on' }}";
+ # #message = "XXXXXXXXXXXXXXXXXXXXXX {{ state_attr('trigger.to_state.state', 'illuminance') }}";
+ # };
+ # }
+ # ];
+ # }
+ {
+ alias = "movement reset timer ${id}";
+ hide_entity = true;
+ trigger = {
+ platform = "state";
+ entity_id = sensor_;
+ from = "off";
+ to = "on";
+ };
+ action = [
+ {
+ service = "timer.cancel";
+ data_template.entity_id = "timer.${id}";
+ }
+ ];
+ }
+ {
+ alias = "movement on ${id}";
+ # hide_entity = true;
+ trigger = {
+ platform = "state";
+ entity_id = "binary_sensor.${sensor}_occupancy";
+ from = "off";
+ to = "on";
+ };
+ condition = {
+ condition = "and";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.to_state.attributes.illuminance < 13000 }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ states('${light_}') == 'off' }}";
+ }
+ ];
+ };
+ action = [
+ {
+ service = "light.turn_on";
+ data_template = {
+ entity_id = light_;
+ brightness = "100";
+ };
+ }
+ { delay = "0:00:02"; }
+ {
+ service = "input_boolean.turn_on";
+ data_template.entity_id = "input_boolean.${id}";
+ }
+ ];
+ }
+ {
+ alias = "movement off ${id}";
+ hide_entity = true;
+ trigger = {
+ platform = "state";
+ entity_id = sensor_;
+ from = "on";
+ to = "off";
+ };
+ condition = {
+ condition = "template";
+ value_template = "{{ states('input_boolean.${id}') == 'on' }}";
+ };
+ action = [
+ {
+ service = "timer.start";
+ entity_id = "timer.${id}";
+ }
+ ];
+ }
+ {
+ alias = "movement override ${id}";
+ hide_entity = true;
+ trigger = {
+ platform = "state";
+ entity_id = light_;
+ };
+ action = [
+ {
+ service = "input_boolean.turn_off";
+ data_template.entity_id = "input_boolean.${id}";
+ }
+ {
+ service = "system_log.write";
+ data_template = {
+ message = "XXXXXXXXXXXXXXXXXXXXXX {{ trigger }}";
+ };
+ }
+ ];
+ }
+ {
+ alias = "movement expired ${id}";
+ hide_entity = true;
+ trigger = {
+ platform = "event";
+ event_type = "timer.finished";
+ event_data.entity_id = "timer.${id}";
+ };
+ action = [
+ {
+ service = "light.turn_off";
+ data_template = {
+ entity_id = light_;
+ };
+ }
+ {
+ service = "input_boolean.turn_off";
+ data_template.entity_id = "input_boolean.${id}";
+ }
+ ];
+ }
+ ];
+ };
+
+ lightswitch = switch: light: {
+ automation = [
+ {
+ alias = "lightswitch ${switch} turn on light ${light}";
+ hide_entity = "true";
+ trigger = {
+ platform = "mqtt";
+ topic = "zigbee/${switch}";
+ };
+ condition = {
+ condition = "or";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'on-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'up-press' }}";
+ }
+ {
+ condition = "and";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'down-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.brightness > 30 }}";
+ }
+ ];
+ }
+ ];
+ };
+ action = [
+ {
+ service = "light.turn_on";
+ data_template = {
+ entity_id = "light.${light}_light";
+ brightness = "{{ trigger.payload_json.brightness }}";
+ };
+ }
+ ];
+ }
+ {
+ alias = "lightswitch ${switch} turn off light ${light}";
+ hide_entity = "true";
+ trigger = {
+ platform = "mqtt";
+ topic = "zigbee/${switch}";
+ };
+ condition = {
+ condition = "or";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'off-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.brightness < 30 }}";
+ }
+ ];
+ };
+ action = {
+ service = "light.turn_off";
+ data_template = {
+ entity_id = "light.${light}_light";
+ };
+ };
+ }
+ ];
+ };
+}
diff --git a/lass/2configs/hass/rooms/bett.nix b/lass/2configs/hass/rooms/bett.nix
new file mode 100644
index 000000000..b5da9221c
--- /dev/null
+++ b/lass/2configs/hass/rooms/bett.nix
@@ -0,0 +1,8 @@
+{ lib, ... }:
+with import ../lib.nix { inherit lib; };
+
+{
+ lass.hass.config = lib.mkMerge [
+ (lightswitch switches.dimmer.bett lights.bett)
+ ];
+}
diff --git a/lass/2configs/hass/rooms/essen.