summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/2configs/shack/glados/automation/hass-restart.nix3
-rw-r--r--krebs/2configs/shack/glados/automation/shack-startup.nix82
-rw-r--r--krebs/2configs/shack/glados/default.nix24
-rw-r--r--krebs/2configs/shack/glados/lib/default.nix60
-rw-r--r--krebs/2configs/shack/glados/multi/schlechte_luft.nix12
-rw-r--r--krebs/2configs/shack/glados/sensors/sensemap.nix6
-rw-r--r--krebs/2configs/shack/muellshack.nix5
-rw-r--r--krebs/3modules/makefu/default.nix7
-rw-r--r--krebs/3modules/makefu/sshd/omo.pub2
-rw-r--r--makefu/1systems/omo/config.nix39
-rw-r--r--makefu/2configs/default.nix5
-rw-r--r--makefu/2configs/ham/default.nix225
-rw-r--r--makefu/2configs/ham/google-muell.nix (renamed from makefu/2configs/homeautomation/google-muell.nix)0
-rw-r--r--makefu/2configs/ham/lib/default.nix318
-rw-r--r--makefu/2configs/ham/mqtt.nix (renamed from makefu/2configs/homeautomation/mqtt.nix)0
-rw-r--r--makefu/2configs/ham/multi/timer.nix123
-rw-r--r--makefu/2configs/ham/multi/zigbee2mqtt.nix165
-rw-r--r--makefu/2configs/ham/sensor/outside.nix26
-rw-r--r--makefu/2configs/homeautomation/default.nix305
-rw-r--r--makefu/2configs/stats/arafetch.nix4
-rw-r--r--makefu/2configs/stats/external/aralast.nix5
-rw-r--r--makefu/5pkgs/pico2wave/default.nix51
22 files changed, 1069 insertions, 398 deletions
diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix
index e87354978..1b380204d 100644
--- a/krebs/2configs/shack/glados/automation/hass-restart.nix
+++ b/krebs/2configs/shack/glados/automation/hass-restart.nix
@@ -6,12 +6,13 @@
platform = "homeassistant";
event = "start";
};
+ # trigger good/bad air
action = [
{ service = "light.turn_on";
data = {
entity_id = "light.fablab_led";
effect = "Rainbow";
- color_name = "yellow";
+ color_name = "purple";
};
}
];
diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix
new file mode 100644
index 000000000..10051d60a
--- /dev/null
+++ b/krebs/2configs/shack/glados/automation/shack-startup.nix
@@ -0,0 +1,82 @@
+# needs:
+# binary_sensor.portal_lock
+# sensor.keyholder
+# media_player.lounge
+let
+ glados = import ../lib;
+in
+[
+ {
+ alias = "Greet new keyholder for key exchange";
+ initial_state = true;
+ trigger = {
+ platform = "state";
+ entity_id = "sensor.keyholder";
+ };
+ condition = {
+ condition = "template";
+ value_template = "{{ trigger.from_state.state != 'No Keyholder' }}";
+ };
+ #action = glados.say.lounge "Danke {{trigger.to_state.state}} für das Übernehmen des Keys von {{trigger.from_state.state}}";
+ action = [];
+ }
+
+ {
+ alias = "Start Music on portal lock on";
+ # TODO: use "power" trigger
+ trigger = {
+ platform = "state";
+ entity_id = "binary_sensor.portal_lock";
+ to = "on";
+ for.seconds = 30;
+ };
+ condition = {
+ condition = "and";
+ conditions =
+ [
+ { # only start if a keyholder opened the door and if the lounge mpd is currently not playing anything
+ condition = "template";
+ value_template = "{{ state('sensor.keyholder') != 'No Keyholder' }}";
+ }
+ {
+ condition = "state";
+ entity_id = "media_player.lounge";
+ state = "idle";
+ }
+ ];
+ };
+ action = [
+ {
+ service = "media_player.volume_set";
+ data = {
+ entity_id = "media_player.lounge";
+ volume_level = 1.0;
+ };
+ }
+ {
+ service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.lounge";
+ media_content_type = "playlist";
+ media_content_id = "ansage";
+ };
+ }
+ { delay.seconds = 8; }
+ {
+ service = "media_player.volume_set";
+ data = {
+ entity_id = "media_player.lounge";
+ volume_level = 0.6;
+ };
+ }
+ {
+ service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.lounge";
+ media_content_type = "playlist";
+ media_content_id = "lassulus superradio";
+ };
+ }
+ ];
+ }
+]
diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix
index e48a54551..7abc55af1 100644
--- a/krebs/2configs/shack/glados/default.nix
+++ b/krebs/2configs/shack/glados/default.nix
@@ -93,8 +93,13 @@ in {
light = badair.light;
media_player = [
{ platform = "mpd";
+ name = "lounge";
host = "lounge.mpd.shack";
}
+ { platform = "mpd";
+ name = "kiosk";
+ host = "lounge.kiosk.shack";
+ }
];
sensor =
@@ -102,6 +107,7 @@ in {
++ (import ./sensors/power.nix)
++ shackopen.sensor
++ badair.sensor;
+ airquality = (import ./sensors/sensemap.nix );
binary_sensor = shackopen.binary_sensor;
@@ -117,19 +123,27 @@ in {
#conversation = {};
history = {};
logbook = {};
+ logger = {
+ default = "info";
+ };
recorder = {};
tts = [
{ platform = "google_translate";
+ service_name = "say";
language = "de";
+ cache = true;
+ time_memory = 57600;
+ }
+ { platform = "picotts";
+ language = "de-DE";
+ service_name = "pico";
}
- #{ platform = "picotts";
- # language = "de-DE";
- #}
];
sun = {};
- automation = wasser.automation
- ++ badair.automation
+ automation = wasser.automation
+ ++ badair.automation
+ ++ (import ./automation/shack-startup.nix)
++ (import ./automation/hass-restart.nix);
device_tracker = [];
diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix
index 6737af842..eb0528a06 100644
--- a/krebs/2configs/shack/glados/lib/default.nix
+++ b/krebs/2configs/shack/glados/lib/default.nix
@@ -2,6 +2,50 @@ let
prefix = "glados";
in
{
+
+ say = let
+ # returns a list of actions to be performed on an mpd to say something
+ tts = { message, entity }:
+ [
+ {
+ service = "media_player.turn_on";
+ data.entity_id = "media_player.${entity}";
+ }
+ { service = "media_player.play_media";
+ data = {
+ entity_id = "media_player.${entity}";
+ media_content_type = "playlist";
+ media_content_id = "ansage";
+ };
+ }
+ {
+ service = "media_player.turn_on";
+ data.entity_id = "media_player.${entity}";
+ }
+ { delay.seconds = 8; }
+ { service = "tts.say";
+ entity_id = "media_player.${entity}";
+ data_template = {
+ inherit message;
+ language = "de";
+ };
+ }
+ ];
+ in
+ {
+ lounge = message: tts {
+ inherit message;
+ entity = "lounge";
+ };
+ herrenklo = message: tts {
+ inherit message;
+ entity = "herrenklo";
+ };
+ kiosk = message: tts {
+ inherit message;
+ entity = "kiosk";
+ };
+ };
esphome =
{
temp = {host, topic ? "temperature" }:
@@ -75,6 +119,22 @@ in
state_topic = "${prefix}/${host}/sensor/${topic}/state";
availability_topic = "${prefix}/${host}/status";
};
+ ip = {host, name ? "${host} IP", topic ? "ip_address" }:
+ {
+ platform = "mqtt";
+ inherit name;
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "dB";
+ icon = "mdi:wifi";
+ inherit name;
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
switch = {host, name ? "${host} Button", topic ? "btn" }:
# host: ampel
# name: Button 1
diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix
index 9cd2c56f4..c02287d56 100644
--- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix
+++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix
@@ -12,9 +12,21 @@ in
(glados.esphome.led { name = "Fablab LED Part D"; host = "fablab_led"; topic = "D";})
];
sensor = [
+ (glados.esphome.ip { host = "fablab_feinstaub";})
+ (glados.esphome.wifi { host = "fablab_feinstaub";})
(glados.esphome.temp { host = "fablab_feinstaub";})
(glados.esphome.dust_25m { host = "fablab_feinstaub";})
(glados.esphome.dust_100m { host = "fablab_feinstaub";})
+
+ (glados.esphome.ip { host = "fablab_led";})
+ (glados.esphome.wifi { host = "fablab_led";})
+
+ (glados.esphome.ip { host = "rz_feinstaub";})
+ (glados.esphome.wifi { host = "rz_feinstaub";})
+ (glados.esphome.temp { host = "rz_feinstaub";})
+ (glados.esphome.hum { host = "rz_feinstaub";})
+ (glados.esphome.dust_25m { host = "rz_feinstaub";})
+ (glados.esphome.dust_100m { host = "rz_feinstaub";})
];
automation =
[
diff --git a/krebs/2configs/shack/glados/sensors/sensemap.nix b/krebs/2configs/shack/glados/sensors/sensemap.nix
new file mode 100644
index 000000000..dff29c3c4
--- /dev/null
+++ b/krebs/2configs/shack/glados/sensors/sensemap.nix
@@ -0,0 +1,6 @@
+[
+ {
+ platform = "opensensemap";
+ station_id = "56a0de932cb6e1e41040a68b";
+ }
+]
diff --git a/krebs/2configs/shack/muellshack.nix b/krebs/2configs/shack/muellshack.nix
index c67d8f523..e894b9394 100644
--- a/krebs/2configs/shack/muellshack.nix
+++ b/krebs/2configs/shack/muellshack.nix
@@ -4,8 +4,9 @@ let
pkg = pkgs.callPackage (
pkgs.fetchgit {
url = "https://git.shackspace.de/rz/muellshack";
- rev = "c3d1f70325e5b90f280c5be60110e14f4de653ae";
- sha256 = "1dd4kqwdr4v413rmkvmyjzzvw8id9747nifp96pg0c2cy6bhzj24";
+ rev = "dc80cf1edaa3d86ec2bebae8596ad1d4c4e3650a";
+ sha256 = "1yipr66zhrg5m20pf3rzvgvvl78an6ddkq6zc45rxb2r0i7ipkyh";
+
}) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; };
home = "/var/lib/muellshack";
port = "8081";
diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix
index dcfee59b3..56d313528 100644
--- a/krebs/3modules/makefu/default.nix
+++ b/krebs/3modules/makefu/default.nix
@@ -164,12 +164,14 @@ in {
ci = true;
extraZones = {
"krebsco.de" = ''
+ bookmark.euer IN A ${nets.internet.ip4.addr}
boot IN A ${nets.internet.ip4.addr}
boot.euer IN A ${nets.internet.ip4.addr}
cache.euer IN A ${nets.internet.ip4.addr}
cache.gum IN A ${nets.internet.ip4.addr}
cgit.euer IN A ${nets.internet.ip4.addr}
dl.euer IN A ${nets.internet.ip4.addr}
+ dns.euer IN A ${nets.internet.ip4.addr}
dockerhub IN A ${nets.internet.ip4.addr}
euer IN A ${nets.internet.ip4.addr}
euer IN MX 1 aspmx.l.google.com.
@@ -178,7 +180,9 @@ in {
gold IN A ${nets.internet.ip4.addr}
graph IN A ${nets.internet.ip4.addr}
gum IN A ${nets.internet.ip4.addr}
+ io IN NS gum.krebsco.de.
iso.euer IN A ${nets.internet.ip4.addr}
+ mediengewitter IN CNAME over.dose.io.
mon.euer IN A ${nets.internet.ip4.addr}
netdata.euer IN A ${nets.internet.ip4.addr}
nixos.unstable IN CNAME krebscode.github.io.
@@ -189,9 +193,6 @@ in {
wg.euer IN A ${nets.internet.ip4.addr}
wiki.euer IN A ${nets.internet.ip4.addr}
wikisearch IN A ${nets.internet.ip4.addr}
- bookmark.euer IN A ${nets.internet.ip4.addr}
- io IN NS gum.krebsco.de.
- mediengewitter IN CNAME over.dose.io.
'';
};
cores = 8;
diff --git a/krebs/3modules/makefu/sshd/omo.pub b/krebs/3modules/makefu/sshd/omo.pub
index 63bbbc709..5b9435414 100644
--- a/krebs/3modules/makefu/sshd/omo.pub
+++ b/krebs/3modules/makefu/sshd/omo.pub
@@ -1 +1 @@
-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTBGboU/P00yYiwYje53G0oqDFWmcSJ+hIpMsl4f/HH
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIujMZ3ZFxKpWeB/cjfKfYRr77+VRZk0Eik+92t03NoA
diff --git a/makefu/1systems/omo/config.nix b/makefu/1systems/omo/config.nix
index 9b9b91a6f..d00d61fdc 100644
--- a/makefu/1systems/omo/config.nix
+++ b/makefu/1systems/omo/config.nix
@@ -57,7 +57,7 @@ in {
<stockholm/makefu/2configs/stats/telegraf>
# <stockholm/makefu/2configs/stats/telegraf/europastats.nix>
<stockholm/makefu/2configs/stats/telegraf/hamstats.nix>
- <stockholm/makefu/2configs/stats/arafetch.nix>
+ # <stockholm/makefu/2configs/stats/arafetch.nix>
# services
{
@@ -71,14 +71,9 @@ in {
<stockholm/makefu/2configs/virtualisation/docker.nix>
<stockholm/makefu/2configs/bluetooth-mpd.nix>
- {
- # Risikoübernahme
- nixpkgs.config.permittedInsecurePackages = [
- "homeassistant-0.77.2"
- ];
- }
- <stockholm/makefu/2configs/homeautomation>
- <stockholm/makefu/2configs/homeautomation/google-muell.nix>
+ <stockholm/makefu/2configs/ham>
+ <stockholm/makefu/2configs/ham/google-muell.nix>
+ <stockholm/makefu/2configs/ham/zigbee2mqtt>
{
makefu.ps3netsrv = {
enable = true;
@@ -120,7 +115,7 @@ in {
gid = (import <stockholm/lib>).genid "share";
members = [ "makefu" "misa" ];
};
- networking.firewall.trustedInterfaces = [ primaryInterface ];
+ networking.firewall.trustedInterfaces = [ primaryInterface "docker0" ];
@@ -141,18 +136,18 @@ in {
sed-plugin
random-emoji ];
};
- krebs.Reaktor.reaktor-bgt = {
- nickname = "Reaktor|bgt";
- workdir = "/var/lib/Reaktor/bgt";
- channels = [ "#binaergewitter" ];
- plugins = with pkgs.ReaktorPlugins;
- [ titlebot
- # stockholm-issue
- nixos-version
- shack-correct
- sed-plugin
- random-emoji ];
- };
+ #krebs.Reaktor.reaktor-bgt = {
+ # nickname = "Reaktor|bgt";
+ # workdir = "/var/lib/Reaktor/bgt";
+ # channels = [ "#binaergewitter" ];
+ # plugins = with pkgs.ReaktorPlugins;
+ # [ titlebot
+ # # stockholm-issue
+ # nixos-version
+ # shack-correct
+ # sed-plugin
+ # random-emoji ];
+ #};
krebs.build.host = config.krebs.hosts.omo;
}
diff --git a/makefu/2configs/default.nix b/makefu/2configs/default.nix
index 5faf3ce93..0cbb5efe7 100644
--- a/makefu/2configs/default.nix
+++ b/makefu/2configs/default.nix
@@ -28,6 +28,7 @@ with import <stockholm/lib>;
openssh.authorizedKeys.keys = [ config.krebs.users.makefu.pubkey ];
};
};
+ nix.trustedUsers = [ config.krebs.build.user.name ];
boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
@@ -41,8 +42,6 @@ with import <stockholm/lib>;
};
-
-
boot.tmpOnTmpfs = true;
systemd.tmpfiles.rules = [
"d /tmp 1777 root root - -"
@@ -61,7 +60,7 @@ with import <stockholm/lib>;
environment.shellAliases = {
# TODO: see .aliases
lsl = "ls -lAtr";
- dmesg = "journalctl -kb | cat";
+ dmesg = "dmesg -L --reltime";
psg = "ps -ef | grep";
nmap = "nmap -oN $HOME/loot/scan-`date +\%s`.nmap -oX $HOME/loot/scan-`date +%s`.xml";
grep = "grep --color=auto";
diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix
new file mode 100644
index 000000000..56acc2d07
--- /dev/null
+++ b/makefu/2configs/ham/default.nix
@@ -0,0 +1,225 @@
+{ pkgs, lib, config, ... }:
+
+# Ideas:
+## wake-on-lan server
+##
+let
+ hlib = (import ./lib);
+ prefix = hlib.prefix;
+ tasmota = hlib.tasmota;
+ firetv = "192.168.1.183";
+ kodi-host = firetv;
+ hassdir = "/var/lib/hass";
+ zigbee = import ./multi/zigbee2mqtt.nix;
+# switch
+# automation
+# binary_sensor
+# sensor
+# input_select
+# timer
+in {
+ imports = [
+ ./mqtt.nix
+ ];
+
+ services.home-assistant = {
+ config = {
+ input_select = zigbee.input_select; # dict
+ timer = zigbee.timer; # dict
+ homeassistant = {
+ name = "Home"; time_zone = "Europe/Berlin";
+ latitude = "48.7687";
+ longitude = "9.2478";
+ elevation = 247;
+ };
+ #discovery = {};
+ conversation = {};
+ history = {};
+ logbook = {};
+ tts = [
+ { platform = "google_translate";
+ language = "de";
+ time_memory = 57600;
+ service_name = "google_say";
+ }
+ ];
+
+ telegram_bot = [
+ # secrets file: {
+ # "platform": "broadcast",
+ # "api_key": "", # talk to Botfather /newbot
+ # "allowed_chat_ids": [ ID ] # curl -X GET # https://api.telegram.org/bot<YOUR_API_TOKEN>/getUpdates
+ #}
+ (builtins.fromJSON
+ (builtins.readFile <secrets/hass/telegram-bot.json>))
+ ];
+ notify = [
+ {
+ platform = "kodi";
+ name = "wohnzimmer";
+ host = kodi-host;
+ }
+ {
+ platform = "telegram";
+ name = "telegrambot";
+ chat_id = builtins.elemAt
+ (builtins.fromJSON (builtins.readFile
+ <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0;
+ }
+ ];
+ sun.elevation = 247;
+ recorder = {};
+ media_player = [
+ { platform = "kodi";
+ host = firetv;
+ }
+ { platform = "firetv";
+ name = "FireTV Stick";
+ host = firetv;
+ adbkey = <secrets/hass/adbkey>;
+ }
+ ];
+ mqtt = {
+ broker = "localhost";
+ port = 1883;
+ client_id = "home-assistant";
+ username = "hass";
+ password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/hass>);
+ keepalive = 60;
+ protocol = 3.1;
+ birth_message = {
+ topic = "${prefix}/hass/tele/LWT";
+ payload = "Online";
+ qos = 1;
+ retain = true;
+ };
+ will_message = {
+ topic = "${prefix}/hass/tele/LWT";
+ payload = "Offline";
+ qos = 1;
+ retain = true;
+ };
+ };
+ binary_sensor = [
+ (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";})
+ ] ++ zigbee.binary_sensor;
+ sensor = [
+ # broken
+ #{ platform = "speedtest";
+ # monitored_conditions = [ "ping" "download" "upload" ];
+ #}
+ # https://www.home-assistant.io/cookbook/automation_for_rainy_days/
+ ]
+ ++ ((import ./sensor/outside.nix) {inherit lib;})
+ ++ zigbee.sensor
+ ++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";})
+ ++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; });
+ frontend = { };
+ group =
+ { default_view =
+ { view = "yes";
+ entities = [
+ "group.flur"
+ "group.schlafzimmer"
+ "group.draussen"
+ "group.wohnzimmer"
+ "group.arbeitszimmer"
+ ];
+ };
+ flur = [
+ "light.flurlicht"
+ "binary_sensor.flur_bewegung"
+ "automation.dunkel_bei_sonnenuntergang"
+ "automation.hell_bei_sonnenaufgang"
+ ];
+ wohnzimmer = [
+ "media_player.kodi"
+ "media_player.firetv_stick"
+ ];
+ draussen = [
+ "sensor.dark_sky_temperature"
+ "sensor.dark_sky_hourly_summary"
+ "sensor.dark_sky_humidity"
+ "sensor.dark_sky_pressure"
+ "sensor.muehlhausen_pm10"
+ "sensor.muehlhausen_pm25"
+ ];
+ schlafzimmer = [
+ "sensor.schlafzimmer_temperatur"
+ "sensor.schlafzimmer_luftdruck"
+ "sensor.schlafzimmer_luftfeuchtigkeit"
+ "switch.lichterkette_schlafzimmer"
+ ];
+ arbeitszimmer = [
+ "switch.strom_staubsauger"
+ "sensor.arbeitszimmer_temperatur"
+ "sensor.arbeitszimmer_luftfeuchtigkeit"
+ ];
+ };
+ http = { };
+ switch = [
+ (tasmota.plug { name = "Lichterkette Schlafzimmer"; host = "schlafzimmer";})
+ (tasmota.plug { name = "Strom Staubsauger"; host = "arbeitszimmer"; } )
+ ] ++ zigbee.switch;
+ light = [ (tasmota.rgb { name = "Flurlicht"; host = "flurlicht";} ) ];
+ automation = [
+ { alias = "Dunkel bei Sonnenuntergang";
+ trigger = {
+ platform = "sun";
+ event = "sunset";
+ # offset: "-00:45:00"
+ };
+ action = [
+ {
+ service= "light.turn_on";
+ data = {
+ entity_id= "light.flurlicht";
+ # rgb_color = [ 0,0,0 ]; <-- TODO default color
+ brightness_pct = 15;
+ };
+ }
+ {
+ service= "light.turn_off";
+ entity_id= "light.flurlicht";
+ }
+ ];
+ }
+ { alias = "Hell bei Sonnenaufgang";
+ trigger = {
+ platform = "sun";
+ event = "sunrise";
+ # offset: "-00:00:00"
+ };
+ action = [
+ {
+ service= "light.turn_on";
+ data = {
+ entity_id= "light.flurlicht";
+ brightness_pct = 85;
+ };
+ }
+ {
+ service= "light.turn_off";
+ entity_id= "light.flurlicht";
+ }
+ ];
+ }
+ #{ alias = "Staubsauger Strom aus nach 6h";
+ # trigger = {
+ # platform = "state";
+ # entity_id = "switch.strom_staubsauger";
+ # to = "on";
+ # for.hours = 6;
+ # };
+ # action = {
+ # service= "homeassistant.turn_off";
+ # entity_id= "switch.strom_staubsauger";
+ # };
+ #}
+ ] ++ zigbee.automation;
+ };
+ enable = true;
+ configDir = hassdir;
+ };
+
+}
diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/ham/google-muell.nix
index c81eae201..c81eae201 100644
--- a/makefu/2configs/homeautomation/google-muell.nix
+++ b/makefu/2configs/ham/google-muell.nix
diff --git a/makefu/2configs/ham/lib/default.nix b/makefu/2configs/ham/lib/default.nix
new file mode 100644
index 000000000..8bc544310
--- /dev/null
+++ b/makefu/2configs/ham/lib/default.nix
@@ -0,0 +1,318 @@
+let
+ prefix = "/ham";
+in
+{
+ inherit prefix;
+ say = let
+ # returns a list of actions to be performed on an mpd to say something
+ tts = { message, entity }:
+ [
+ {
+ service = "media_player.turn_on";
+ data.entity_id = entity;
+ }
+ {
+ service = "media_player.play_media";
+ data = {
+ entity_id = entity;
+ media_content_type = "playlist";
+ media_content_id = "ansage";
+ };
+ }
+ {
+ service = "media_player.turn_on";
+ data.entity_id = entity;
+ }
+ { delay.seconds = 8; }
+ {
+ service = "tts.say";
+ entity_id = entity;
+ data_template = {
+ inherit message;
+ language = "de";
+ };
+ }
+ ];
+ in
+ {
+ firetv = message: tts {
+ inherit message;
+ entity = "firetv";
+ };
+ };
+ zigbee = let
+ prefix = "/ham/zigbee";
+ in
+ {
+ inherit prefix;
+ state = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} connectivity";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ payload_on = true;
+ payload_off = false;
+ value_template = "{{ value_json.state }}";
+ device_class = "connectivity";
+ };
+ battery = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} battery";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ unit_of_measurement = "%";
+ device_class = "battery";
+ value_template = "{{ value_json.battery }}";
+ };
+ linkquality = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} linkquality";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ unit_of_measurement = "-";
+ value_template = "{{ value_json.linkquality }}";
+ };
+ temperature = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} temperature";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ unit_of_measurement = "°C";
+ device_class = "temperature";
+ value_template = "{{ value_json.temperature }}";
+ };
+ humidity = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} humidity";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ unit_of_measurement = "%";
+ device_class = "humidity";
+ value_template = "{{ value_json.humidity }}";
+ };
+ pressure = name: {
+ platform = "mqtt";
+ state_topic = "${prefix}/${name}";
+ name = "zigbee ${name} pressure";
+ availability_topic = "${prefix}/bridge/state";
+ unit_of_measurement = "hPa";
+ device_class = "pressure";
+ value_template = "{{ value_json.pressure }}" ;
+ };
+ click = name:
+ {
+ platform = "mqtt";
+ name = "zigbee ${name} click";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ icon = "mdi:toggle-switch";
+ value_template = "{{ value_json.click }}";
+ };
+ contact = name: {
+ platform = "mqtt";
+ name = "zigbee ${name} contact";
+ state_topic = "${prefix}/${name}";
+ availability_topic = "${prefix}/bridge/state";
+ payload_on = false;
+ payload_off = true;
+ value_template = "{{ value_json.contact }}";
+ device_class = "door";
+ };
+ };
+ esphome =
+ {
+ temp = {host, topic ? "temperature" }:
+ {
+ platform = "mqtt";
+ name = "${host} Temperature";
+ device_class = "temperature";
+ unit_of_measurement = "°C";
+ icon = "mdi:thermometer";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+ hum = {host, topic ? "humidity" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "%";
+ icon = "mdi:water-percent";
+ device_class = "humidity";
+ name = "${host} Humidity";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+ # copied from "homeassistant/light/fablab_led/led_ring/config"
+ led = {host, topic ? "led", name ? host}:
+ { # name: fablab_led
+ # topic: led_ring
+ platform = "mqtt";
+ inherit name;
+ schema = "json";
+ brightness = true;
+ rgb = true;
+ effect = true;
+ effect_list = [ # TODO: may be different
+ "Random"
+ "Strobe"
+ "Rainbow"
+ "Color Wipe"
+ "Scan"
+ "Twinkle"
+ "Fireworks"
+ "Addressable Flicker"
+ "None"
+ ];
+ state_topic = "${prefix}/${host}/light/${topic}/state";
+ command_topic = "${prefix}/${host}/light/${topic}/command";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ qos = 1;
+ };
+ # Feinstaub
+