add home assistant
This commit is contained in:
@@ -290,5 +290,85 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
home-assistant = {
|
||||
enable = true;
|
||||
subdomain = "home";
|
||||
config = {
|
||||
homeassistant = {
|
||||
name = "Koti";
|
||||
unit_system = "metric";
|
||||
time_zone = "Europe/Helsinki";
|
||||
};
|
||||
http = {
|
||||
server_port = 8123;
|
||||
use_x_forwarded_for = true;
|
||||
trusted_proxies = [
|
||||
"127.0.0.1"
|
||||
"::1"
|
||||
];
|
||||
};
|
||||
mqtt = [
|
||||
{
|
||||
climate = {
|
||||
unique_id = "nappula";
|
||||
name = "Nappula";
|
||||
current_humidity_topic = "homie/nappula/humidity/value";
|
||||
current_humidity_template = "{{ value | float }}";
|
||||
current_temperature_topic = "homie/nappula/temperature/value";
|
||||
current_temperature_template = "{{ value | float }}";
|
||||
mode_state_topic = "homie/nappula/ac/trigger";
|
||||
mode_state_template = "{% if value == 'true' %}heat{% else %}off{% endif %}";
|
||||
availability = {
|
||||
topic = "homie/nappula/$online";
|
||||
payload_available = "true";
|
||||
payload_not_available = "false";
|
||||
};
|
||||
modes = [
|
||||
"off"
|
||||
"heat"
|
||||
];
|
||||
};
|
||||
}
|
||||
{
|
||||
button = {
|
||||
unique_id = "nappula_button";
|
||||
name = "Nappula anschalten";
|
||||
command_topic = "homie/nappula/button/trigger/set";
|
||||
payload_press = "true";
|
||||
availability = {
|
||||
topic = "homie/nappula/$online";
|
||||
payload_available = "true";
|
||||
payload_not_available = "false";
|
||||
};
|
||||
icon = "mdi:power";
|
||||
};
|
||||
}
|
||||
{
|
||||
sensor = {
|
||||
unique_id = "nappula_pressure";
|
||||
name = "Luftdruck";
|
||||
state_topic = "homie/nappula/pressure/value";
|
||||
device_class = "atmospheric_pressure";
|
||||
unit_of_measurement = "hPa";
|
||||
state_class = "measurement";
|
||||
value_template = "{{ value | float // 100 }}";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
extraComponents = [
|
||||
"default_config"
|
||||
"esphome"
|
||||
"met"
|
||||
"radio_browser"
|
||||
"mqtt"
|
||||
];
|
||||
extraPackages = (
|
||||
python3Packages: with python3Packages; [
|
||||
paho-mqtt
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,5 +22,6 @@
|
||||
./mealie.nix
|
||||
./uptime-kuma.nix
|
||||
./mosquitto.nix
|
||||
./home-assistant.nix
|
||||
];
|
||||
}
|
||||
|
||||
20
modules/services/home-assistant.nix
Normal file
20
modules/services/home-assistant.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.services.home-assistant;
|
||||
fqdn = "${cfg.subdomain}.${config.networking.domain}";
|
||||
in
|
||||
{
|
||||
options.services.home-assistant = {
|
||||
subdomain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The subdomain to use for Home Assistant";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.webserver = {
|
||||
enable = lib.mkDefault true;
|
||||
vHosts.${fqdn}.locations."/".proxyPort = cfg.config.http.server_port;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user