1
0
Fork 0
dotfiles/system/nixos/temper.nix

25 lines
722 B
Nix
Raw Permalink Normal View History

2024-09-17 07:02:38 +00:00
{ pkgs, ... }:
{
systemd.services.temper-to-home-assistant =
let
script = pkgs.writeScriptBin "temper-to-ha-mqtt" ''
#! ${pkgs.runtimeShell} -e
temp=$(${pkgs.python312Packages.temperusb}/bin/temper-poll -c -s 0)
${pkgs.mosquitto}/bin/mosquitto_pub -h 10.0.0.230 -m "$temp" -t hadata/temper/serverraum -u mqtt_bridge -P verySecurePassword
'';
in
{
description = "Send current temperature reading to HA using MQTT";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
startAt = "*-*-* *:*:00";
serviceConfig = {
Type = "oneshot";
ExecStart = "${script}/bin/temper-to-ha-mqtt";
};
};
}