raspite: add home devices

This commit is contained in:
xinyangli 2025-03-26 11:21:23 +08:00
parent 6ad4e9477c
commit 6ab5672a8c
No known key found for this signature in database
3 changed files with 208 additions and 55 deletions

View file

@ -6,7 +6,7 @@
}:
{
imports = [ ./hass.nix ];
imports = [ ./services/hass.nix ];
commonSettings = {
nix.enable = true;

View file

@ -1,54 +0,0 @@
{ config, pkgs, ... }:
{
services.home-assistant = {
enable = true;
openFirewall = false;
config = {
default_config = { };
http = {
server_host = "127.0.0.1";
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" ];
};
};
extraPackages =
python3Packages: with python3Packages; [
# speed up aiohttp
isal
zlib-ng
];
};
services.esphome = {
enable = true;
openFirewall = false;
};
users.groups.dialout.members = config.users.groups.wheel.members;
services.mosquitto = {
enable = true;
};
services.zigbee2mqtt = {
enable = true;
settings = {
home-assistant = config.services.home-assistant.enable;
permit_join = true;
serial = {
port = "/dev/ttyUSB0";
};
};
};
networking.firewall.allowedTCPPorts = [ 8443 ];
services.caddy = {
enable = true;
virtualHosts = {
"raspite.coho-tet.ts.net".extraConfig = ''
reverse_proxy ${config.services.home-assistant.config.http.server_host}:${toString config.services.home-assistant.config.http.server_port}
'';
};
};
}

View file

@ -0,0 +1,207 @@
{ config, pkgs, ... }:
{
services.home-assistant = {
enable = true;
openFirewall = false;
config = {
default_config = { };
http = {
server_host = "127.0.0.1";
use_x_forwarded_for = true;
trusted_proxies = [ "127.0.0.1" ];
};
};
extraPackages =
python3Packages: with python3Packages; [
# speed up aiohttp
isal
zlib-ng
];
extraComponents = [
"mqtt"
"roborock"
];
};
services.esphome = {
enable = true;
openFirewall = false;
};
users.groups.dialout.members = config.users.groups.wheel.members;
services.mosquitto = {
enable = true;
};
services.zigbee2mqtt = {
enable = true;
package = pkgs.zigbee2mqtt_2;
settings = {
home-assistant = config.services.home-assistant.enable;
serial = {
adapter = "zstack";
port = "/dev/ttyUSB0";
};
frontend = {
enabled = true;
port = 15313;
host = "127.0.0.1";
};
advanced = {
log_level = "debug";
availability = {
# Periodically check whether devices are online/offline
enabled = true;
};
channel = 11;
homeassistant_legacy_entity_attributes = false;
homeassistant_legacy_triggers = false;
legacy_api = false;
legacy_availability_payload = false;
};
device_options = {
legacy = false;
};
devices = {
"0x000d6f001673c5d4" = {
friendly_name = "";
};
"0x000d6f001673c1df" = {
friendly_name = "";
};
"0x000d6f0014cbc2c6" = {
friendly_name = "";
};
"0x8cf681fffe0a5e38" = {
friendly_name = "";
description = "1: 2: ";
};
"0x8cf681fffe0d9f1c" = {
friendly_name = "1";
description = "1: 2: 西";
};
"0x000d6f00167839ff" = {
friendly_name = "2";
description = "1: 2: ";
};
"0x8cf681fffe0db266" = {
friendly_name = "3";
description = "";
};
"0x8cf681fffe0d9ccb" = {
friendly_name = "4";
description = "1.";
};
"0x000d6f001673c512" = {
friendly_name = "";
};
"0xa4c13815e2f92d74" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54ced3" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe54c8d4" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c82b" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe5210bc" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c851" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54ce63" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c8ce" = {
friendly_name = "";
transition = 1;
};
"0xa4c138693a2afad7" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c826" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe521114" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe54c86b" = {
friendly_name = "西";
transition = 1;
};
"0x540f57fffe54c82e" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe5210e3" = {
friendly_name = "";
transition = 1;
};
"0xfc4d6afffe6eb9e3" = {
friendly_name = "";
};
"0x540f57fffe5210cf" = {
friendly_name = "1";
transition = 1;
};
"0x540f57fffe54c8bb" = {
friendly_name = "2";
transition = 1;
};
"0x540f57fffe5210db" = {
friendly_name = "3";
transition = 1;
};
"0x540f57fffe54cec5" = {
friendly_name = "1";
transition = 1;
};
"0x540f57fffe520d1d" = {
friendly_name = "2";
transition = 1;
};
"0x540f57fffe54c966" = {
friendly_name = "3";
transition = 1;
};
"0x540f57fffe520ceb" = {
friendly_name = "";
transition = 1;
};
"0x540f57fffe5210cd" = {
friendly_name = "";
transition = 1;
};
};
};
};
networking.firewall.allowedTCPPorts = [ 8443 ];
services.caddy = {
enable = true;
virtualHosts = {
"raspite.coho-tet.ts.net".extraConfig = ''
reverse_proxy ${config.services.home-assistant.config.http.server_host}:${toString config.services.home-assistant.config.http.server_port}
'';
"https://raspite.coho-tet.ts.net:8080".extraConfig = ''
reverse_proxy ${config.services.zigbee2mqtt.settings.frontend.host}:${toString config.services.zigbee2mqtt.settings.frontend.port}
'';
};
};
}