From d150f472138f1d1540fcf62df57e85f5c9b110b5 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Wed, 3 Jun 2020 01:03:15 +0200 Subject: [PATCH] light-control: update to current develop branch --- configs/pepe/home-assistant/light-control.nix | 18 ++++++++---------- modules/services/light-control.nix | 4 ++-- pkgs/light-control/default.nix | 8 ++++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/configs/pepe/home-assistant/light-control.nix b/configs/pepe/home-assistant/light-control.nix index 34b0871..75f9f2b 100644 --- a/configs/pepe/home-assistant/light-control.nix +++ b/configs/pepe/home-assistant/light-control.nix @@ -31,19 +31,13 @@ key = "contact"; rooms = rooms; invert_state = true; - delay = { - secs = 90; - nanos = 0; - }; + delay = 90; }; motion = { topic, rooms }: { topic = topic; key = "occupancy"; rooms = rooms; - delay = { - secs = 60; - nanos = 0; - }; + delay = 60; }; in [ (motion { @@ -84,10 +78,11 @@ }) ]; switches = let - sonoff = { id, rooms }: { + sonoff = { id, rooms, delay ? 0 }: { topic = "stat/${id}/RESULT"; key = "POWER"; rooms = rooms; + delay = delay; command = { command = "{{state}}"; init_command = "(null)"; @@ -96,10 +91,11 @@ off = "OFF"; }; }; - light = { topic, rooms }: { + light = { topic, rooms, delay ? 0 }: { topic = topic; key = "state"; rooms = rooms; + delay = delay; command = { command = ''{"state":"{{state}}","brightness":{{brightness}}}''; topic = "${topic}/set"; @@ -119,6 +115,7 @@ (light { topic = "zigbee2mqtt/light_3"; rooms = [ "living_room" ]; + delay = 10; }) (light { topic = "zigbee2mqtt/light_4"; @@ -127,6 +124,7 @@ (light { topic = "zigbee2mqtt/light_8"; rooms = [ "bed_room" ]; + delay = 10; }) (sonoff { id = "PAL01"; diff --git a/modules/services/light-control.nix b/modules/services/light-control.nix index 2fbb19b..6a1b2ab 100644 --- a/modules/services/light-control.nix +++ b/modules/services/light-control.nix @@ -39,9 +39,9 @@ in { config = mkIf cfg.enable { systemd.services."light-control" = { wantedBy = [ "multi-user.target" ]; - environment = { RUST_LOG = "rust_iot=trace"; }; + environment = { RUST_LOG = "light_control=trace"; }; script = '' - ${pkgs.light-control}/bin/rust-iot ${lightControlConfig} + ${pkgs.light-control}/bin/light-control ${lightControlConfig} ''; }; }; diff --git a/pkgs/light-control/default.nix b/pkgs/light-control/default.nix index 6bcf971..48b01c5 100644 --- a/pkgs/light-control/default.nix +++ b/pkgs/light-control/default.nix @@ -5,8 +5,8 @@ rustPlatform.buildRustPackage rec { version = "0.1.0"; src = fetchgit { url = "https://git.ingolf-wagner.de/palo/light-control.git"; - rev = "180200b6085291834079322fc63c5220cac28e43"; - sha256 = "0dwf6dvpgrkpgaba4ayb0z6qjk8wjmp38y5viiq7hbjg5wcbr9qf"; + rev = "af6f9f78180af24f329736f04bda07cf90ab98c9"; + sha256 = "0yc5chl3pfx91rr59ngjfj0dahipjc0jkclxs2w0fg1j5aknxinc"; }; cargoSha256 = "1yzkbj36sx4vc8dsgcxahrvn33ci2ad1cpd1shcismw33k63rimh"; @@ -15,8 +15,8 @@ rustPlatform.buildRustPackage rec { buildInputs = [ mosquitto openssl cmake ]; meta = with stdenv.lib; { - description = "write me"; - homepage = "https://foo"; + description = "light control over mqtt, with scenes and room tracking"; + homepage = "https://github.com/mrVanDalo/light-control"; license = licenses.gpl3; maintainers = [ maintainers.mrVanDalo ]; platforms = platforms.all;