summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2019-07-17 10:43:12 +0200
committermakefu <github@syntax-fehler.de>2019-07-17 10:43:12 +0200
commit35837fd8d6df7d3fe4797fbc478fb2ccd0581bcb (patch)
tree5d40c9ce4969d892ea37fac6982eb753495e415d /krebs/2configs
parentc38f02c4d7a09cd8a1fd50b68f08338ae54a82bb (diff)
shack/powerraw: init
Diffstat (limited to 'krebs/2configs')
-rw-r--r--krebs/2configs/shack/powerraw.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/krebs/2configs/shack/powerraw.nix b/krebs/2configs/shack/powerraw.nix
new file mode 100644
index 000000000..9b957b783
--- /dev/null
+++ b/krebs/2configs/shack/powerraw.nix
@@ -0,0 +1,41 @@
+{ config, lib, pkgs, ... }:
+# Replacement for powerraw.shack pollin box
+# Requires usb-serial device on host
+# Requires mqtt available at mqtt.shack
+# Requires hostname powerraw.shack
+let
+ pkg = pkgs.python3.pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/powermeter.git";
+ rev = "96609f0d632e0732afa768ddd7b3f8841ca37c1b";
+ sha256 = "sha256:0wfpm3ik5r081qv2crmpjwylgg2v8ximq347qh0fzq1rwv0dqbnn";
+ }) {};
+in {
+ # receive response from light.shack / standby.shack
+ networking.firewall.allowedUDPPorts = [ 11111 ];
+ users.users.powermeter = {
+ extraGroups = [ "dialout" ];
+ };
+
+ systemd.services.powermeter-serial2mqtt = {
+ description = "powerraw Serial -> mqtt";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ User = "powermeter";
+ ExecStart = "${pkg}/bin/powermeter-serial2mqtt";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+
+ systemd.services.powermeter-mqtt2socket = {
+ description = "powerraw mqtt -> raw socket 11111";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ User = "powermeter";
+ ExecStart = "${pkg}/bin/powermeter-mqtt2socket";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+}