summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/2configs/ircd.nix4
-rw-r--r--krebs/3modules/default.nix2
-rw-r--r--krebs/3modules/solanum.nix (renamed from krebs/3modules/charybdis.nix)46
-rw-r--r--krebs/5pkgs/simple/solanum/bandb.patch12
-rw-r--r--krebs/5pkgs/simple/solanum/default.nix63
-rw-r--r--krebs/5pkgs/simple/solanum/dont-create-logdir.patch14
-rw-r--r--krebs/nixpkgs-unstable.json8
-rw-r--r--krebs/nixpkgs.json8
-rw-r--r--makefu/0tests/data/secrets/signal/messenger.nix6
-rw-r--r--makefu/1systems/gum/config.nix2
-rw-r--r--makefu/2configs/bgt/etherpad.euer.krebsco.de.nix11
-rw-r--r--makefu/2configs/bgt/social-to-irc.nix11
-rw-r--r--makefu/2configs/bgt/template.md1
-rw-r--r--makefu/2configs/bureautomation/default.nix4
-rw-r--r--makefu/2configs/home/ham/automation/fenster_auf.nix63
-rw-r--r--makefu/2configs/home/ham/automation/giesskanne.nix4
-rw-r--r--makefu/2configs/home/ham/automation/lichter_dimmen.nix135
-rw-r--r--makefu/2configs/home/ham/automation/light_buttons.nix83
-rw-r--r--makefu/2configs/home/ham/automation/pflanzen_giessen_erinnerung.nix39
-rw-r--r--makefu/2configs/home/ham/calendar/nextcloud.nix30
-rw-r--r--makefu/2configs/home/ham/default.nix21
-rw-r--r--makefu/2configs/home/ham/multi/kurzzeitwecker.nix11
-rw-r--r--makefu/2configs/home/ham/signal-rest/default.nix20
-rw-r--r--makefu/2configs/home/ham/signal-rest/hass.nix20
-rw-r--r--makefu/2configs/home/ham/signal-rest/pkg.nix25
-rw-r--r--makefu/2configs/home/ham/signal-rest/service.nix18
-rw-r--r--makefu/2configs/home/zigbee2mqtt/default.nix1
-rw-r--r--makefu/2configs/printer.nix30
-rw-r--r--makefu/2configs/systemdultras/ircbot.nix8
-rw-r--r--makefu/2configs/tools/extra-gui.nix1
-rw-r--r--makefu/5pkgs/awesomecfg/default.nix1
-rw-r--r--makefu/5pkgs/awesomecfg/full.cfg19
-rw-r--r--makefu/5pkgs/studio-link/default.nix4
33 files changed, 592 insertions, 133 deletions
diff --git a/krebs/2configs/ircd.nix b/krebs/2configs/ircd.nix
index 3ef2e7d2b..d4ac9e42a 100644
--- a/krebs/2configs/ircd.nix
+++ b/krebs/2configs/ircd.nix
@@ -5,9 +5,9 @@
6667 6669
];
- systemd.services.charybdis.serviceConfig.LimitNOFILE = 16384;
+ systemd.services.solanum.serviceConfig.LimitNOFILE = 16384;
- krebs.charybdis = {
+ krebs.solanum = {
enable = true;
motd = ''
hello
diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix
index 85d27459b..e75afad1d 100644
--- a/krebs/3modules/default.nix
+++ b/krebs/3modules/default.nix
@@ -17,7 +17,6 @@ let
./buildbot/slave.nix
./build.nix
./cachecache.nix
- ./charybdis.nix
./ci.nix
./current.nix
./dns.nix
@@ -52,6 +51,7 @@ let
./secret.nix
./setuid.nix
./shadow.nix
+ ./solanum.nix
./sync-containers.nix
./tinc.nix
./tinc_graphs.nix
diff --git a/krebs/3modules/charybdis.nix b/krebs/3modules/solanum.nix
index 038d79dd0..00aefce85 100644
--- a/krebs/3modules/charybdis.nix
+++ b/krebs/3modules/solanum.nix
@@ -2,10 +2,10 @@
let
inherit (lib) mkEnableOption mkIf mkOption singleton types;
- inherit (pkgs) coreutils charybdis;
- cfg = config.krebs.charybdis;
+ inherit (pkgs) coreutils solanum;
+ cfg = config.krebs.solanum;
- configFile = pkgs.writeText "charybdis.conf" ''
+ configFile = pkgs.writeText "solanum.conf" ''
${cfg.config}
'';
in
@@ -16,22 +16,22 @@ in
options = {
- krebs.charybdis = {
+ krebs.solanum = {
- enable = mkEnableOption "Charybdis IRC daemon";
+ enable = mkEnableOption "Solanum IRC daemon";
config = mkOption {
type = types.str;
description = ''
- Charybdis IRC daemon configuration file.
+ Solanum IRC daemon configuration file.
'';
};
statedir = mkOption {
- type = types.str;
- default = "/var/lib/charybdis";
+ type = types.path;
+ default = "/var/lib/solanum";
description = ''
- Location of the state directory of charybdis.
+ Location of the state directory of solanum.
'';
};
@@ -39,7 +39,7 @@ in
type = types.str;
default = "ircd";
description = ''
- Charybdis IRC daemon user.
+ Solanum IRC daemon user.
'';
};
@@ -47,7 +47,7 @@ in
type = types.str;
default = "ircd";
description = ''
- Charybdis IRC daemon group.
+ Solanum IRC daemon group.
'';
};
@@ -55,9 +55,9 @@ in
type = types.nullOr types.lines;
default = null;
description = ''
- Charybdis MOTD text.
+ Solanum MOTD text.
- Charybdis will read its MOTD from /etc/charybdis/ircd.motd .
+ Solanum will read its MOTD from /etc/solanum/ircd.motd .
If set, the value of this option will be written to this path.
'';
};
@@ -72,38 +72,36 @@ in
config = mkIf cfg.enable (lib.mkMerge [
{
users.users.${cfg.user} = {
- description = "Charybdis IRC daemon user";
+ description = "Solanum IRC daemon user";
uid = config.ids.uids.ircd;
group = cfg.group;
};
users.groups.${cfg.group} = {
- name = cfg.group;
gid = config.ids.gids.ircd;
};
- systemd.services.charybdis = {
- description = "Charybdis IRC daemon";
+ systemd.tmpfiles.rules = [
+ "d ${cfg.statedir} - ${cfg.user} ${cfg.group} - -"
+ ];
+
+ systemd.services.solanum = {
+ description = "Solanum IRC daemon";
wantedBy = [ "multi-user.target" ];
environment = {
BANDB_DBPATH = "${cfg.statedir}/ban.db";
};
serviceConfig = {
- ExecStart = "${charybdis}/bin/charybdis -foreground -logfile /dev/stdout -configfile ${configFile}";
+ ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile ${configFile} -pidfile ${cfg.statedir}/ircd.pid";
Group = cfg.group;
User = cfg.user;
- PermissionsStartOnly = true; # preStart needs to run with root permissions
};
- preStart = ''
- ${coreutils}/bin/mkdir -p ${cfg.statedir}
- ${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.statedir}
- '';
};
}
(mkIf (cfg.motd != null) {
- environment.etc."charybdis/ircd.motd".text = cfg.motd;
+ environment.etc."solanum/ircd.motd".text = cfg.motd;
})
]);
}
diff --git a/krebs/5pkgs/simple/solanum/bandb.patch b/krebs/5pkgs/simple/solanum/bandb.patch
new file mode 100644
index 000000000..7d204398b
--- /dev/null
+++ b/krebs/5pkgs/simple/solanum/bandb.patch
@@ -0,0 +1,12 @@
+diff --git a/ircd/bandbi.c b/ircd/bandbi.c
+index 29a3bfa2..16a40f17 100644
+--- a/ircd/bandbi.c
++++ b/ircd/bandbi.c
+@@ -83,7 +83,6 @@ start_bandb(void)
+ const char *suffix = "";
+ #endif
+
+- rb_setenv("BANDB_DBPATH", ircd_paths[IRCD_PATH_BANDB], 1);
+ if(bandb_path == NULL)
+ {
+ snprintf(fullpath, sizeof(fullpath), "%s%cbandb%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
diff --git a/krebs/5pkgs/simple/solanum/default.nix b/krebs/5pkgs/simple/solanum/default.nix
new file mode 100644
index 000000000..279cccbcc
--- /dev/null
+++ b/krebs/5pkgs/simple/solanum/default.nix
@@ -0,0 +1,63 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, bison
+, flex
+, openssl
+, sqlite
+, lksctp-tools
+}:
+
+stdenv.mkDerivation rec {
+ pname = "solanum";
+ version = "unstable-2021-04-27";
+
+ src = fetchFromGitHub {
+ owner = "solanum-ircd";
+ repo = pname;
+ rev = "3ff5a12e75662e9a642f2a4364797bd361eb0925";
+ sha256 = "14ywmfdv8cncbyg08y2qdis00kwg8lvhkcgj185is67smh0qf88f";
+ };
+
+ patches = [
+ ./dont-create-logdir.patch
+ ./bandb.patch # https://github.com/solanum-ircd/solanum/issues/156
+ ];
+
+ configureFlags = [
+ "--enable-epoll"
+ "--enable-ipv6"
+ "--enable-openssl=${openssl.dev}"
+ "--with-program-prefix=solanum-"
+ "--localstatedir=/var/lib"
+ "--with-rundir=/run"
+ "--with-logdir=/var/log"
+ ] ++ lib.optionals (stdenv.isLinux) [
+ "--enable-sctp=${lksctp-tools.out}/lib"
+ ];
+
+ nativeBuildInputs = [
+ autoreconfHook
+ bison
+ flex
+ pkg-config
+ ];
+
+ buildInputs = [
+ openssl
+ sqlite
+ ];
+
+ doCheck = !stdenv.isDarwin;
+
+ enableParallelBuilding = true;
+
+ meta = with lib; {
+ description = "An IRCd for unified networks";
+ homepage = "https://github.com/solanum-ircd/solanum";
+ license = licenses.gpl2Only;
+ maintainers = with maintainers; [ hexa ];
+ platforms = platforms.unix;
+ };
+}
diff --git a/krebs/5pkgs/simple/solanum/dont-create-logdir.patch b/krebs/5pkgs/simple/solanum/dont-create-logdir.patch
new file mode 100644
index 000000000..e348dd7b8
--- /dev/null
+++ b/krebs/5pkgs/simple/solanum/dont-create-logdir.patch
@@ -0,0 +1,14 @@
+diff --git a/Makefile.am b/Makefile.am
+index 19e7b396..21093521 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -35,9 +35,6 @@ include/serno.h:
+ echo '#define DATECODE 0UL' >>include/serno.h; \
+ fi
+
+-install-data-hook:
+- test -d ${DESTDIR}${logdir} || mkdir -p ${DESTDIR}${logdir}
+-
+ install-exec-hook:
+ rm -f ${DESTDIR}${libdir}/*.la
+ rm -f ${DESTDIR}${moduledir}/*.la
diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json
index 83ae57a6f..fe46ec022 100644
--- a/krebs/nixpkgs-unstable.json
+++ b/krebs/nixpkgs-unstable.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "39e6bf76474ce742eb027a88c4da6331f0a1526f",
- "date": "2021-05-04T23:07:42+02:00",
- "path": "/nix/store/9zbih9x2pfi782vv73v0vjxscmzyf4da-nixpkgs",
- "sha256": "1pxigbywdq4yf7smas6zq4vhakbkvm1vhj443qjikh77fc8hy17b",
+ "rev": "7a1fbc38a4b538450ac0d42aec8a3e513b4d723e",
+ "date": "2021-05-16T12:16:31+02:00",
+ "path": "/nix/store/iq2sy65gmwad2prm8lcdh6k5f7ywxci5-nixpkgs",
+ "sha256": "0jg8dilsw0gr4jfshkk3wd50gddd11hvd836fxkw43m6m47885p7",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json
index 1d1dee220..06b865cc8 100644
--- a/krebs/nixpkgs.json
+++ b/krebs/nixpkgs.json
@@ -1,9 +1,9 @@
{
"url": "https://github.com/NixOS/nixpkgs",
- "rev": "d90df566caff6ef84f7bfccc2a2c95496f221d62",
- "date": "2021-05-04T18:59:22-04:00",
- "path": "/nix/store/3jr3hwykb05r9m5g3phpx6f7k2956ny3-nixpkgs",
- "sha256": "0f1im9c83kyc465k5lsqyhb5saki3dgh5bb1gyyh7gmqlhyvqcax",
+ "rev": "33824cdf8e4fec30c5b9ddc91b18991c3c375227",
+ "date": "2021-05-18T19:08:44-04:00",
+ "path": "/nix/store/s3f1q2a5hn60jdnz8h66z7yahrmzifin-nixpkgs",
+ "sha256": "1sad0x998k3iid2vp57kv4skvf90yh4gbs61dv3p45c2qi3sql46",
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
diff --git a/makefu/0tests/data/secrets/signal/messenger.nix b/makefu/0tests/data/secrets/signal/messenger.nix
new file mode 100644
index 000000000..b43bb3897
--- /dev/null
+++ b/makefu/0tests/data/secrets/signal/messenger.nix
@@ -0,0 +1,6 @@
+{
+ number = "+1dotdotdot";
+ home = "group.ABCDE";
+ felix = "group.ABCDE";
+
+}
diff --git a/makefu/1systems/gum/config.nix b/makefu/1systems/gum/config.nix
index 862dfb53e..763d36841 100644
--- a/makefu/1systems/gum/config.nix
+++ b/makefu/1systems/gum/config.nix
@@ -160,7 +160,7 @@ in {
<stockholm/makefu/2configs/bgt/download.binaergewitter.de.nix>
<stockholm/makefu/2configs/bgt/hidden_service.nix>
<stockholm/makefu/2configs/bgt/backup.nix>
- <stockholm/makefu/2configs/bgt/social-to-irc.nix>
+ # <stockholm/makefu/2configs/bgt/social-to-irc.nix>
# <stockholm/makefu/2configs/logging/client.nix>
diff --git a/makefu/2configs/bgt/etherpad.euer.krebsco.de.nix b/makefu/2configs/bgt/etherpad.euer.krebsco.de.nix
index 48b947c58..cf5b22bae 100644
--- a/makefu/2configs/bgt/etherpad.euer.krebsco.de.nix
+++ b/makefu/2configs/bgt/etherpad.euer.krebsco.de.nix
@@ -30,8 +30,12 @@ in {
proxy_read_timeout 1799s;
'';
};
- docker-containers."etherpad-lite" = {
- image = "makefoo/bgt-etherpad:2020-05-02.6";
+ state = [ "/var/lib/docker/volumes/etherpad_data/_data/" ];
+ virtualisation.oci-containers.containers."etherpad-lite" = {
+ image = "makefoo/bgt-etherpad:2021-04-16.3"; # --build-arg ETHERPAD_PLUGINS="ep_markdown"
+ # ep_codepad does not work anymore
+
+ #image = "etherpad/etherpad:1.8.13";
ports = [ "127.0.0.1:${toString port}:9001" ];
volumes = [
"/var/src/secrets/etherpad/apikey:/opt/etherpad-lite/APIKEY.txt"
@@ -46,7 +50,10 @@ in {
#DB_PASS=mypassword
environment = {
# ADMIN_PASSWORD = "auf jeden fall nicht das echte admin passwort";
+ # LOGLEVEL = "DEBUG";
+
SUPPRESS_ERRORS_IN_PAD_TEXT = "true";
+ TRUST_PROXY = "true";
TITLE = "Binärgewitter Etherpad";
SKIN_NAME = "no-skin";
DEFAULT_PAD_TEXT = builtins.replaceStrings ["\n"] ["\\n"] (builtins.readFile ./template.md);
diff --git a/makefu/2configs/bgt/social-to-irc.nix b/makefu/2configs/bgt/social-to-irc.nix
index dc975c359..8e81f9b50 100644
--- a/makefu/2configs/bgt/social-to-irc.nix
+++ b/makefu/2configs/bgt/social-to-irc.nix
@@ -1,10 +1,17 @@
+{ pkgs, ... }:
{
- # systemd.services.brockman.environment."BROCKMAN_LOG_LEVEL" = "DEBUG";
+ systemd.services.brockman.environment."BROCKMAN_LOG_LEVEL" = "DEBUG";
+ systemd.services.restart-brockman = {
+ after = [ "brockman.service" ];
+ wantedBy = [ "multi-user.target" ];
+ startAt = "daily";
+ script = "${pkgs.systemd}/bin/systemctl try-restart brockman.service";
+ };
krebs.brockman = {
enable = true;
config = {
channel = "#binaergewitter";
- notifyErrors = false;
+ notifyErrors = false;
irc = {
host = "irc.freenode.net";
port = 6667;
diff --git a/makefu/2configs/bgt/template.md b/makefu/2configs/bgt/template.md
index d30cb49eb..af5de0697 100644
--- a/makefu/2configs/bgt/template.md
+++ b/makefu/2configs/bgt/template.md
@@ -21,6 +21,7 @@
## Vorschläge
### Backlog von Picks und Lesefoo aus der letzten Woche
+die Nachfolgenden 3 Striche sind sehr wichtig, bitte nicht löschen
---
## Blast from the Past
diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix
index aa13b62b7..669754caf 100644
--- a/makefu/2configs/bureautomation/default.nix
+++ b/makefu/2configs/bureautomation/default.nix
@@ -59,7 +59,7 @@ in {
extraPackages = p: [
# TODO: put somewhere else
(p.callPackage <stockholm/makefu/2configs/home/ham/deps/dwdwfsapi.nix> {})
- (p.callPackage <stockholm/makefu/2configs/home/ham/deps/pykodi.nix> {})
+ # (p.callPackage <stockholm/makefu/2configs/home/ham/deps/pykodi.nix> {})
p.APScheduler ];
};
autoExtraComponents = true;
@@ -147,7 +147,7 @@ in {
frontend = { };
http = {
# TODO: https://github.com/home-assistant/home-assistant/issues/16149
- base_url = "http://192.168.8.11:8123";
+ # base_url = "http://192.168.8.11:8123";
};
conversation = {};
history = {};
diff --git a/makefu/2configs/home/ham/automation/fenster_auf.nix b/makefu/2configs/home/ham/automation/fenster_auf.nix
index ccebd5b00..871f248b9 100644
--- a/makefu/2configs/home/ham/automation/fenster_auf.nix
+++ b/makefu/2configs/home/ham/automation/fenster_auf.nix
@@ -1,3 +1,8 @@
+{ lib, ... }:
+#uses:
+# notify.signal
+# binary_sensor.badezimmer_fenster_contact
+# binary_sensor.dusche_fenster_contact
let
min = 20;
fenster_offen = name: entity:
@@ -13,21 +18,57 @@ let
action =
[
{
- service = "notify.firetv_wohnzimmer";
+ service = "notify.signal_home";
data = {
- title = "${name} seit ${toString min} Minuten offen";
- message = "Bitte einmal checken ob das ok ist :)";
- data = {
- interrupt = 1;
- duration = 300;
- };
+ message= "${name} seit ${toString min} Minuten offen\nBitte einmal checken ob das ok ist :)";
};
}
+ {
+ service = "input_boolean.turn_on";
+ target.entity_id = "input_boolean.${lib.toLower name}_lang_offen";
+ }
+ ];
+ };
+ fenster_geschlossen_lang = name: entity:
+ { alias = "${name} wieder geschlossen";
+ trigger = [
+ {
+ platform = "state";
+ entity_id = entity;
+ to = "off";
+ }
+ ];
+ condition = [
+ { condition = "state";
+ entity_id = "input_boolean.${lib.toLower name}_lang_offen";
+ state = "on";
+ }
+ ];
+ action =
+ [
+ {
+ service = "notify.signal_home";
+ data = {
+ message= "${name} ist wieder geschlossen, Danke!";
+ };
+ }
+ {
+ service = "input_boolean.turn_off";
+ target.entity_id = "input_boolean.${lib.toLower name}_lang_offen";
+ }
];
};
in {
- services.home-assistant.config.automation = [
- (fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact")
- (fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact")
- ];
+ services.home-assistant.config = {
+ input_boolean = {
+ badezimmerfinester_lang_offen.name = "Badezimmer lange offen";
+ duschfenster_lang_offen.name = "Duschfenster lange offen";
+ };
+ automation = [
+ (fenster_geschlossen_lang "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact")
+ (fenster_geschlossen_lang "Duschfenster" "binary_sensor.badezimmer_fenster_contact")
+ (fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact")
+ (fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact")
+ ];
+ };
}
diff --git a/makefu/2configs/home/ham/automation/giesskanne.nix b/makefu/2configs/home/ham/automation/giesskanne.nix
index 4b0fb61dd..b11fd9d52 100644
--- a/makefu/2configs/home/ham/automation/giesskanne.nix
+++ b/makefu/2configs/home/ham/automation/giesskanne.nix
@@ -5,9 +5,9 @@ let
name = "chilicam";
camera = "camera.espcam_02";
light = "light.espcam_02_light";
- seconds = 60; # default shutoff to protect the LED from burning out
+ seconds = 90; # default shutoff to protect the LED from burning out
};
- seconds = 60;
+ seconds = 70; # time for giesskanne
pump = "switch.arbeitszimmer_giesskanne_relay";
# sensor = "sensor.statistics_for_sensor_crafting_brotbox_soil_moisture";
in
diff --git a/makefu/2configs/home/ham/automation/lichter_dimmen.nix b/makefu/2configs/home/ham/automation/lichter_dimmen.nix
new file mode 100644
index 000000000..4303cdfa5
--- /dev/null
+++ b/makefu/2configs/home/ham/automation/lichter_dimmen.nix
@@ -0,0 +1,135 @@
+# This module maps the RF433 Remote Control to zigbee and wifi lights
+let
+ rf_turn_off = code: light:
+ {
+ alias = "Turn off ${light} via rf code ${code}";
+ trigger = {
+ platform = "event";
+ event_type = "esphome.rf_code_received";
+ event_data.code = code;
+ };
+ action = {
+ service = "light.turn_off";
+ data.entity_id = light;
+ };
+ };
+ rf_turn_on = code: light:
+ {
+ alias = "Turn on ${light} via rf code ${code}";
+ trigger = {
+ platform = "event";
+ event_type = "esphome.rf_code_received";
+ event_data.code = code;
+ };
+ action = {
+ service = "light.turn_on";
+ data.entity_id = light;
+ };
+ };
+ rf_state = code: light: halfbright:
+ let
+ maxbright = 255;
+ transition = 0.2; # seconds
+ in
+ # this function implements a simple state machine based on the state and brightness of the light (light must support brightness
+ {
+ alias = "Cycle through states of ${light} via rf code ${code}";
+ trigger = {
+ platform = "event";
+ event_type = "esphome.rf_code_received";
+ event_data.code = code;
+ };
+ action = {
+ choose = [
+ {
+ # state 0: off to half
+ conditions = {
+ condition = "template";
+ value_template = ''{{ states("${light}") == "off" }}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_on";
+ data = {
+ entity_id = light;
+ brightness = halfbright;
+ };
+ }
+ ];
+ }
+ {
+ # state 1: half to full
+ conditions = {
+ condition = "template";
+ value_template = ''{{ states('${light}') == 'on' and ( ${toString (halfbright - 1)} <= state_attr("${light}","brightness") <= ${toString (halfbright + 1)})}}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_on";
+ data = {
+ entity_id = light;
+ brightness = maxbright;
+ };
+ }
+ ];
+ }
+ {
+ # state 2: full to off
+ conditions = {
+ condition = "template";
+ # TODO: it seems like the devices respond with brightness-1 , maybe off-by-one somewhere?
+ value_template = ''{{ states("${light}") == "on" and state_attr("${light}","brightness") >= ${toString (maxbright - 1)}}}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_off";
+ data = {
+ entity_id = light;
+ };
+ }
+ ];
+ }
+ ];
+ # default: on to off
+ # this works because state 0 checks for "state == off"
+ default = [{
+ service = "light.turn_off";
+ data = {
+ entity_id = light;
+ };
+ }];
+ };
+ }
+;
+ rf_toggle = code: light:
+ {
+ alias = "Toggle ${light} via rf code ${code}";
+ trigger = {
+ platform = "event";
+ event_type = "esphome.rf_code_received";
+ event_data.code = code;
+ };
+ action = {
+ service = "light.toggle";
+ data.entity_id = light;
+ };
+ };
+in
+{
+ services.home-assistant.config.automation = [
+ (rf_toggle "400551" "light.wohnzimmer_fernseher_led_strip") # A
+ (rf_state "401151" "light.wohnzimmer_stehlampe_osram" 128) # B
+ (rf_state "401451" "light.wohnzimmer_komode_osram" 128) # C
+ (rf_state "401511" "light.wohnzimmer_schrank_osram" 128) # D
+
+ # OFF Lane
+ (rf_turn_off "400554" "all") # A
+ (rf_toggle "401154" "light.wohnzimmer_fenster_lichterkette_licht") # B
+ (rf_toggle "401454" "light.wohnzimmer_fernsehwand_led") # C
+ # (rf_toggle "401514" "") # D
+ ];
+ # "400554" # A OFF
+ # "401154" # B OFF
+ # "401454" # C OFF
+ # "401514" # D OFF
+}
diff --git a/makefu/2configs/home/ham/automation/light_buttons.nix b/makefu/2configs/home/ham/automation/light_buttons.nix
index 32d134ecc..89caf1a41 100644
--- a/makefu/2configs/home/ham/automation/light_buttons.nix
+++ b/makefu/2configs/home/ham/automation/light_buttons.nix
@@ -1,22 +1,77 @@
-# light.wohnzimmerbeleuchtung
-# light.wohnzimmer_deko
-# light.arbeitszimmerbeleuchtung
-# light.arbeitszimmer_deko
-# light.schlafzimmerbeleuchtung
let
- toggle = light: btn:
+ btn_state = light: btn: halfbright:
+ let
+ maxbright = 255;
+ transition = 0.2; # seconds
+ in
+ # this function implements a simple state machine based on the state and brightness of the light (light must support brightness
{
- alias = "Toggle Light ${light} via ${btn}";
+ alias = "Cycle through states of ${light} via button ${btn}";
trigger = {
platform = "state";
entity_id = "sensor.${btn}_click";
to = "single";
};
action = {
- service = "light.toggle";
- data.entity_id = light;
- data.transition = 0;
+ choose = [
+ {
+ # state 0: off to half
+ conditions = {
+ condition = "template";
+ value_template = ''{{ states("${light}") == "off" }}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_on";
+ data = {
+ entity_id = light;
+ brightness = halfbright;
+ };
+ }
+ ];
+ }
+ {
+ # state 1: half to full
+ conditions = {
+ condition = "template";
+ value_template = ''{{ states('${light}') == 'on' and ( ${toString (halfbright - 1)} <= state_attr("${light}","brightness") <= ${toString (halfbright + 1)})}}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_on";
+ data = {
+ entity_id = light;
+ brightness = maxbright;
+ };
+ }
+ ];
+ }
+ {
+ # state 2: full to off
+ conditions = {
+ condition = "template";
+ # TODO: it seems like the devices respond with brightness-1 , maybe off-by-one somewhere?
+ value_template = ''{{ states("${light}") == "on" and state_attr("${light}","brightness") >= ${toString (maxbright - 1)}}}'';
+ };
+ sequence = [
+ {
+ service = "light.turn_off";
+ data = {
+ entity_id = light;
+ };
+ }
+ ];
+ }
+ ];
+ # default: on to off
+ # this works because state 0 checks for "state == off"
+ default = [{
+ service = "light.turn_off";
+ data = {