add heater control
This commit is contained in:
parent
dc1a70d94f
commit
671ab04997
5 changed files with 26 additions and 12 deletions
|
@ -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
|
||||
|
|
16
configs/pepe/home-assistant/heater-control.nix
Normal file
16
configs/pepe/home-assistant/heater-control.nix
Normal file
|
@ -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 ${<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):
|
|
@ -1,20 +1,15 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
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 ];
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue