feat(ntfy): wire Home Assistant rest_command publisher
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -31,27 +31,44 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkMerge [
|
||||||
services.ntfy-sh = {
|
(lib.mkIf cfg.enable {
|
||||||
enable = true;
|
services.ntfy-sh = {
|
||||||
settings = {
|
enable = true;
|
||||||
base-url = "http://${hostName}:${toString cfg.port}";
|
settings = {
|
||||||
listen-http = ":${toString cfg.port}";
|
base-url = "http://${hostName}:${toString cfg.port}";
|
||||||
auth-file = "/var/lib/ntfy-sh/user.db";
|
listen-http = ":${toString cfg.port}";
|
||||||
auth-default-access = "deny-all";
|
auth-file = "/var/lib/ntfy-sh/user.db";
|
||||||
|
auth-default-access = "deny-all";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ cfg.port ];
|
networking.firewall.allowedTCPPorts = [ cfg.port ];
|
||||||
|
|
||||||
my.homepage.services = [
|
my.homepage.services = [
|
||||||
{
|
{
|
||||||
group = "Services";
|
group = "Services";
|
||||||
name = "ntfy";
|
name = "ntfy";
|
||||||
description = "Push notifications";
|
description = "Push notifications";
|
||||||
href = "http://${hostName}:${toString cfg.port}";
|
href = "http://${hostName}:${toString cfg.port}";
|
||||||
icon = "ntfy.svg";
|
icon = "ntfy.svg";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
})
|
||||||
|
|
||||||
|
(lib.mkIf (cfg.enable && cfg.haIntegration.enable && config.my.profiles.home-assistant.enable) {
|
||||||
|
services.home-assistant.config.rest_command.ntfy_send = {
|
||||||
|
url = "http://${hostName}:${toString cfg.port}/${cfg.topic}";
|
||||||
|
method = "POST";
|
||||||
|
payload = "{{ message }}";
|
||||||
|
content_type = "text/plain";
|
||||||
|
username = "homeassistant";
|
||||||
|
password = "!secret ntfy_password";
|
||||||
|
headers = {
|
||||||
|
Title = "{{ title | default('Home Assistant') }}";
|
||||||
|
Priority = "{{ priority | default('default') }}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user