1
0
mirror of https://github.com/kmein/niveum synced 2026-03-20 03:51:07 +01:00

1 Commits

Author SHA1 Message Date
9f0c8c7a73 wip: hass with nix 2023-02-08 10:09:24 +01:00
2 changed files with 107 additions and 161 deletions

1
ci.nix
View File

@@ -69,7 +69,6 @@
tabula = ensureFiles basic; tabula = ensureFiles basic;
ful = ensureFiles (["root.password"] ++ basic); ful = ensureFiles (["root.password"] ++ basic);
makanek = ensureFiles ([ makanek = ensureFiles ([
"grafana/admin"
"irc/retiolum" "irc/retiolum"
"irc/hackint" "irc/hackint"
"irc/libera" "irc/libera"

View File

@@ -1,197 +1,144 @@
{pkgs, ...}: let {config, ...}: let
port = 8123; port = 8123;
mosquittoPort = 1883;
zigbee2mqttPort = 7977;
in { in {
networking.firewall.allowedTCPPorts = [port zigbee2mqttPort]; networking.firewall.allowedTCPPorts = [port];
services.zigbee2mqtt = {
enable = true;
settings = {
serial.port = "/dev/ttyACM0";
permit_join = true;
homeassistant = true;
frontend = {
port = zigbee2mqttPort;
host = "0.0.0.0";
};
experimental.new_api = true;
mqtt = {
discovery = true;
base_topic = "zigbee";
server = "mqtt://localhost:${toString mosquittoPort}";
user = "as59";
password = "as59-mqtt";
};
};
};
services.mosquitto = {
enable = true;
listeners = [
{
acl = [];
users.as59 = {
acl = ["readwrite #"];
password = "as59-mqtt";
};
port = mosquittoPort;
}
];
};
environment.systemPackages = [pkgs.mosquitto];
services.nginx.virtualHosts."home.kmein.r" = { services.nginx.virtualHosts."home.kmein.r" = {
locations."/" = { locations."/" = {
proxyPass = "http://127.0.0.1:${toString port}"; proxyPass = "http://127.0.0.1:${toString config.services.home-assistant.http.server_port}";
}; };
}; };
services.home-assistant = { services.home-assistant = {
enable = true; enable = true;
configWritable = true; config = {
lovelaceConfigWritable = true; frontend = {};
config = let sun = {};
in { # TODO calendar = { platform = "caldav"; url = "TODO"; username = "TODO"; password = "TODO"; }
config = {};
mobile_app = {};
network = {};
homeassistant = { homeassistant = {
name = "Home"; name = "Home";
time_zone = "Europe/Berlin"; latitude = "";
latitude = "52.46187";
longitude = "13.41489";
elevation = 90;
unit_system = "metric";
# customize = friendly_names;
}; };
config = {}; auth.users = [
sun.elevation = 66;
discovery = {};
frontend = {};
http = {};
weather = [
#{
# platform = "openweathermap";
# api_key = "xxx"; # TODO put into secrets
#}
];
system_health = {};
history = {};
switch = [
{ {
platform = "mqtt"; id = "aa6284a151da4a9c91b4a18d86a5788b";
name = "zigbee2mqtt_join"; group_ids = ["system-admin"];
state_topic = "/zigbee2mqtt/bridge/config/permit_join"; is_owner = true;
command_topic = "/zigbee2mqtt/bridge/config/permit_join"; is_active = true;
payload_on = "true"; name = "kmein";
payload_off = "false";
} }
]; ];
"core.area_registry".areas = [
{
id = "living_room";
name = "Saal";
}
{
id = "kitchen";
name = "Küche";
}
{
id = "bedroom";
name = "Zimmer";
}
{
id = "corridor";
name = "Korridor";
}
];
default_config = {};
http.server_port = 8124;
automation = [ automation = [
{ {
id = "zigbee_join_enabled"; id = "1647008057816";
alias = ""; alias = "Abend";
trigger = { description = "";
platform = "state";
entity_id = "switch.zigbee2mqtt_join";
to = "on";
};
action = {
service = "timer.start";
entity_id = "timer.zigbee_permit_join";
};
}
{
id = "zigbee_join_disabled";
trigger = [ trigger = [
{ {
platform = "event"; platform = "sun";
event_type = "timer.finished"; event = "sunset";
event_data.entity_id = "timer.zigbee_permit_join"; offset = 15;
}
{
platform = "state";
entity_id = "switch.zigbee2mqtt_join";
to = "off";
} }
]; ];
condition = [];
mode = "single";
action = [ action = [
{ {
service = "timer.cancel"; service = "scene.turn_on";
data.entity_id = "timer.zigbee_permit_join"; target.entity_id = "scene.abend";
metadata = {};
} }
];
}
{
id = "1647205852858";
alias = "Come home";
description = "";
trigger = [
{ {
service = "switch.turn_off"; platform = "device";
entity_id = "switch.zigbee2mqtt_join"; device_id = "7279f87d95574352ff7e9cc69c325a63";
domain = "device_tracker";
entity_id = "device_tracker.moto_g_7_power";
type = "enters";
zone = "zone.home";
}
];
condition = [
{
condition = "sun";
after = "sunset";
after_offset = 15;
}
];
mode = "single";
action = [
{
type = "turn_on";
device_id = "4cf6a7217da6633d4a9c74fdf82ff30f";
entity_id = "light.corridor_ceiling";
domain = "light";
} }
]; ];
} }
]; ];
timer.zigbee_permit_join = { tradfri = {};
name = "Zigbee Time remaining"; openweathermap = {};
duration = 120; weather = {};
}; scene = [
mobile_app = {};
sensor = [
{ {
platform = "dwd_weather_warnings"; id = "1647007926507";
region_name = "Berlin"; name = "Abend";
} entities = {
# Sensor for monitoring the bridge state "switch.kette".state = "on";
{ "switch.tradfri_outlet_2".state = "on"; # Kette 2
platform = "mqtt"; "light.arod" = {
name = "Zigbee2mqtt Bridge state"; min_mireds = 250;
state_topic = "/zigbee2mqtt/bridge/state"; max_mireds = 454;
icon = "mdi:router-wireless"; color_mode = "hs";
} brightness = 76;
# Sensor for Showing the Zigbee2mqtt Version hs_color = [29.021 74.588];
{ state = "on";
platform = "mqtt"; };
name = "Zigbee2mqtt Version"; };
state_topic = "/zigbee2mqtt/bridge/config";
value_template = "{{ value_json.version }}";
icon = "mdi:zigbee";
}
# Sensor for Showing the Coordinator Version
{
platform = "mqtt";
name = "Coordinator Version";
state_topic = "/zigbee2mqtt/bridge/config";
value_template = "{{ value_json.coordinator }}";
icon = "mdi:chip";
} }
]; ];
mqtt = {
broker = "localhost";
port = mosquittoPort;
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";
};
};
}; };
}; };
# virtualisation.oci-containers = { virtualisation.oci-containers = {
# backend = "podman"; backend = "podman";
# containers.homeassistant = { containers.homeassistant = {
# volumes = ["home-assistant:/config"]; volumes = ["home-assistant:/config"];
# environment.TZ = "Europe/Berlin"; environment.TZ = "Europe/Berlin";
# image = "ghcr.io/home-assistant/home-assistant:stable"; image = "ghcr.io/home-assistant/home-assistant:stable";
# extraOptions = [ extraOptions = [
# "--network=host" "--network=host"
# # "--device=/dev/ttyUSB0:/dev/ttyACM0" # Example, change this to match your own hardware # "--device=/dev/ttyUSB0:/dev/ttyACM0" # Example, change this to match your own hardware
# ]; ];
# }; };
# }; };
} }