stockholm/lass/2configs/hass/default.nix

130 lines
3.5 KiB
Nix
Raw Normal View History

2020-04-21 12:21:17 +00:00
{ config, lib, pkgs, ... }:
2020-05-16 15:21:34 +00:00
with import ./lib.nix { inherit lib; };
2021-02-11 16:13:55 +00:00
let
unstable = import (pkgs.fetchFromGitHub {
owner = "nixos";
repo = "nixpkgs";
rev = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).rev;
sha256 = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).sha256;
}) {};
dwdwfsapi = pkgs.python3Packages.buildPythonPackage rec {
pname = "dwdwfsapi";
version = "1.0.3";
2020-05-16 15:21:34 +00:00
2021-02-11 16:13:55 +00:00
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "0fcv79xiq0qr4kivhd68iqpgrsjc7djxqs2h543pyr0sdgb5nz9x";
};
buildInputs = with pkgs.python3Packages; [
requests ciso8601
];
# LC_ALL = "en_US.UTF-8";
};
in {
2020-04-21 12:21:17 +00:00
imports = [
./zigbee.nix
./rooms/bett.nix
2020-05-16 15:21:34 +00:00
./rooms/essen.nix
./rooms/nass.nix
2020-04-21 12:21:17 +00:00
];
krebs.iptables.tables.filter.INPUT.rules = [
{ predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
{ predicate = "-i docker0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto
{ predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass
2021-01-24 08:43:53 +00:00
{ predicate = "-i int0 -p tcp --dport 1337"; target = "ACCEPT"; } # hass
2020-04-21 12:21:17 +00:00
{ predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass
2021-01-24 08:43:53 +00:00
{ predicate = "-i retiolum -p tcp --dport 1337"; target = "ACCEPT"; } # hass frontend
2020-06-07 11:06:25 +00:00
{ predicate = "-i wiregrill -p tcp --dport 8123"; target = "ACCEPT"; } # hass
2020-04-21 12:21:17 +00:00
];
services.home-assistant = {
enable = true;
2021-03-27 17:17:46 +00:00
package = unstable.home-assistant.overrideAttrs (old: {
2021-02-11 16:13:55 +00:00
doInstallCheck = false;
2021-03-27 17:17:46 +00:00
});
2020-04-21 12:21:17 +00:00
configWritable = true;
2020-09-27 13:36:01 +00:00
lovelaceConfigWritable = true;
2021-02-11 16:13:55 +00:00
config = let
tasmota_s20 = name: topic: {
platform = "mqtt";
inherit name;
state_topic = "stat/${topic}/POWER";
command_topic = "cmnd/${topic}/POWER";
payload_on = "ON";
payload_off = "OFF";
};
in {
homeassistant = {
name = "Home";
time_zone = "Europe/Berlin";
latitude = "52.46187";
longitude = "13.41489";
elevation = 90;
unit_system = "metric";
customize = friendly_names;
2020-04-21 12:21:17 +00:00
};
2021-02-11 16:13:55 +00:00
config = {};
sun.elevation = 66;
shopping_list = {};
discovery = {};
frontend = {};
http = {};
mqtt = {
broker = "localhost";
port = 1883;
client_id = "home-assistant";
username = "gg23";
password = "gg23-mqtt";
keepalive = 60;
protocol = 3.1;
discovery = true;
birth_message = {
topic = "/hass/status";
payload = "online";
};
will_message = {
topic = "/hass/status";
payload = "offline";
};
2020-04-21 12:21:17 +00:00
};
2021-02-11 16:13:55 +00:00
sensor = [
{
platform = "dwd_weather_warnings";
region_name = "Berlin";
}
];
switch = [
(tasmota_s20 "TV" "tv")
(tasmota_s20 "Drucker Strom" "drucker")
(tasmota_s20 "Waschmaschine" "wasch")
(tasmota_s20 "Stereo Anlage" "stereo")
];
mobile_app = {};
weather = [
{
platform = "openweathermap";
api_key = "xxx"; # TODO put into secrets
}
];
system_health = {};
history = {};
shopping_list = {};
2020-04-21 12:21:17 +00:00
};
};
services.mosquitto = {
enable = true;
2021-12-01 16:52:23 +00:00
listeners = [{
acl = [ "topic pattern readwrite #" ];
users.gg23 = { acl = [ "topic readwrite #" ]; password = "gg23-mqtt"; };
}];
2020-04-21 12:21:17 +00:00
};
environment.systemPackages = [ pkgs.mosquitto ];
}