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/mpd.nix
|
||||||
#./home-assistant/timer.nix
|
#./home-assistant/timer.nix
|
||||||
./home-assistant/light-control.nix
|
./home-assistant/light-control.nix
|
||||||
|
./home-assistant/heater-control.nix
|
||||||
./home-assistant/chaospott.nix
|
./home-assistant/chaospott.nix
|
||||||
./home-assistant/kodi.nix
|
./home-assistant/kodi.nix
|
||||||
./home-assistant/mqtt.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):
|
def publish_heater_depending_on_scene(client):
|
||||||
if scene == "night":
|
if scene == "night":
|
||||||
publish_heater(client, 10)
|
publish_heater(client, 12)
|
||||||
elif scene == "default":
|
elif scene == "default":
|
||||||
publish_heater(client, 26)
|
publish_heater(client, 26)
|
||||||
elif scene == "outside":
|
elif scene == "outside":
|
||||||
publish_heater(client, 8)
|
publish_heater(client, 10)
|
||||||
else:
|
else:
|
||||||
publish_heater(client, 8)
|
publish_heater(client, 10)
|
||||||
|
|
||||||
|
|
||||||
def loop_thread(client):
|
def loop_thread(client):
|
|
@ -1,20 +1,15 @@
|
||||||
{ pkgs ? import <nixpkgs> { } }:
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
let
|
let
|
||||||
|
|
||||||
myPython = pkgs.python3.withPackages (python-packages:
|
myPython = pkgs.python3.withPackages
|
||||||
with python-packages; [
|
(python-packages: with python-packages; [ paho-mqtt ]);
|
||||||
paho-mqtt
|
|
||||||
]);
|
|
||||||
|
|
||||||
startServer = pkgs.writers.writeBashBin "start-server" ''
|
startServer = pkgs.writers.writeBashBin "start-server" ''
|
||||||
${myPython}/bin/python ./main.py
|
${myPython}/bin/python ./heater.py
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in pkgs.mkShell {
|
in pkgs.mkShell {
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [ myPython startServer ];
|
||||||
myPython
|
|
||||||
startServer
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,8 @@ let
|
||||||
pkgs.file = toString ./pkgs;
|
pkgs.file = toString ./pkgs;
|
||||||
assets.file = toString ./assets;
|
assets.file = toString ./assets;
|
||||||
|
|
||||||
|
mqtt.file = toString ./mqtt;
|
||||||
|
|
||||||
nix-writers.git = {
|
nix-writers.git = {
|
||||||
url = "https://cgit.krebsco.de/nix-writers/";
|
url = "https://cgit.krebsco.de/nix-writers/";
|
||||||
ref = (ops.importJson ./.nix-writers.json).rev;
|
ref = (ops.importJson ./.nix-writers.json).rev;
|
||||||
|
|
Loading…
Reference in a new issue