2023-11-14 09:01:02 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2023-11-14 23:36:43 +02:00
|
|
|
pkgs,
|
2023-11-14 09:01:02 +02:00
|
|
|
myData,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.mj.services.hass;
|
|
|
|
in {
|
|
|
|
options.mj.services.hass = with lib.types; {
|
|
|
|
enable = lib.mkEnableOption "Enable home-assistant";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
mj.services.friendlyport.ports = [
|
|
|
|
{
|
2023-11-14 23:36:43 +02:00
|
|
|
subnets = [myData.subnets.tailscale.cidr];
|
2023-11-14 09:01:02 +02:00
|
|
|
tcp = [myData.ports.hass];
|
|
|
|
}
|
2023-11-14 23:30:00 +02:00
|
|
|
{
|
|
|
|
subnets = myData.subnets.motiejus.cidrs;
|
|
|
|
tcp = [config.services.esphome.port];
|
|
|
|
}
|
2023-11-14 09:01:02 +02:00
|
|
|
];
|
|
|
|
|
2023-11-14 23:36:43 +02:00
|
|
|
environment.systemPackages = [pkgs.esphome]; # so it lands in PATH
|
|
|
|
|
2023-11-14 09:01:02 +02:00
|
|
|
services = {
|
2023-11-14 23:31:21 +02:00
|
|
|
esphome = {
|
|
|
|
enable = true;
|
|
|
|
address = "0.0.0.0";
|
|
|
|
};
|
2023-11-14 23:30:00 +02:00
|
|
|
|
2023-11-14 09:01:02 +02:00
|
|
|
home-assistant = {
|
|
|
|
enable = true;
|
|
|
|
extraComponents = [
|
|
|
|
"esphome"
|
|
|
|
"met"
|
|
|
|
"radio_browser"
|
2023-11-14 09:01:02 +02:00
|
|
|
|
|
|
|
# my stuff
|
|
|
|
"yamaha_musiccast"
|
|
|
|
"dlna_dmr"
|
2023-11-14 10:07:52 +02:00
|
|
|
"shelly"
|
2023-11-14 12:50:37 +02:00
|
|
|
"webostv"
|
2023-11-14 09:01:02 +02:00
|
|
|
];
|
|
|
|
config = {
|
|
|
|
default_config = {};
|
2023-11-14 18:29:44 +02:00
|
|
|
|
2023-11-14 09:01:02 +02:00
|
|
|
http = {
|
|
|
|
use_x_forwarded_for = true;
|
|
|
|
trusted_proxies = ["127.0.0.1"];
|
|
|
|
};
|
|
|
|
homeassistant = {
|
|
|
|
auth_providers = [
|
|
|
|
{
|
|
|
|
type = "trusted_networks";
|
2023-11-14 23:36:43 +02:00
|
|
|
trusted_networks = myData.subnets.motiejus.cidrs;
|
2023-11-14 09:01:02 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-11-14 18:29:44 +02:00
|
|
|
|
|
|
|
wake_on_lan = {};
|
2023-11-17 16:59:50 +02:00
|
|
|
|
|
|
|
# requires a restore from backup
|
|
|
|
"automation ui" = "!include automations.yaml";
|
|
|
|
"automation yaml" = [
|
2023-11-14 18:29:44 +02:00
|
|
|
{
|
|
|
|
alias = "Turn On Living Room TV with WakeOnLan";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "webostv.turn_on";
|
|
|
|
entity_id = "media_player.lg_webos_smart_tv";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "wake_on_lan.send_magic_packet";
|
|
|
|
data = {mac = "74:e6:b8:4c:fb:b7";};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2023-11-14 09:01:02 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|