nixos-configuration/hosts/aluminium/services/home-assistant.nix
2025-04-16 22:54:28 +02:00

141 lines
4.3 KiB
Nix

args@{ lib, pkgs, config, custom-utils, ... }:
let
ports = import ../ports.nix args;
in
{
services.home-assistant = {
enable = true;
lovelaceConfig = {
title = "Home";
views = [
{
path = "default_view";
title = "Home";
cards = [
{
title = "Heizung";
type = "entities";
entities = [
{ entity = "sensor.guntamaticbiostar_betrieb"; }
{ entity = "sensor.guntamaticbiostar_pufferladung"; }
{ entity = "sensor.guntamaticbiostar_puffer_oben"; }
{ entity = "sensor.guntamaticbiostar_puffer_unten"; }
{ entity = "sensor.guntamaticbiostar_kesseltemperatur"; }
{ entity = "sensor.guntamaticbiostar_vorlauf_ist_1"; }
{ entity = "sensor.guntamaticbiostar_aussentemperatur"; }
{ entity = "sensor.guntamaticbiostar_co2_gehalt"; }
{ entity = "select.guntamaticbiostar_program"; }
{ entity = "sensor.guntamaticbiostar_programm"; }
{ entity = "sensor.guntamaticbiostar_programm_hk1"; }
{ entity = "sensor.guntamaticbiostar_rucklauftemperatur"; }
{ entity = "sensor.guntamaticbiostar_servicezeit"; }
];
}
{
type = "grid";
square = false;
columns = 1;
cards = [
{
title = "Wasserbett";
type = "entities";
entities = [
{
entity = "sensor.waterbed_temperatur";
name = "Temperatur";
}
];
}
{
type = "thermostat";
entity = "climate.waterbed_temperatur";
}
];
}
];
}
];
};
extraComponents = [
# See https://www.home-assistant.io/integrations
"esphome"
"openweathermap"
];
customComponents = [
# https://github.com/a529987659852/GuntamaticBiostar
pkgs.home-assistant-custom-components.guntamatic
];
lovelaceConfigWritable = false;
configWritable = false;
config = {
http = {
server_host = [ "127.0.0.1" ];
server_port = ports.home-assistant.tcp;
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" ];
};
homeassistant = {
unit_system = "metric";
time_zone = "Europe/Berlin";
temperature_unit = "C";
inherit (config.location) longitude;
inherit (config.location) latitude;
};
default_config = { };
"automation nix" = [
{
alias = "Nachschüren";
description = "Benachrichtigung auf iPad bei Wechsel auf Teillast";
mode = "single";
trigger = [
{
platform = "state";
entity_id = [ "sensor.guntamaticbiostar_betrieb" ];
from = "VOLLLAST";
to = "TEILLAST";
}
];
condition = [
{
condition = "numeric_state";
entity_id = "sensor.guntamaticbiostar_pufferladung";
below = "80";
}
];
action = [
{
device_id = "5612874405fa2ee539ad4518a1bb8e34";
domain = "mobile_app";
type = "notify";
message = ''
Kessel läuft auf Teillast und Puffer ist unter 80%. Vielleicht willst du
nachschüren.
'';
title = "Nachschüren?";
}
];
}
];
"automation ui" = "!include automations.yaml";
"scene nix" = [
];
"scene ui" = "!include scenes.yaml";
};
};
systemd.tmpfiles.rules = [
"f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
"f ${config.services.home-assistant.configDir}/scenes.yaml 0755 hass hass"
];
services.nginx.virtualHosts."hass.kbh.jalr.de" = {
enableACME = true;
forceSSL = true;
kTLS = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString ports.home-assistant.tcp}/";
recommendedProxySettings = true;
proxyWebsockets = true;
};
};
}