From 2b11913dc9d962d75040c1b8a348dd1c30d5d09e Mon Sep 17 00:00:00 2001 From: magic_rb Date: Mon, 23 Oct 2023 23:30:38 +0200 Subject: [PATCH] Better pin zigbee dongle serial device Signed-off-by: magic_rb --- nixos/systems/blowhole/default.nix | 13 +++++++++++++ terranix/containers/home-assistant/job.hcl | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nixos/systems/blowhole/default.nix b/nixos/systems/blowhole/default.nix index 0437c80..bc6e91d 100644 --- a/nixos/systems/blowhole/default.nix +++ b/nixos/systems/blowhole/default.nix @@ -98,6 +98,19 @@ in system.stateVersion = "21.05"; boot.kernel.sysctl."fs.inotify.max_user_instances" = 256; + services.udev.extraRules = + let + devPath = + "/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_4c004e9c53c9eb118a9f8b4f1d69213e-if00-port0"; + zigbeeScript = pkgs.writeShellScript "zigbeeScript" '' + ${pkgs.lib.getExe' pkgs.utillinux "mount"} --bind \ + "$(${pkgs.lib.getExe' pkgs.coreutils "readlink"} -f "${devPath}")" \ + /dev/ttyZigbee + ''; + in + '' + ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea60", RUN+="${zigbeeScript}" + ''; }); }; } diff --git a/terranix/containers/home-assistant/job.hcl b/terranix/containers/home-assistant/job.hcl index e0b64f9..ea2bfad 100644 --- a/terranix/containers/home-assistant/job.hcl +++ b/terranix/containers/home-assistant/job.hcl @@ -82,7 +82,7 @@ job "home-assistant" { devices = [ { - host_path = "/dev/ttyUSB0" #"serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_4c004e9c53c9eb118a9f8b4f1d69213e-if00-port0" + host_path = "/dev/ttyZigbee" #"serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_4c004e9c53c9eb118a9f8b4f1d69213e-if00-port0" container_path = "/dev/ttyUSB0" } ]