From 94d29220d8030a41b52cafe33805484645f21eb8 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 22 Nov 2020 01:58:32 +0100 Subject: [PATCH] pepe update 20.09 --- configs/pepe/hardware-configuration.nix | 11 ++-- configs/pepe/home-assistant/zigbee2mqtt.nix | 50 +++++++++++++++++-- .../home-assistant/zigbee2mqtt/buttons.nix | 8 +-- .../zigbee2mqtt/configurationHelper.nix | 20 ++++++++ .../pepe/home-assistant/zigbee2mqtt/doors.nix | 2 +- .../home-assistant/zigbee2mqtt/fyrtur.nix | 2 +- .../home-assistant/zigbee2mqtt/heater.nix | 2 +- .../pepe/home-assistant/zigbee2mqtt/leds.nix | 2 +- .../home-assistant/zigbee2mqtt/lights.nix | 2 +- .../home-assistant/zigbee2mqtt/motion.nix | 2 +- .../home-assistant/zigbee2mqtt/repeater.nix | 2 +- .../home-assistant/zigbee2mqtt/temperatur.nix | 2 +- configs/workout/packages.nix | 2 +- pkgs/light-control/default.nix | 3 +- 14 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 configs/pepe/home-assistant/zigbee2mqtt/configurationHelper.nix diff --git a/configs/pepe/hardware-configuration.nix b/configs/pepe/hardware-configuration.nix index 67329ae..d5af445 100644 --- a/configs/pepe/hardware-configuration.nix +++ b/configs/pepe/hardware-configuration.nix @@ -57,11 +57,12 @@ # lvm volume group # ---------------- - boot.initrd.luks.devices = [{ - name = "secure_vg"; - device = "/dev/sda2"; - preLVM = true; - }]; + boot.initrd.luks.devices = { + "secure_vg" = { + device = "/dev/sda2"; + preLVM = true; + }; + }; # NTFS support # ------------ diff --git a/configs/pepe/home-assistant/zigbee2mqtt.nix b/configs/pepe/home-assistant/zigbee2mqtt.nix index 50c574a..3640cd7 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt.nix @@ -2,6 +2,7 @@ imports = [ ./mqtt.nix ./zigbee2mqtt/buttons.nix + ./zigbee2mqtt/configurationHelper.nix ./zigbee2mqtt/doors.nix ./zigbee2mqtt/fyrtur.nix ./zigbee2mqtt/heater.nix @@ -9,16 +10,55 @@ ./zigbee2mqtt/lights.nix ./zigbee2mqtt/motion.nix ./zigbee2mqtt/repeater.nix - ./zigbee2mqtt/service.nix ./zigbee2mqtt/temperatur.nix ]; + #services.zigbee2mqtt = { + # enable = true; + # mqttPassword = lib.fileContents ; + # networkKey = import ; + # # only turn on for new devices, usually turn of for security reasons. + # discover = true; + #}; + + # new services.zigbee2mqtt = { enable = true; - mqttPassword = lib.fileContents ; - networkKey = import ; - # only turn on for new devices, usually turn of for security reasons. - discover = true; + config = { + + # Home Assistant integration (MQTT discovery) + homeassistant = false; + + # allow new devices to join + permit_join = true; + + # MQTT settings + mqtt = { + # MQTT base topic for zigbee2mqtt MQTT messages + base_topic = "zigbee2mqtt"; + # MQTT server URL + server = "mqtt://127.0.0.1:1883"; + # MQTT server authentication, uncomment if required: + user = "zigbee"; + password = lib.fileContents ; + }; + + # Serial settings + serial = { + port = "/dev/ttyACM0"; + # disable LED of CC2531 USB sniffer + disable_led = true; + }; + + # you own network key, + # 16 numbers between 0 and 255 + # see https://www.zigbee2mqtt.io/how_tos/how_to_secure_network.html + advanced.network_key = import ; + + # todo : devices should be defined later + #devices = cfg.devices; + + }; }; } diff --git a/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix b/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix index f10a2af..943f30c 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix @@ -9,21 +9,21 @@ let # https://www.zigbee2mqtt.io/devices/WXKG12LM.html allDevices = { - "button_1" = { + "button_a1" = { id = "0x00158d0002b04f65"; #groups = [ "living_room" ]; states.single = "input_boolean.situation_toggle"; states.hold = "input_boolean.printer_toggle"; states.double = "input_boolean.windows_up"; }; - "button_2" = { + "button_a2" = { id = "0x00158d0002b04f09"; #groups = [ "bed_room" ]; states.single = "input_boolean.situation_toggle"; states.hold = "input_boolean.printer_toggle"; states.double = "input_boolean.windows_up"; }; - "button_3" = { + "button_a3" = { id = "0x00158d0002b00e04"; #groups = [ "bed_room" ]; states.single = "input_boolean.situation_toggle"; @@ -34,7 +34,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/configurationHelper.nix b/configs/pepe/home-assistant/zigbee2mqtt/configurationHelper.nix new file mode 100644 index 0000000..a56a3d5 --- /dev/null +++ b/configs/pepe/home-assistant/zigbee2mqtt/configurationHelper.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.zigbee2mqttConfiguration; + +in { + + options.services.zigbee2mqttConfiguration = mkOption { + type = with types; attrs; + description = '' + device definitions. + ''; + }; + config = { + services.zigbee2mqtt.config.devices = cfg; + }; +} diff --git a/configs/pepe/home-assistant/zigbee2mqtt/doors.nix b/configs/pepe/home-assistant/zigbee2mqtt/doors.nix index 6332b4d..634ecbf 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/doors.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/doors.nix @@ -12,7 +12,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/fyrtur.nix b/configs/pepe/home-assistant/zigbee2mqtt/fyrtur.nix index e0536bb..a43dda1 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/fyrtur.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/fyrtur.nix @@ -13,7 +13,7 @@ let # -t "zigbee2mqtt/fyrtur1/set" -m '{"position":15}' in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/heater.nix b/configs/pepe/home-assistant/zigbee2mqtt/heater.nix index ba440a6..0e7e82e 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/heater.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/heater.nix @@ -14,7 +14,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/leds.nix b/configs/pepe/home-assistant/zigbee2mqtt/leds.nix index d331c92..c78e54a 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/leds.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/leds.nix @@ -13,7 +13,7 @@ let # -t "zigbee2mqtt/led_1/set" -m '{"state":"OFF"}' in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index bd53916..53cd8c3 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -15,7 +15,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix index f99edd1..ea1376e 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix @@ -16,7 +16,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, timeout ? 65, ... }: { name = id; value = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix b/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix index 398469b..da90113 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix @@ -10,7 +10,7 @@ let }; in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { friendly_name = name; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix index 0d1d571..c9e9862 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix @@ -15,7 +15,7 @@ let in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: + services.zigbee2mqttConfiguration = lib.mapAttrs' (name: { id, ... }: { name = id; value = { diff --git a/configs/workout/packages.nix b/configs/workout/packages.nix index 028cb1d..c0b535b 100644 --- a/configs/workout/packages.nix +++ b/configs/workout/packages.nix @@ -13,7 +13,7 @@ in { }; environment.systemPackages = with pkgs; [ - bitwig-studio + #bitwig-studio sononym-crawler # rust development environment diff --git a/pkgs/light-control/default.nix b/pkgs/light-control/default.nix index 77f0697..b0fd5f8 100644 --- a/pkgs/light-control/default.nix +++ b/pkgs/light-control/default.nix @@ -9,7 +9,8 @@ rustPlatform.buildRustPackage rec { sha256 = "1bnxvgaa58hga20ywgk728aj4wll2rhxgrdp477d2d8isifvij4v"; }; - cargoSha256 = "05mm82hdbs36p6mr4qdpip16phg28r44lbni09x48qni81dbw3wx"; + cargoSha256 = "1hhgk3mpmd143d3kfhxsaz2y5aksnwiz1bh4396hh0j7j4kqbgrw"; + #cargoSha256 = "05mm82hdbs36p6mr4qdpip16phg28r44lbni09x48qni81dbw3wx"; #verifyCargoDeps = true; nativeBuildInputs = [ cmake ];