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

2 Commits

Author SHA1 Message Date
62f3c7fcc0 wip 2023-02-09 18:05:17 +01:00
0f88954989 fix(ci): add grafana secret to makanek 2023-02-09 09:48:36 +01:00
2 changed files with 173 additions and 119 deletions

1
ci.nix
View File

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

View File

@@ -1,144 +1,197 @@
{config, ...}: let
{pkgs, ...}: let
port = 8123;
mosquittoPort = 1883;
zigbee2mqttPort = 7977;
in {
networking.firewall.allowedTCPPorts = [port];
networking.firewall.allowedTCPPorts = [port zigbee2mqttPort];
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" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.home-assistant.http.server_port}";
proxyPass = "http://127.0.0.1:${toString port}";
};
};
services.home-assistant = {
enable = true;
config = {
frontend = {};
sun = {};
# TODO calendar = { platform = "caldav"; url = "TODO"; username = "TODO"; password = "TODO"; }
config = {};
mobile_app = {};
network = {};
configWritable = true;
lovelaceConfigWritable = true;
config = let
in {
homeassistant = {
name = "Home";
latitude = "";
time_zone = "Europe/Berlin";
latitude = "52.46187";
longitude = "13.41489";
elevation = 90;
unit_system = "metric";
# customize = friendly_names;
};
auth.users = [
config = {};
sun.elevation = 66;
discovery = {};
frontend = {};
http = {};
weather = [
#{
# platform = "openweathermap";
# api_key = "xxx"; # TODO put into secrets
#}
];
system_health = {};
history = {};
switch = [
{
id = "aa6284a151da4a9c91b4a18d86a5788b";
group_ids = ["system-admin"];
is_owner = true;
is_active = true;
name = "kmein";
platform = "mqtt";
name = "zigbee2mqtt_join";
state_topic = "/zigbee2mqtt/bridge/config/permit_join";
command_topic = "/zigbee2mqtt/bridge/config/permit_join";
payload_on = "true";
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 = [
{
id = "1647008057816";
alias = "Abend";
description = "";
trigger = [
{
platform = "sun";
event = "sunset";
offset = 15;
}
];
condition = [];
mode = "single";
action = [
{
service = "scene.turn_on";
target.entity_id = "scene.abend";
metadata = {};
}
];
}
{
id = "1647205852858";
alias = "Come home";
description = "";
trigger = [
{
platform = "device";
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";
}
];
}
];
tradfri = {};
openweathermap = {};
weather = {};
scene = [
{
id = "1647007926507";
name = "Abend";
entities = {
"switch.kette".state = "on";
"switch.tradfri_outlet_2".state = "on"; # Kette 2
"light.arod" = {
min_mireds = 250;
max_mireds = 454;
color_mode = "hs";
brightness = 76;
hs_color = [29.021 74.588];
state = "on";
};
id = "zigbee_join_enabled";
alias = "";
trigger = {
platform = "state";
entity_id = "switch.zigbee2mqtt_join";
to = "on";
};
action = {
service = "timer.start";
entity_id = "timer.zigbee_permit_join";
};
}
{
id = "zigbee_join_disabled";
trigger = [
{
platform = "event";
event_type = "timer.finished";
event_data.entity_id = "timer.zigbee_permit_join";
}
{
platform = "state";
entity_id = "switch.zigbee2mqtt_join";
to = "off";
}
];
action = [
{
service = "timer.cancel";
data.entity_id = "timer.zigbee_permit_join";
}
{
service = "switch.turn_off";
entity_id = "switch.zigbee2mqtt_join";
}
];
}
];
timer.zigbee_permit_join = {
name = "Zigbee Time remaining";
duration = 120;
};
mobile_app = {};
sensor = [
{
platform = "dwd_weather_warnings";
region_name = "Berlin";
}
# Sensor for monitoring the bridge state
{
platform = "mqtt";
name = "Zigbee2mqtt Bridge state";
state_topic = "/zigbee2mqtt/bridge/state";
icon = "mdi:router-wireless";
}
# Sensor for Showing the Zigbee2mqtt Version
{
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 = {
backend = "podman";
containers.homeassistant = {
volumes = ["home-assistant:/config"];
environment.TZ = "Europe/Berlin";
image = "ghcr.io/home-assistant/home-assistant:stable";
extraOptions = [
"--network=host"
# "--device=/dev/ttyUSB0:/dev/ttyACM0" # Example, change this to match your own hardware
];
};
};
# virtualisation.oci-containers = {
# backend = "podman";
# containers.homeassistant = {
# volumes = ["home-assistant:/config"];
# environment.TZ = "Europe/Berlin";
# image = "ghcr.io/home-assistant/home-assistant:stable";
# extraOptions = [
# "--network=host"
# # "--device=/dev/ttyUSB0:/dev/ttyACM0" # Example, change this to match your own hardware
# ];
# };
# };
}