summaryrefslogtreecommitdiffstats
path: root/makefu/2configs
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs')
-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
11 files changed, 863 insertions, 313 deletions
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
+ dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "µg/m³";
+ icon = "mdi:chemical-weapon";
+ inherit name;
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "µg/m³";
+ icon = "mdi:chemical-weapon";
+ inherit name;
+ 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
+ # topic: btn1
+ {
+ inherit name;
+ platform = "mqtt";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ command_topic = "${prefix}/${host}/switch/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ };
+ tasmota =
+ {
+ plug = {host, name ? host, topic ? host}:
+ {
+ platform = "mqtt";
+ inherit name;
+ state_topic = "sonoff/stat/${topic}/POWER1";
+ command_topic = "sonoff/cmnd/${topic}/POWER1";
+ availability_topic = "sonoff/tele/${topic}/LWT";
+ payload_on= "ON";
+ payload_off= "OFF";
+ payload_available= "Online";
+ payload_not_available= "Offline";
+ retain = false;
+ qos = 1;
+ };
+ am2301 = { name, host, topic?host }:
+ [ { platform = "mqtt";
+ name = "${name} Temperatur";
+ state_topic = "${prefix}/${topic}/tele/SENSOR";
+ value_template = "{{ value_json.AM2301.Temperature }}";
+ unit_of_measurement = "°C";
+ }
+ { platform = "mqtt";
+ name = "${name} Luftfeuchtigkeit";
+ state_topic = "${prefix}/${topic}/tele/SENSOR";
+ value_template = "{{ value_json.AM2301.Humidity }}";
+ unit_of_measurement = "%";
+ }
+ ];
+ bme = { name, host, topic?host }:
+ [ { platform = "mqtt";
+ name = "${name} Temperatur";
+ state_topic = "${prefix}/${topic}/tele/SENSOR";
+ value_template = "{{ value_json.BME280.Temperature }}";
+ unit_of_measurement = "°C";
+ }
+ { platform = "mqtt";
+ name = "${name} Luftfeuchtigkeit";
+ state_topic = "${prefix}/${topic}/tele/SENSOR";
+ value_template = "{{ value_json.BME280.Humidity }}";
+ unit_of_measurement = "%";
+ }
+ { platform = "mqtt";
+ name = "${name} Luftdruck";
+ state_topic = "${prefix}/${topic}/tele/SENSOR";
+ value_template = "{{ value_json.BME280.Pressure }}";
+ unit_of_measurement = "hPa";
+ }
+ ];
+ rgb = { name, host, topic?host }:
+ { platform = "mqtt";
+ inherit name;
+ retain = false;
+ qos = 1;
+ optimistic = false;
+ # state
+ # TODO: currently broken, will not use the custom state topic
+ #state_topic = "${prefix}/${topic}/stat/POWER";
+ state_topic = "${prefix}/${topic}/stat/POWER";
+ command_topic = "${prefix}/${topic}/cmnd/POWER";
+ availability_topic = "${prefix}/${topic}/tele/LWT";
+ payload_on= "ON";
+ payload_off= "OFF";
+ payload_available= "Online";
+ payload_not_available= "Offline";
+ # brightness
+ brightness_state_topic = "${prefix}/${topic}/stat/Dimmer";
+ brightness_command_topic = "${prefix}/${topic}/cmnd/Dimmer";
+ brightness_value_template = "{{ value_json.Dimmer }}";
+ brightness_scale = 100;
+ # color
+ rgb_state_topic = "${prefix}/${topic}/stat/Color";
+ rgb_command_topic = "${prefix}/${topic}/cmnd/MEM1"; # use enabled rule
+ rgb_command_mode = "hex";
+ rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
+ # effects
+ effect_state_topic = "${prefix}/${topic}/stat/Scheme";
+ effect_command_topic = "${prefix}/${topic}/cmnd/Scheme";
+ effect_value_template = "{{ value_json.Scheme }}";
+ effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ];
+};
+ motion = { name, host, topic?host }:
+ { platform = "mqtt";
+ device_class = "motion";
+ inherit name;
+ # TODO: currently broken, will not use the custom state topic
+ state_topic = "${prefix}/${topic}/stat/POWER";
+ payload_on = "ON";
+ payload_off = "OFF";
+ availability_topic = "${prefix}/${topic}/tele/LWT";
+ payload_available = "Online";
+ payload_not_available = "Offline";
+ };
+ };
+}
diff --git a/makefu/2configs/homeautomation/mqtt.nix b/makefu/2configs/ham/mqtt.nix
index cd1c328d7..cd1c328d7 100644
--- a/makefu/2configs/homeautomation/mqtt.nix
+++ b/makefu/2configs/ham/mqtt.nix
diff --git a/makefu/2configs/ham/multi/timer.nix b/makefu/2configs/ham/multi/timer.nix
new file mode 100644
index 000000000..eafb7841d
--- /dev/null
+++ b/makefu/2configs/ham/multi/timer.nix
@@ -0,0 +1,123 @@
+# Provides:
+# timer
+# automation
+# script
+
+# Needs:
+# sensor.zigbee_btn1_click
+# notify.telegrambot
+let
+ button = "sensor.zigbee_btn1_click";
+in {
+ timer.kurzzeitwecker =
+ {
+ name = "Zigbee Kurzzeitwecker";
+ duration = 300;
+ };
+ script.add_5_minutes_to_kurzzeitwecker =
+ {
+ alias = "Add 5 minutes to kurzzeitwecker";
+ sequence = [
+ { service = "timer.pause";
+ entity_id = "timer.kurzzeitwecker";
+ }
+ { service = "timer.start";
+ data_template = {
+ entity_id = "timer.kurzzeitwecker";
+ duration = ''
+ {% set r = state_attr('timer.wecker', 'remaining') ~ '-0000' %}
+ {% set t = strptime(r, '%H:%M:%S.%f%z') %}
+ {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }}
+ '';
+ };
+ }
+ ];
+ };
+ automation =
+ [
+ {
+ alias = "Start Timer 5min";
+ trigger = {
+ platform = "state";
+ entity_id = button;
+ to = "single";
+ };
+ condition =
+ { condition = "state";
+ entity_id = "timer.kurzzeitwecker";
+ state = "idle";
+ };
+
+ action = [
+ { service = "timer.start";
+ entity_id = "timer.kurzzeitwecker";
+ duration = "00:05:00";
+ }
+ {
+ service = "notify.telegrambot";
+ data = {
+ title = "Timer gestartet";
+ message = "Timer auf 5 minuten gestellt";
+ };
+ }
+ ];
+ }
+ {
+ alias = "Start Timer 10min";
+ trigger = {
+ platform = "state";
+ entity_id = button;
+ to = "double";
+ };
+ condition =
+ {
+ condition = "state";
+ entity_id = "timer.kurzzeitwecker";
+ state = "idle";
+ };
+ action =
+ [
+ {
+ service = "timer.start";
+ entity_id = "timer.kurzzeitwecker";
+ duration = "00:10:00";
+ }
+ {
+ service = "notify.telegrambot";
+ data = {
+ title = "Timer gestartet";
+ message = "Timer auf 10 minuten gestellt";
+ };
+ }
+ ];
+ }
+ {
+ alias = "Stop timer on triple click";
+ trigger =
+ {
+ platform = "state";
+ entity_id = button;
+ to = "triple";
+ };
+ condition =
+ {
+ condition = "state";
+ entity_id = "timer.kurzzeitwecker";
+ state = "active";
+ };
+
+ action = [
+ {
+ service = "timer.stop";
+ entity_id = "timer.kurzzeitwecker";
+ }
+ {
+ service = "notify.telegrambot";
+ data = {
+ title = "Timer gestoppt";
+ };
+ }
+ ];
+ }
+ ];
+}
diff --git a/makefu/2configs/ham/multi/zigbee2mqtt.nix b/makefu/2configs/ham/multi/zigbee2mqtt.nix
new file mode 100644
index 000000000..ba81b1298
--- /dev/null
+++ b/makefu/2configs/ham/multi/zigbee2mqtt.nix
@@ -0,0 +1,165 @@
+# provides:
+# switch
+# automation
+# binary_sensor
+# sensor
+# input_select
+# timer
+let
+ inherit (import ../lib) zigbee;
+ prefix = zigbee.prefix;
+ xiaomi_btn = name: [
+ (zigbee.battery name)
+ (zigbee.linkquality name)
+ (zigbee.click name)
+ ];
+ xiaomi_temp = name: [
+ (zigbee.battery name)
+ (zigbee.linkquality name)
+ (zigbee.temperature name)
+ (zigbee.humidity name)
+ (zigbee.pressure name)
+ ];
+ xiaomi_contact = name: [
+ (zigbee.battery name)
+ (zigbee.linkquality name)
+ (zigbee.contact name)
+ ];
+ router_link = name: [
+ (zigbee.linkquality name)
+ ];
+ router_bin = name: [
+ (zigbee.state name)
+ ];
+in {
+ sensor =
+ (xiaomi_btn "btn1")
+ ++ (xiaomi_btn "btn2")
+ ++ (xiaomi_btn "btn3")
+
+ ++ (xiaomi_temp "temp1")
+ ++ (xiaomi_temp "temp2")
+ ++ (xiaomi_temp "temp3")
+
+ ++ (router_link "router1")
+ ++ (router_link "router2")
+
+ ++ [
+ # Sensor for monitoring the bridge state
+ {
+ platform = "mqtt";
+ name = "Zigbee2mqtt Bridge state";
+ state_topic = "${prefix}/bridge/state";
+ icon = "mdi:router-wireless";
+ }
+ # Sensor for Showing the Zigbee2mqtt Version
+ {
+ platform = "mqtt";
+ name = "Zigbee2mqtt Version";
+ state_topic = "${prefix}/bridge/config";
+ value_template = "{{ value_json.version }}";
+ icon = "mdi:zigbee";
+ }
+ # Sensor for Showing the Coordinator Version
+ {
+ platform = "mqtt";
+ name = "Coordinator Version";
+ state_topic = "${prefix}/bridge/config";
+ value_template = "{{ value_json.coordinator }}";
+ icon = "mdi:chip";
+ }
+ ];
+ binary_sensor =
+ (router_bin "router1")
+ ++ (router_bin "router2");
+ switch = [
+ {
+ platform = "mqtt";
+ name = "Zigbee2mqtt Main join";
+ state_topic = "${prefix}/bridge/config/permit_join";
+ command_topic = "${prefix}/bridge/config/permit_join";
+ payload_on = "true";
+ payload_off = "false";
+ }
+ ];
+ automation = [
+ {
+ alias = "Zigbee2mqtt Log Level";
+ initial_state = "on";
+ trigger = {
+ platform = "state";
+ entity_id = "input_select.zigbee2mqtt_log_level";
+ };
+ action = [
+ {
+ service = "mqtt.publish";
+ data = {
+ payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}";
+ topic = "${prefix}/bridge/config/log_level";
+ };
+ }
+ ];
+ }
+# Automation to start timer when enable join is turned on
+ {
+ id = "zigbee_join_enabled";
+ alias = "Zigbee Join Enabled";
+ hide_entity = "true";
+ trigger =
+ {
+ platform = "state";
+ entity_id = "switch.zigbee2mqtt_main_join";
+ to = "on";
+ };
+ action =
+ {
+ service = "timer.start";
+ entity_id = "timer.zigbee_permit_join";
+ };
+ }
+# # Automation to stop timer when switch turned off and turn off switch when timer finished
+ {
+ id = "zigbee_join_disabled";
+ alias = "Zigbee Join Disabled";
+ hide_entity = "true";
+ trigger = [
+ {
+ platform = "event";
+ event_type = "timer.finished";
+ event_data.entity_id = "timer.zigbee_permit_join";
+ }
+ {
+ platform = "state";
+ entity_id = "switch.zigbee2mqtt_main_join";
+ to = "off";
+ }
+ ];
+ action = [
+ { service = "timer.cancel";
+ data.entity_id = "timer.zigbee_permit_join";
+ }
+ { service = "switch.turn_off";
+ entity_id = "switch.zigbee2mqtt_main_join";
+ }
+ ];
+ }
+ ];
+ input_select.zigbee2mqtt_log_level =
+ {
+ name = "Zigbee2mqtt Log Level";
+ options = [
+ "debug"
+ "info"
+ "warn"
+ "error"
+ ];
+ initial = "info";
+ icon = "mdi:format-list-bulleted";
+ };
+
+ timer.zigbee_permit_join =
+ {
+ name = "Zigbee Time remaining";
+ duration = 120;
+ };
+}
diff --git a/makefu/2configs/ham/sensor/outside.nix b/makefu/2configs/ham/sensor/outside.nix
new file mode 100644
index 000000000..8436b8de2
--- /dev/null
+++ b/makefu/2configs/ham/sensor/outside.nix
@@ -0,0 +1,26 @@
+{lib,...}: [
+ { platform = "darksky";
+ api_key = lib.removeSuffix "\n"
+ (builtins.readFile <secrets/hass/darksky.apikey>);
+ language = "de";
+ monitored_conditions = [
+ "summary" "icon"
+ "nearest_storm_distance" "precip_probability"
+ "precip_intensity"
+ "temperature" # "temperature_high" "temperature_low"
+ "apparent_temperature"
+ "hourly_summary" # next 24 hours text
+ "humidity"
+ "pressure"
+ "uv_index"
+ ];
+ units = "si" ;
+ scan_interval = "00:30:00";
+ }
+ { platform = "luftdaten";
+ name = "Muehlhausen";
+ show_on_map = true;
+ sensor_id = "679";
+ sensors.monitored_conditions = [ "P1" "P2" ];
+ }
+ ]
diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix
deleted file mode 100644
index 4e9ac0ee3..000000000
--- a/makefu/2configs/homeautomation/default.nix
+++ /dev/null
@@ -1,305 +0,0 @@
-{ pkgs, lib, config, ... }:
-
-# Ideas:
-## wake-on-lan server
-##
-let
- tasmota_rgb = name: topic:
-# LED WS2812b
-# effect_state_topic: "stat/led/Scheme"
-# effect_command_topic: "cmnd/led/Scheme"
-# effect_value_template: "{{ value_json.Scheme }}"
- { platform = "mqtt";
- inherit name;
- retain = false;
- qos = 1;
- optimistic = false;
- # state
- # TODO: currently broken, will not use the custom state topic
- #state_topic = "/ham/${topic}/stat/POWER";
- state_topic = "/ham/${topic}/stat/POWER";
- command_topic = "/ham/${topic}/cmnd/POWER";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- # brightness
- brightness_state_topic = "/ham/${topic}/stat/Dimmer";
- brightness_command_topic = "/ham/${topic}/cmnd/Dimmer";
- brightness_value_template = "{{ value_json.Dimmer }}";
- brightness_scale = 100;
- # color
- rgb_state_topic = "/ham/${topic}/stat/Color";
- rgb_command_topic = "/ham/${topic}/cmnd/MEM1"; # use enabled tasmota rule
- rgb_command_mode = "hex";
- rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
- # effects
- effect_state_topic = "/ham/${topic}/stat/Scheme";
- effect_command_topic = "/ham/${topic}/cmnd/Scheme";
- effect_value_template = "{{ value_json.Scheme }}";
- effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ];
-};
- # switchmode 1 - also toggle power
- # switchtopic flurlicht
- tasmota_motion = name: topic:
- { platform = "mqtt";
- device_class = "motion";
- inherit name;
- # TODO: currently broken, will not