stockholm/makefu/2configs/ham/default.nix

226 lines
6.2 KiB
Nix
Raw Normal View History

{ pkgs, lib, config, ... }:
# Ideas:
## wake-on-lan server
2020-02-04 17:26:59 +00:00
##
2018-09-13 20:29:29 +00:00
let
2020-02-04 17:26:59 +00:00
hlib = (import ./lib);
prefix = hlib.prefix;
tasmota = hlib.tasmota;
2019-03-06 15:42:52 +00:00
firetv = "192.168.1.183";
2020-02-04 17:26:59 +00:00
kodi-host = firetv;
2019-03-06 15:42:52 +00:00
hassdir = "/var/lib/hass";
2020-02-04 17:26:59 +00:00
zigbee = import ./multi/zigbee2mqtt.nix;
# switch
# automation
# binary_sensor
# sensor
# input_select
# timer
2018-09-13 20:29:29 +00:00
in {
2018-09-17 19:52:41 +00:00
imports = [
./mqtt.nix
];
2019-03-06 15:42:52 +00:00
2018-09-13 20:29:29 +00:00
services.home-assistant = {
config = {
2020-02-04 17:26:59 +00:00
input_select = zigbee.input_select; # dict
timer = zigbee.timer; # dict
2018-09-13 20:29:29 +00:00
homeassistant = {
name = "Home"; time_zone = "Europe/Berlin";
latitude = "48.7687";
longitude = "9.2478";
elevation = 247;
2018-09-13 20:29:29 +00:00
};
#discovery = {};
conversation = {};
history = {};
logbook = {};
tts = [
2020-02-04 17:26:59 +00:00
{ platform = "google_translate";
language = "de";
time_memory = 57600;
service_name = "google_say";
}
];
2020-02-04 17:26:59 +00:00
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 = {};
2018-09-13 20:29:29 +00:00
media_player = [
{ platform = "kodi";
host = firetv;
}
2019-03-06 15:42:52 +00:00
{ platform = "firetv";
name = "FireTV Stick";
host = firetv;
adbkey = <secrets/hass/adbkey>;
}
2018-09-13 20:29:29 +00:00
];
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 = {
2020-02-04 17:26:59 +00:00
topic = "${prefix}/hass/tele/LWT";
payload = "Online";
qos = 1;
retain = true;
};
will_message = {
2020-02-04 17:26:59 +00:00
topic = "${prefix}/hass/tele/LWT";
payload = "Offline";
qos = 1;
retain = true;
};
};
binary_sensor = [
2020-02-04 17:26:59 +00:00
(tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";})
] ++ zigbee.binary_sensor;
2018-09-13 20:29:29 +00:00
sensor = [
# broken
#{ platform = "speedtest";
# monitored_conditions = [ "ping" "download" "upload" ];
#}
2018-09-13 20:29:29 +00:00
# https://www.home-assistant.io/cookbook/automation_for_rainy_days/
2018-11-05 12:52:11 +00:00
]
2020-02-04 17:26:59 +00:00
++ ((import ./sensor/outside.nix) {inherit lib;})
++ zigbee.sensor
++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";})
++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; });
2018-09-13 20:29:29 +00:00
frontend = { };
group =
{ default_view =
{ view = "yes";
entities = [
"group.flur"
"group.schlafzimmer"
"group.draussen"
"group.wohnzimmer"
2018-11-05 12:52:11 +00:00
"group.arbeitszimmer"
];
};
flur = [
"light.flurlicht"
"binary_sensor.flur_bewegung"
2019-03-06 15:42:52 +00:00
"automation.dunkel_bei_sonnenuntergang"
"automation.hell_bei_sonnenaufgang"
];
wohnzimmer = [
"media_player.kodi"
2019-03-06 15:42:52 +00:00
"media_player.firetv_stick"
];
draussen = [
"sensor.dark_sky_temperature"
"sensor.dark_sky_hourly_summary"
2020-02-04 17:26:59 +00:00
"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"
];
2018-11-05 12:52:11 +00:00
arbeitszimmer = [
"switch.strom_staubsauger"
"sensor.arbeitszimmer_temperatur"
"sensor.arbeitszimmer_luftfeuchtigkeit"
];
};
2018-09-13 20:29:29 +00:00
http = { };
switch = [
2020-02-04 17:26:59 +00:00
(tasmota.plug { name = "Lichterkette Schlafzimmer"; host = "schlafzimmer";})
(tasmota.plug { name = "Strom Staubsauger"; host = "arbeitszimmer"; } )
] ++ zigbee.switch;
light = [ (tasmota.rgb { name = "Flurlicht"; host = "flurlicht";} ) ];
2018-11-05 12:52:11 +00:00
automation = [
2019-03-06 15:42:52 +00:00
{ 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";
}
];
}
2020-02-04 17:26:59 +00:00
#{ 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;
2018-09-13 20:29:29 +00:00
};
enable = true;
2019-03-06 15:42:52 +00:00
configDir = hassdir;
2018-09-13 20:29:29 +00:00
};
2018-09-13 20:29:29 +00:00
}