diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index 9f54c70..b1dbbdb 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -6,6 +6,7 @@ in { #./home-assistant/mpd.nix #./home-assistant/timer.nix ./home-assistant/light-control.nix + ./home-assistant/heater-control.nix ./home-assistant/chaospott.nix ./home-assistant/kodi.nix ./home-assistant/mqtt.nix diff --git a/configs/pepe/home-assistant/heater-control.nix b/configs/pepe/home-assistant/heater-control.nix new file mode 100644 index 0000000..56afb3b --- /dev/null +++ b/configs/pepe/home-assistant/heater-control.nix @@ -0,0 +1,16 @@ +{ lib, pkgs, config, ... }: { + + users.users.heater-control = { }; + + systemd.services.heater-control = { + enable = true; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { User = "heater-control"; }; + script = + let myPython = pkgs.python3.withPackages (ps: with ps; [ paho-mqtt ]); + in '' + ${myPython}/bin/python ${} + ''; + }; +} diff --git a/mqtt/main.py b/mqtt/heater.py similarity index 97% rename from mqtt/main.py rename to mqtt/heater.py index 0eb132b..65541ab 100644 --- a/mqtt/main.py +++ b/mqtt/heater.py @@ -55,13 +55,13 @@ def publish_heater(client, temperature=10): def publish_heater_depending_on_scene(client): if scene == "night": - publish_heater(client, 10) + publish_heater(client, 12) elif scene == "default": publish_heater(client, 26) elif scene == "outside": - publish_heater(client, 8) + publish_heater(client, 10) else: - publish_heater(client, 8) + publish_heater(client, 10) def loop_thread(client): diff --git a/mqtt/shell.nix b/mqtt/shell.nix index 66f3f9e..97f0099 100644 --- a/mqtt/shell.nix +++ b/mqtt/shell.nix @@ -1,20 +1,15 @@ { pkgs ? import { } }: let - myPython = pkgs.python3.withPackages (python-packages: - with python-packages; [ - paho-mqtt - ]); + myPython = pkgs.python3.withPackages + (python-packages: with python-packages; [ paho-mqtt ]); startServer = pkgs.writers.writeBashBin "start-server" '' - ${myPython}/bin/python ./main.py + ${myPython}/bin/python ./heater.py ''; in pkgs.mkShell { - buildInputs = with pkgs; [ - myPython - startServer - ]; + buildInputs = with pkgs; [ myPython startServer ]; } diff --git a/shell.nix b/shell.nix index 8685f3f..03aef46 100644 --- a/shell.nix +++ b/shell.nix @@ -82,6 +82,8 @@ let pkgs.file = toString ./pkgs; assets.file = toString ./assets; + mqtt.file = toString ./mqtt; + nix-writers.git = { url = "https://cgit.krebsco.de/nix-writers/"; ref = (ops.importJson ./.nix-writers.json).rev;