summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-02-04 18:26:59 +0100
committermakefu <github@syntax-fehler.de>2020-02-04 18:26:59 +0100
commit89032b3ac2aff2373377ef442804e90db9694c91 (patch)
tree5a61ce51777f260b9a03236b6b57bffd7c15636f
parente38f61c7ff54031d5f48e57b96eff0062feb99b2 (diff)
ma homeautomation: init with zigbee
-rw-r--r--makefu/2configs/homeautomation/default.nix224
-rw-r--r--makefu/2configs/homeautomation/lib/default.nix318
-rw-r--r--makefu/2configs/homeautomation/multi/timer.nix123
-rw-r--r--makefu/2configs/homeautomation/multi/zigbee2mqtt.nix165
-rw-r--r--makefu/2configs/homeautomation/sensor/outside.nix26
5 files changed, 704 insertions, 152 deletions
diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix
index 4e9ac0ee3..56acc2d07 100644
--- a/makefu/2configs/homeautomation/default.nix
+++ b/makefu/2configs/homeautomation/default.nix
@@ -2,106 +2,21 @@
# 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 use the custom state topic
- state_topic = "/ham/${topic}/stat/POWER";
- payload_on = "ON";
- payload_off = "OFF";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- };
-
+ hlib = (import ./lib);
+ prefix = hlib.prefix;
+ tasmota = hlib.tasmota;
firetv = "192.168.1.183";
+ kodi-host = firetv;
hassdir = "/var/lib/hass";
- tasmota_plug = name: topic:
- { platform = "mqtt";
- inherit name;
- state_topic = "/ham/${topic}/stat/POWER1";
- command_topic = "/ham/${topic}/cmnd/POWER1";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- };
- tasmota_bme = name: topic:
- [ { platform = "mqtt";
- name = "${name} Temperatur";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Temperature }}";
- unit_of_measurement = "°C";
- }
- { platform = "mqtt";
- name = "${name} Luftfeuchtigkeit";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Humidity }}";
- unit_of_measurement = "%";
- }
- { platform = "mqtt";
- name = "${name} Luftdruck";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Pressure }}";
- unit_of_measurement = "hPa";
- }
- ];
- tasmota_am2301 = name: topic:
- [ { platform = "mqtt";
- name = "${name} Temperatur";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.AM2301.Temperature }}";
- unit_of_measurement = "°C";
- }
- { platform = "mqtt";
- name = "${name} Luftfeuchtigkeit";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.AM2301.Humidity }}";
- unit_of_measurement = "%";
- }
- ];
+ zigbee = import ./multi/zigbee2mqtt.nix;
+# switch
+# automation
+# binary_sensor
+# sensor
+# input_select
+# timer
in {
imports = [
./mqtt.nix
@@ -109,6 +24,8 @@ in {
services.home-assistant = {
config = {
+ input_select = zigbee.input_select; # dict
+ timer = zigbee.timer; # dict
homeassistant = {
name = "Home"; time_zone = "Europe/Berlin";
latitude = "48.7687";
@@ -120,8 +37,36 @@ in {
history = {};
logbook = {};
tts = [
- { platform = "google";}
+ { 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 = [
@@ -143,56 +88,32 @@ in {
keepalive = 60;
protocol = 3.1;
birth_message = {
- topic = "/ham/hass/tele/LWT";
+ topic = "${prefix}/hass/tele/LWT";
payload = "Online";
qos = 1;
retain = true;
};
will_message = {
- topic = "/ham/hass/tele/LWT";
+ topic = "${prefix}/hass/tele/LWT";
payload = "Offline";
qos = 1;
retain = true;
};
};
binary_sensor = [
- (tasmota_motion "Flur Bewegung" "flurlicht")
- ];
+ (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";})
+ ] ++ zigbee.binary_sensor;
sensor = [
# broken
#{ platform = "speedtest";
# monitored_conditions = [ "ping" "download" "upload" ];
#}
- { platform = "luftdaten";
- name = "Wangen";
- sensorid = "663";
- monitored_conditions = [ "P1" "P2" ];
- }
# https://www.home-assistant.io/cookbook/automation_for_rainy_days/
- { 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"
- "apparent_temperature"
- "hourly_summary"
- "humidity"
- "pressure"
- "uv_index" ];
- units = "si" ;
- update_interval = {
- days = 0;
- hours = 0;
- minutes = 30;
- seconds = 0;
- };
- }
]
- ++ (tasmota_bme "Schlafzimmer" "schlafzimmer")
- ++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer");
+ ++ ((import ./sensor/outside.nix) {inherit lib;})
+ ++ zigbee.sensor
+ ++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";})
+ ++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; });
frontend = { };
group =
{ default_view =
@@ -218,8 +139,10 @@ in {
draussen = [
"sensor.dark_sky_temperature"
"sensor.dark_sky_hourly_summary"
- "sensor.wangen_pm10"
- "sensor.wangen_pm25"
+ "sensor.dark_sky_humidity"
+ "sensor.dark_sky_pressure"
+ "sensor.muehlhausen_pm10"
+ "sensor.muehlhausen_pm25"
];
schlafzimmer = [
"sensor.schlafzimmer_temperatur"
@@ -235,10 +158,10 @@ in {
};
http = { };
switch = [
- (tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer")
- (tasmota_plug "Strom Staubsauger" "arbeitszimmer")
- ];
- light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ];
+ (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 = {
@@ -281,25 +204,22 @@ in {
}
];
}
- { 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";
- };
- }
- ];
+ #{ 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;
};
- nixpkgs.config.permittedInsecurePackages = [
- "homeassistant-0.77.2"
- ];
}
diff --git a/makefu/2configs/homeautomation/lib/default.nix b/makefu/2configs/homeautomation/lib/default.nix
new file mode 100644
index 000000000..8bc544310
--- /dev/null
+++ b/makefu/2configs/homeautomation/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/multi/timer.nix b/makefu/2configs/homeautomation/multi/timer.nix
new file mode 100644
index 000000000..eafb7841d
--- /dev/null
+++ b/makefu/2configs/homeautomation/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/homeautomation/multi/zigbee2mqtt.nix b/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix
new file mode 100644
index 000000000..ba81b1298
--- /dev/null
+++ b/makefu/2configs/homeautomation/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/homeautomation/sensor/outside.nix b/makefu/2configs/homeautomation/sensor/outside.nix
new file mode 100644
index 000000000..8436b8de2
--- /dev/null
+++ b/makefu/2configs/homeautomation/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" ];
+ }
+ ]