2018-10-16 22:34:46 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
2018-09-18 00:16:12 +00:00
|
|
|
|
|
|
|
# Ideas:
|
|
|
|
## wake-on-lan server
|
|
|
|
##
|
2018-09-13 20:29:29 +00:00
|
|
|
let
|
2018-10-16 22:34:46 +00:00
|
|
|
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";
|
2018-11-05 12:52:11 +00:00
|
|
|
state_topic = "/ham/${topic}/stat/POWER";
|
2018-10-16 22:34:46 +00:00
|
|
|
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";
|
2018-12-13 00:47:56 +00:00
|
|
|
rgb_command_topic = "/ham/${topic}/cmnd/MEM1"; # use enabled tasmota rule
|
2018-10-16 22:34:46 +00:00
|
|
|
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
|
2018-11-05 12:52:11 +00:00
|
|
|
state_topic = "/ham/${topic}/stat/POWER";
|
2018-10-16 22:34:46 +00:00
|
|
|
payload_on = "ON";
|
|
|
|
payload_off = "OFF";
|
|
|
|
availability_topic = "/ham/${topic}/tele/LWT";
|
|
|
|
payload_available = "Online";
|
|
|
|
payload_not_available = "Offline";
|
|
|
|
};
|
|
|
|
|
2018-09-13 20:29:29 +00:00
|
|
|
firetv = "192.168.1.238";
|
2018-09-18 00:16:12 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
];
|
2018-11-05 12:52:11 +00:00
|
|
|
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 = "%";
|
|
|
|
}
|
|
|
|
];
|
2018-09-13 20:29:29 +00:00
|
|
|
in {
|
2018-09-17 19:52:41 +00:00
|
|
|
imports = [
|
|
|
|
./mqtt.nix
|
|
|
|
];
|
2018-10-16 22:34:46 +00:00
|
|
|
#systemd.services.firetv = {
|
|
|
|
# wantedBy = [ "multi-user.target" ];
|
|
|
|
# serviceConfig = {
|
|
|
|
# User = "nobody";
|
|
|
|
# ExecStart = "${pkgs.python-firetv}/bin/firetv-server -d ${firetv}:5555";
|
|
|
|
# };
|
|
|
|
#};
|
2018-09-13 20:29:29 +00:00
|
|
|
services.home-assistant = {
|
|
|
|
config = {
|
|
|
|
homeassistant = {
|
|
|
|
name = "Home"; time_zone = "Europe/Berlin";
|
|
|
|
latitude = "48.7687";
|
|
|
|
longitude = "9.2478";
|
2018-09-18 00:16:12 +00:00
|
|
|
elevation = 247;
|
2018-09-13 20:29:29 +00:00
|
|
|
};
|
2018-10-16 22:34:46 +00:00
|
|
|
#discovery = {};
|
2018-09-18 00:16:12 +00:00
|
|
|
conversation = {};
|
|
|
|
history = {};
|
|
|
|
logbook = {};
|
|
|
|
tts = [
|
|
|
|
{ platform = "google";}
|
|
|
|
];
|
|
|
|
sun.elevation = 247;
|
|
|
|
recorder = {};
|
2018-09-13 20:29:29 +00:00
|
|
|
media_player = [
|
|
|
|
{ platform = "kodi";
|
|
|
|
host = firetv;
|
|
|
|
}
|
2018-10-16 22:34:46 +00:00
|
|
|
#{ platform = "firetv";
|
|
|
|
# # assumes python-firetv running
|
|
|
|
#}
|
2018-09-13 20:29:29 +00:00
|
|
|
];
|
2018-09-18 00:16:12 +00:00
|
|
|
mqtt = {
|
|
|
|
broker = "localhost";
|
|
|
|
port = 1883;
|
|
|
|
client_id = "home-assistant";
|
|
|
|
username = "hass";
|
2018-10-16 22:34:46 +00:00
|
|
|
password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/hass>);
|
2018-09-18 00:16:12 +00:00
|
|
|
keepalive = 60;
|
|
|
|
protocol = 3.1;
|
|
|
|
birth_message = {
|
|
|
|
topic = "/ham/hass/tele/LWT";
|
|
|
|
payload = "Online";
|
|
|
|
qos = 1;
|
|
|
|
retain = true;
|
|
|
|
};
|
|
|
|
will_message = {
|
|
|
|
topic = "/ham/hass/tele/LWT";
|
|
|
|
payload = "Offline";
|
|
|
|
qos = 1;
|
|
|
|
retain = true;
|
|
|
|
};
|
|
|
|
};
|
2018-10-16 22:34:46 +00:00
|
|
|
binary_sensor = [
|
|
|
|
(tasmota_motion "Flur Bewegung" "flurlicht")
|
|
|
|
];
|
2018-09-13 20:29:29 +00:00
|
|
|
sensor = [
|
2018-10-16 22:34:46 +00:00
|
|
|
# broken
|
|
|
|
#{ platform = "speedtest";
|
|
|
|
# monitored_conditions = [ "ping" "download" "upload" ];
|
|
|
|
#}
|
2018-09-13 20:29:29 +00:00
|
|
|
{ platform = "luftdaten";
|
2018-11-05 12:52:11 +00:00
|
|
|
name = "Wangen";
|
2018-09-13 20:29:29 +00:00
|
|
|
sensorid = "663";
|
|
|
|
monitored_conditions = [ "P1" "P2" ];
|
|
|
|
}
|
|
|
|
# https://www.home-assistant.io/cookbook/automation_for_rainy_days/
|
|
|
|
{ platform = "darksky";
|
2018-10-16 22:34:46 +00:00
|
|
|
api_key = lib.removeSuffix "\n"
|
|
|
|
(builtins.readFile <secrets/hass/darksky.apikey>);
|
2018-09-13 20:29:29 +00:00
|
|
|
language = "de";
|
|
|
|
monitored_conditions = [ "summary" "icon"
|
|
|
|
"nearest_storm_distance" "precip_probability"
|
|
|
|
"precip_intensity"
|
2018-11-05 12:52:11 +00:00
|
|
|
"temperature"
|
|
|
|
"apparent_temperature"
|
2018-09-13 20:29:29 +00:00
|
|
|
"hourly_summary"
|
2018-11-05 12:52:11 +00:00
|
|
|
"humidity"
|
|
|
|
"pressure"
|
2018-09-13 20:29:29 +00:00
|
|
|
"uv_index" ];
|
|
|
|
units = "si" ;
|
|
|
|
update_interval = {
|
|
|
|
days = 0;
|
|
|
|
hours = 0;
|
2018-11-05 12:52:11 +00:00
|
|
|
minutes = 30;
|
2018-09-13 20:29:29 +00:00
|
|
|
seconds = 0;
|
|
|
|
};
|
|
|
|
}
|
2018-11-05 12:52:11 +00:00
|
|
|
]
|
|
|
|
++ (tasmota_bme "Schlafzimmer" "schlafzimmer")
|
|
|
|
++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer");
|
2018-09-13 20:29:29 +00:00
|
|
|
frontend = { };
|
2018-10-16 22:34:46 +00:00
|
|
|
group =
|
|
|
|
{ default_view =
|
|
|
|
{ view = "yes";
|
|
|
|
entities = [
|
|
|
|
"group.flur"
|
|
|
|
"group.schlafzimmer"
|
|
|
|
"group.draussen"
|
|
|
|
"group.wohnzimmer"
|
2018-11-05 12:52:11 +00:00
|
|
|
"group.arbeitszimmer"
|
2018-10-16 22:34:46 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
flur = [
|
|
|
|
"light.flurlicht"
|
|
|
|
"binary_sensor.flur_bewegung"
|
|
|
|
];
|
|
|
|
wohnzimmer = [
|
|
|
|
"media_player.kodi"
|
|
|
|
];
|
|
|
|
draussen = [
|
|
|
|
"sensor.dark_sky_temperature"
|
|
|
|
"sensor.dark_sky_hourly_summary"
|
2018-11-05 12:52:11 +00:00
|
|
|
"sensor.wangen_pm10"
|
|
|
|
"sensor.wangen_pm25"
|
2018-10-16 22:34:46 +00:00
|
|
|
];
|
|
|
|
schlafzimmer = [
|
|
|
|
"sensor.schlafzimmer_temperatur"
|
|
|
|
"sensor.schlafzimmer_luftdruck"
|
|
|
|
"sensor.schlafzimmer_luftfeuchtigkeit"
|
|
|
|
"switch.lichterkette_schlafzimmer"
|
|
|
|
];
|
2018-11-05 12:52:11 +00:00
|
|
|
arbeitszimmer = [
|
|
|
|
"switch.strom_staubsauger"
|
|
|
|
"sensor.arbeitszimmer_temperatur"
|
|
|
|
"sensor.arbeitszimmer_luftfeuchtigkeit"
|
|
|
|
];
|
2018-10-16 22:34:46 +00:00
|
|
|
};
|
2018-09-13 20:29:29 +00:00
|
|
|
http = { };
|
2018-09-18 00:16:12 +00:00
|
|
|
switch = [
|
|
|
|
(tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer")
|
2018-11-05 12:52:11 +00:00
|
|
|
(tasmota_plug "Strom Staubsauger" "arbeitszimmer")
|
2018-09-18 00:16:12 +00:00
|
|
|
];
|
2018-10-16 22:34:46 +00:00
|
|
|
light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ];
|
2018-11-05 12:52:11 +00:00
|
|
|
automation = [
|
|
|
|
{ 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";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2018-09-13 20:29:29 +00:00
|
|
|
};
|
|
|
|
enable = true;
|
|
|
|
#configDir = "/var/lib/hass";
|
|
|
|
};
|
|
|
|
}
|