summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs')
-rw-r--r--krebs/1systems/wolf/config.nix4
-rw-r--r--krebs/2configs/shack/mqtt.nix14
-rw-r--r--krebs/2configs/shack/powerraw.nix41
-rw-r--r--krebs/2configs/shack/s3-power.nix4
4 files changed, 61 insertions, 2 deletions
diff --git a/krebs/1systems/wolf/config.nix b/krebs/1systems/wolf/config.nix
index 0b6824e28..3cb358ca3 100644
--- a/krebs/1systems/wolf/config.nix
+++ b/krebs/1systems/wolf/config.nix
@@ -31,6 +31,8 @@ in
<stockholm/krebs/2configs/shack/muell_mail.nix>
# send mail if muell was not handled
<stockholm/krebs/2configs/shack/s3-power.nix>
+ # powerraw usb serial to mqtt and raw socket
+ <stockholm/krebs/2configs/shack/powerraw.nix>
# create samba share for anonymous usage with the laser and 3d printer pc
<stockholm/krebs/2configs/shack/share.nix>
@@ -46,6 +48,8 @@ in
<stockholm/krebs/2configs/shack/mqtt_sub.nix>
## Collect radioactive data and put into graphite
<stockholm/krebs/2configs/shack/radioactive.nix>
+ ## mqtt.shack
+ <stockholm/krebs/2configs/shack/mqtt.nix>
## Collect local statistics via collectd and send to collectd
<stockholm/krebs/2configs/stats/wolf-client.nix>
diff --git a/krebs/2configs/shack/mqtt.nix b/krebs/2configs/shack/mqtt.nix
new file mode 100644
index 000000000..5e7a1af7c
--- /dev/null
+++ b/krebs/2configs/shack/mqtt.nix
@@ -0,0 +1,14 @@
+{
+ network.firewall.allowedTCPPorts = [ 1883 ];
+ network.firewall.allowedUDPPorts = [ 1883 ];
+ services.mosquitto = {
+ enable = true;
+ host = "0.0.0.0";
+ users = {};
+ # TODO: secure that shit
+ aclExtraConf = ''
+ pattern readwrite /#
+ '';
+ allowAnonymous = true;
+ };
+}
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;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/s3-power.nix b/krebs/2configs/shack/s3-power.nix
index 2b136478d..40c42260f 100644
--- a/krebs/2configs/shack/s3-power.nix
+++ b/krebs/2configs/shack/s3-power.nix
@@ -4,8 +4,8 @@ let
pkg = pkgs.callPackage (
pkgs.fetchgit {
url = "https://git.shackspace.de/rz/s3-power";
- rev = "36df203a8fc1af02b08f60ab8d49c849b01e711f";
- sha256 = "sha256:0i05vllnfwj02sfpmg2m8hy0zq27kww9ampiaix6dl5wbyjlp51j";
+ rev = "b2b87b56bb40d714dbbecd1285566870b256aec4";
+ sha256 = "sha256:02wikwf3rgkkggwbwqisdvhlwd38w5pw011xhwvhnj114s3rynan";
}) {};
home = "/var/lib/s3-power";
cfg = toString <secrets/shack/s3-power.json>;