ctucx.git: nixfiles

ctucx' nixfiles

commit 82da9ba902b7cf0dbc5245d13db5059057a60e01
parent 81b4b8ee2e6a0de1a4170dc1a8c362bdeb638174
Author: Leah (ctucx) <git@ctu.cx>
Date: Fri, 21 Oct 2022 16:42:19 +0200

machines/lollo/smarthome: remove modbus-relayboard, add zigbee-relay
3 files changed, 12 insertions(+), 33 deletions(-)
diff --git a/configurations/darwin/speakers.nix b/configurations/darwin/speakers.nix
@@ -4,7 +4,7 @@ let
   switchSpeakers = pkgs.writeScript "switchSpeakers.sh" ''
     #!/usr/bin/env bash
 
-    curl -d '{"accessToken": "${inputs.local-secrets.hosts.lollo.smartied.accessToken}", "type": "SwitchStateAction", "deviceName": "modbus-20", "relay": 0, "toggle": true}' http://10.0.0.1:5000
+    curl -d '{"accessToken": "${inputs.local-secrets.hosts.lollo.smartied.accessToken}", "type": "SwitchStateAction", "deviceName": "relay-pc-speakers", "toggle": true}' http://10.0.0.1:5000
   '';
 
 in {
diff --git a/machines/lollo/smarthome/smartied.nix b/machines/lollo/smarthome/smartied.nix
@@ -3,13 +3,6 @@
 let
   smartiedConfig = {
     devices = {
-      "modbus-20" = {
-        type          = "RelayBoard";
-        firstRegister = 0;
-        count         = 4;
-        address       = 20;
-      };
-
       "modbus-50" = {
         type    = "PowerMeter";
         model   = "SDM120";

@@ -78,6 +71,11 @@ let
         deviceName = "ikea_lamp_bathroom";
       };
 
+      "relay-pc-speakers" = {
+        type       = "Zigbee2MqttRelay";
+        deviceName = "relay_pc_speakers";
+      };
+
       "tradfri-co-l-bed" = {
         type       = "Zigbee2MqttRelay";
         deviceName = "ikea_control_outlet_l_bed";

@@ -126,27 +124,13 @@ let
           }];
           arrow_left_click = [{
             type       = "SwitchStateAction";
-            deviceName = "modbus-20";
-            relay      = 0;
-            toggle     = true;
-          }];
-          brightness_up_click = [{
-            type       = "SwitchStateAction";
-            deviceName = "modbus-20";
-            relay      = 1;
+            deviceName = "relay-pc-speakers";
             toggle     = true;
           }];
           brightness_down_click = [
             {
               type       = "SwitchStateAction";
-              deviceName = "modbus-20";
-              relay      = 0;
-              state      = false;
-            }
-            {
-              type       = "SwitchStateAction";
-              deviceName = "modbus-20";
-              relay      = 1;
+              deviceName = "relay-pc-speakers";
               state      = false;
             }
             {

@@ -220,11 +204,6 @@ let
                 relay   = 0;
               }
               {
-                name   = "Lights under Desk";
-                device = "modbus-20";
-                relay  = 1;
-              }
-              {
                 name   = "RGB Lamp";
                 device = "tradfri-lamp-l-rgb";
                 relay  = 0;

@@ -235,8 +214,8 @@ let
                 relay  = 0;
               }
               {
-                name   = "PC-Speaker";
-                device = "modbus-20";
+                name   = "PC-Speakers";
+                device = "relay-pc-speakers";
                 relay  = 0;
               }
             ];
diff --git a/pkgs/SpeakerDaemon/default.nix b/pkgs/SpeakerDaemon/default.nix
@@ -39,7 +39,7 @@ let
                 if (curl) {
                     curl_easy_setopt(curl, CURLOPT_WRITEDATA,   dummy_writer);
                     curl_easy_setopt(curl, CURLOPT_URL,         "http://10.0.0.1:5000");
-                    curl_easy_setopt(curl, CURLOPT_POSTFIELDS,  "{\"accessToken\": \"${inputs.local-secrets.hosts.lollo.smartied.accessToken}\", \"type\": \"SwitchStateAction\", \"deviceName\": \"modbus-20\", \"relay\": 0, \"state\": false}");
+                    curl_easy_setopt(curl, CURLOPT_POSTFIELDS,  "{\"accessToken\": \"${inputs.local-secrets.hosts.lollo.smartied.accessToken}\", \"type\": \"SwitchStateAction\", \"deviceName\": \"relay-pc-speakers\", \"state\": false}");
 
                     res = curl_easy_perform(curl);
                     if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));

@@ -61,7 +61,7 @@ let
                 if (curl) {
                     curl_easy_setopt(curl, CURLOPT_WRITEDATA,  dummy_writer);
                     curl_easy_setopt(curl, CURLOPT_URL,        "http://10.0.0.1:5000");
-                    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"accessToken\": \"${inputs.local-secrets.hosts.lollo.smartied.accessToken}\", \"type\": \"SwitchStateAction\", \"deviceName\": \"modbus-20\", \"relay\": 0, \"state\": true}");
+                    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"accessToken\": \"${inputs.local-secrets.hosts.lollo.smartied.accessToken}\", \"type\": \"SwitchStateAction\", \"deviceName\": \"relay-pc-speakers\", \"state\": true}");
 
                     res = curl_easy_perform(curl);
                     if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));