about summary refs log tree commit diff
path: root/nixos/modules/services/home-automation
diff options
context:
space:
mode:
authorRyan Horiguchi <ryan.horiguchi@gmail.com>2024-01-26 19:31:54 +0100
committerRyan Horiguchi <ryan.horiguchi@gmail.com>2024-01-26 19:39:49 +0100
commit17243e6a84f3efe2b2b0d8d6eea9de16baff5046 (patch)
tree4eec9d18a5d969aabe2b8c860b3c784eb2319fa5 /nixos/modules/services/home-automation
parent1704052d67a93984ea2836455e282b2df36b7711 (diff)
downloadnixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar.gz
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar.bz2
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar.lz
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar.xz
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.tar.zst
nixlib-17243e6a84f3efe2b2b0d8d6eea9de16baff5046.zip
nixos/esphome: add option to use ping to check online status of devices
Diffstat (limited to 'nixos/modules/services/home-automation')
-rw-r--r--nixos/modules/services/home-automation/esphome.nix12
1 files changed, 10 insertions, 2 deletions
diff --git a/nixos/modules/services/home-automation/esphome.nix b/nixos/modules/services/home-automation/esphome.nix
index 4fc007a97683..3c0fd8aed08a 100644
--- a/nixos/modules/services/home-automation/esphome.nix
+++ b/nixos/modules/services/home-automation/esphome.nix
@@ -63,6 +63,12 @@ in
       '';
       type = types.listOf types.str;
     };
+
+    usePing = mkOption {
+      default = false;
+      type = types.bool;
+      description = lib.mdDoc "Use ping to check online status of devices instead of mDNS";
+    };
   };
 
   config = mkIf cfg.enable {
@@ -74,8 +80,10 @@ in
       wantedBy = ["multi-user.target"];
       path = [cfg.package];
 
-      # platformio fails to determine the home directory when using DynamicUser
-      environment.PLATFORMIO_CORE_DIR = "${stateDir}/.platformio";
+      environment = {
+        # platformio fails to determine the home directory when using DynamicUser
+        PLATFORMIO_CORE_DIR = "${stateDir}/.platformio";
+      } // lib.optionalAttrs cfg.usePing { ESPHOME_DASHBOARD_USE_PING = "true"; };
 
       serviceConfig = {
         ExecStart = "${cfg.package}/bin/esphome dashboard ${esphomeParams} ${stateDir}";