Über uns
A declarative, reproducible smart-home operating system (NixOS) for people who want their home automation to be as maintainable as their infrastructure. Zigduck home automation system brings reproducibility, version control, and natural-language control to your deployable smart home.
Systeme und InfrastrukturGemessener Sternzuwachs
- in 24h
- Verlauf wird gesammelt
- in 7 days
- Verlauf wird gesammelt
- in 15 days
- Verlauf wird gesammelt
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Originalzigduck
A declarative, reproducible smart-home operating system (NixOS) for people who want their home automation to be as maintainable as their infrastructure.
Zigduck home automation system brings reproducibility, version control, and natural-language control to your deployable smart home.
Nix for configuration, Rust for blazing fast responsive async runtime.
Under the hood: zigbee2mqtt, Mosquitto, tokio/serde_json, adb and yo.
Define once, deploy forever.
🦆 Detailed project tree view
--> View project tree (with info)
zigduck/
├── flake.nix
├── README.md
├── CHANGELOG.md
├── CONTRIBUTING.md # guidelines / templates for contributions
│
├── .github/
│ └── workflows/
│ ├── ci.nix # release ci / tests
│ └── wiki.nix # docs workflow
│
│ 𝑴𝑶𝑫𝑼𝑳𝑬𝑺
├── modules/ # NixOS modules - what services run
│ ├── zigduck.nix # Main daemon
│ ├── dashboard.nix # Web dashboard / API
│ ├── tv.nix # TV control
│ ├── cards.nix # Dashboard cards
│ │
│ ├── grammar/ # Natural-language grammar
│ │ ├── lib.nix # Grammar library
│ │ ├── en/ # English
│ │ │ └── words.nix # english common words / numbers
│ │ │
│ │ └── sv/ # Swedish
│ │ ├── words.nix # swedish common words / numbers
│ │ └── automate.nix # grammar for automate script.
│ │
│ └── scripts/ # Natural-language automations
│ ├── lib.nix # Script helpers
│ │
│ ├── core/ # Core scripts
│ │ ├── automate.nix # `automate` commands
│ │ ├── chain.nix # `chain` commands
│ │ ├── if.nix # `if` commands
│ │ ├── loop.nix # `loop` commands
│ │ ├── while.nix # `while` commands
│ │ ├── wait.nix # `wait` commands
│ │ └── until.nix # `until` commands
│ │
│ ├── media/ # zigduck-tv & zigduck-epg
│ │
│ ├── misc/ # Misc voice control commands
│ │ ├── alarms.nix # full zigduck cli controller
│ │ └── timer.nix # State queries
│ │
│ └── zigbee/ # zigduck-cli
│ ├── house.nix # full zigduck cli controller
│ ├── state.nix # State queries
│ ├── countdown.nix # shutdown counter
│ └── compare.nix # compare metrics queries
│
│ 𝑶𝑷𝑻𝑰𝑶𝑵𝑺
├── options/ # NixOS options - how it's configured
│ ├── devices.nix
│ ├── rooms.nix
│ ├── presence.nix
│ ├── dashboard.nix
│ ├── tv.nix
│ ├── https.nix
│ └── zigbee/ # Coordinator, automations, scenes, dimmer, …
│
│ 𝑷𝑨𝑪𝑲𝑨𝑮𝑬𝑺
├── packages/ # Buildable artifacts
│ │
│ │ 𝒁𝑰𝑮𝑫𝑼𝑪𝑲
│ ├── zigduck/ # 🦆 Daemon (Rust) + API/dashboard binary.
│ │ └── src/
│ │ ├── lib.rs # Crate root - re-exports all modules
│ │ ├── main.rs # bin: zigduck (the daemon, 44 lines)
│ │ ├── zigduck-api.rs # bin: zigduck-api (HTTP server)
│ │ │
│ │ ├── state.rs # ZigduckState - shared application state
│ │ ├── scheduler.rs # Periodic task tickers
│ │ ├── net.rs # Network reachability probes
│ │ │
│ │ ├── domain/ # Pure data types (no logic)
│ │ │ ├── mod.rs
│ │ │ ├── automation.rs # AutomationAction, Condition, schedules
│ │ │ ├── dashboard.rs # DashboardConfig, DashboardCardConfig
│ │ │ ├── device.rs # Device
│ │ │ └── scene.rs # Scene, SceneConfig
│ │ │
│ │ ├── config/ # Config file parsing (serde)
│ │ │ ├── mod.rs # HouseConfig (root)
│ │ │ ├── dark_time.rs # DarkTimeConfig
│ │ │ ├── dimmer.rs # DimmerConfig, DimmerActions
│ │ │ ├── house_device.rs # HouseDevice, HouseControl
│ │ │ ├── hue.rs # HueConfig
│ │ │ ├── mqtt.rs # MosquittoConfig
│ │ │ ├── no_motion.rs # NoMotionConfig
│ │ │ ├── presence.rs # PresenceConfig
│ │ │ ├── simple_actions.rs # SimpleActionsConfig
│ │ │ └── tv.rs # TvConfig
│ │ │
│ │ ├── automations/ # Automation engine
│ │ │ ├── mod.rs # away_duration helper
│ │ │ ├── action.rs # execute_automation_action*, run_simple_action
│ │ │ ├── condition.rs # check_conditions, is_dark_time, time/presence
│ │ │ ├── presence.rs # execute_presence_action, presence shell
│ │ │ └── trigger.rs # execute_automations, MQTT triggers
│ │ │
│ │ ├── mqtt/ # MQTT transport
│ │ │ ├── mod.rs # mqtt_publish
│ │ │ ├── listener.rs # start_listening (event loop, reconnect)
│ │ │ └── router.rs # process_message dispatcher, perf stats
│ │ │
│ │ ├── devices/ # Device state & control
│ │ │ ├── mod.rs
│ │ │ ├── command.rs # handle_device_command (Hue/Z2M routing)
│ │ │ ├── house.rs # handle_house_device_set, control actions
│ │ │ └── state.rs # update_device_state*, get_state, refreshers
│ │ │
│ │ ├── presence/ # Presence detection
│ │ │ └── mod.rs # start_presence_probes, check_presence_transition
│ │ │
│ │ ├── motion/ # Motion tracking
│ │ │ └── mod.rs # MotionTracker, has_recent_motion_in_room
│ │ │
│ │ ├── lights/ # Light groups & control
│ │ │ └── mod.rs # room_lights_on/off, control_all_lights
│ │ │
│ │ ├── scenes/ # Scene activation
│ │ │ └── mod.rs # activate_scene, resolve_scene_name
│ │ │
│ │ ├── snapshots/ # State snapshots
│ │ │ └── mod.rs # create_snapshot, restore_snapshot
│ │ │
│ │ ├── dimmer/ # Dimmer switch handling
│ │ │ └── mod.rs # handle_room_dimmer_action, check_double_click
│ │ │
│ │ ├── hue/ # Hue Bridge client
│ │ │ └── mod.rs # HueClient, convert_to_hue_payload
│ │ │
│ │ └── tv/ # TV state tracking (ADB)
│ │ ├── mod.rs # TvProbe, check_tv_power
│ │ └── tracker.rs # start_tv_state_trackers
│ │
│ ├── zigduck-cli/ # 🦆 Command-line controller
│ ├── zigduck-tv/ # 🦆 TV control (ADB)
│ ├── zigduck-epg/ # 🦆 EPG scraper (Python)
│ └── zigduck.nix # Package aggregator
│
│ 𝑫𝑨𝑺𝑯𝑩𝑶𝑨𝑹𝑫
├── static/ # Web dashboard assets (js, html, wav, ...)
├── wiki/ # Documentation site
├── hooks/ # CI hooks
└── devShells/ # Development shells / grammar testing
Why Zigduck?
- 100% declarative & extremely flexible
- Smart Home in git. No backups needed
- 8 Automation types (including natural language)
- 7 Automation actions
- Simple configuration via Dashboard for users that don't want to write any code.
- Dashboard + Zigbee + Hue + Sync + Scenes + Android TV + EPG + Smart Chat + ...
zigduck uses smart defaults, after defining your rooms & devices --
most users don’t need to write any automations at all.
Lights, dimmers, motion sensors - it should all work as expected out of the box.
A built-in natural-language automation engine supporting hundreds of millions of possible phrases, with full device, TV and EPG control, timers, alarms, notifications, text-to-speech, and advanced logic (if not, if, while, until, when, chain, state) - all ready to use out of the box, with no grammar definitions or scripts to configure.
Much much faster than any LLM and at a much lower power consumption - plus no hallucinations!
Users can even write their automations at runtime.
EVERYTHING is configurable via NixOS options.
Use the GNOME Shell extension (seperate flake) for a handy top bar desktop widget and also an optional dashboard page is generated so user can chat with their devices/play your media right in the browser or run scene activations and device control on-the-fly.

Installation
Two installation paths
Automated USB installer (dedicated host)
- Pick me if you never heard about NixOS and don't want to hear about NixOS.
- Insert USB, boot, wait for shutdown. Eject USB, boot & you are done.
Nix flake module (recommended)
- For users already running NixOS with flakes
- Ideal for power users and custom configurations
Installing using automated USB installer
💾 Installing Using USB Stick
To Be Announced
Coming soon....
Installing using Flakes
❄️ Installing Using Flakes
1: Add zigduck as inputs in your flake.nix
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
zigduck.url = "github:quackhack-mcblindy/zigduck";
};
2: Import the module into your configuration
imports = [
zigduck.nixosModules.zigduck
];
Note: the module also requires
selfandinputsas module arguments. Pass them to yournixosSystemviaspecialArgs:
nixosSystem {
specialArgs = { inherit self inputs; };
...
}
3: Enable the services
services.zigduck = {
enable = true;
cli.enable = true;
# for security reasons, it's highly recommended to serve the dashboard over a reverse proxy (Nginx, Caddy, Traefik, etc).
dashboard = {
enable = true;
# set to false if using http (not recommended)
secure = true;
port = 13336;
openFirewall = true;
passwordFile = config.sops.secrets.dashboard.path;
};
};
Two configuration paths (initial device/room/scenes config)
- Generate your Nix device config using JS from GitHub Pages. Phone/bbrowser friendly.
- Write it yourself. (fun)
Configuration / Setup / Quick Start
📖 Full documentation: quackhack-mcblindy.github.io/zigduck
Example Usage
Just at a glance, please see the documentation for user submitted configurations.
Example usage (automations written in Emgish)
{
config,
lib,
pkgs,
...
}: {
house = {
languages = [ "en" ];
zigbee = {
# 🦆 says ⮞ coordinator configuration
coordinator = {
vendorId = "10c4";
productId = "ea60";
symlink = "zigbee"; # 🦆 says ⮞ creates a symlink to the serial port at /dev/zigbee
};
# 🦆 ⮞ clicking through scenes quickly in the dimmer room!
dimmer.doubleClickTimeout = 500;
# 🦆 says ⮞ when motion triggers the lights to turn on
motion = {
when.dark.enable = true;
trigger.lights = {
after = 14;
before = 9;
duration = 700;
transition = true;
};
};
# 🦆 says ⮞ when no motion triggers ALL lights to turn off
no.motion.trigger = {
all.lights.off = {
enable = true;
after = 90; # 🦆 says ⮞ minutes
exclude = [ ]; # 🦆 says ⮞ list of strings, devices to exclude (friendly name/alias, leaves their states unchanged)
};
};
automations = {
string.prefix = "hey do";
# 🦆 says ⮞ there are 6 different automation types
# 🦆 ⮞ + a greeting automation
greeting = {
enable = true;
awayDuration = 7200;
door = "Door Sensor Hall";
delay = 10; # 🦆 ⮞ welcome home, idiot
actions = [ "say welcome home, idiot" ];
};
# 🦆 says ⮞ 2. room action automations
room_actions = {
kitchen = {
motion_not_detected = [
# 🦆 ⮞ if the fan is consuming more than 20 watts, start a countdown to turn it off after 180 seconds, then slowly turn off the kitchen lights.
"if the fan is consuming more than twenty watts, turn off the fan in one hundred and eighty seconds, then slowly turn off the kitchen lights"
];
motion_detected = [
# 🦆 ⮞ big 20ms window - worth it here
{ type = "scene"; scene = "kitchenInstant"; }
# 🦆 ⮞ 1: turn on the lights.
# 🦆 ⮞ 2: cancel the fan shutoff countdown.
# 🦆 ⮞ 3: if my team is playing RIGHT NOW, activate the scene, and if the TV is off, start the game on TV and use TTS to announce that the game is on.
"turn off the fan in zero seconds and if the fan is off, turn it on"
"if Björklöven is playing right now, activate the Löven scene, and if the TV is off, start the live Björklöven game on TV, for fuck's sake, and say the game is starting now, idiot"
];
};
};
time_based = {
tv_scraping = {
enable = true;
description = "Scrape TV guide";
# 🦆 says ⮞ 3:30 AM every day
schedule = {
start = "03:30";
days = [ "mon" "tue" "wed" "thu" "fri" "sat" "sun" ];
};
# 🦆 says ⮞ scrape and save so the frontend can read it (from the zigduck user)
actions = [
"scrape the web for the TV guide and save it in ${zigduck.stateDir}"
];
};
};
};
};
};}
Example usage (automations written in Swedish)
{
config,
lib,
pkgs,
...
} : {
house = {
languages = [ "en" ];
zigbee = {
# 🦆says⮞ coordinator configuration
coordinator = {
vendorId = "10c4";
productId = "ea60";
symlink = "zigbee"; # 🦆 says ⮞ diz symlinkz da serial port to /dev/zigbee
};
# 🦆 ⮞ clickin' fast cyclez scnes in da dimmers room!
dimmer.doubleClickTimeout = 500;
# 🦆 says ⮞ when motion triggers lights on
motion = {
when.dark.enable = true;
trigger.lights = {
after = 14;
before = 9;
duration = 700;
transition = true;
};
};
# 🦆 says ⮞ when no motion triggers ALL lights off
no.motion.trigger = {
all.lights.off = {
enable = true;
after = 90; # 🦆 says ⮞ min
exclude = [ ]; # 🦆 says ⮞ list of strings, devices to exclude (friendly name/alias, leaves their states as-is)
};
};
automations = {
string.prefix = "yo do";
# 🦆 says ⮞ there are 6 different automation types
# 🦆 ⮞ + a greeting automation
greeting = {
enable = true;
awayDuration = 7200;
door = "Door Sensor Hall";
delay = 10; # 🦆 ⮞ welcome back home idiot
actions = [ "säg välkommen hem idiot" ];
};
# 🦆 says ⮞ 2. room action automations
room_actions = {
kitchen = {
motion_not_detected = [
# 🦆 ⮞ if fan is on and consuming power, start countdown to turn fan off. and slowly fade off lights.
"om fläkten drar mer än tjugo watt så stäng fläkten om etthundraåttio sekunder sedan släck köket långsamt"
];
motion_detected = [
# 🦆 ⮞ "big" 20ms win - worth it here
{ type = "scene"; scene = "kitchenInstant"; }
# 🦆 ⮞ 1: start lights.
# 🦆 ⮞ 2: cancel the off-countdown on fan.
# 🦆 ⮞ 3: if my team is playin' NOW activate scene & if tv is off start the game on TV and TTS dat the game is on now
"stäng fläkten om noll sekunder samt om fläkten är av så sätt på fläkten"
"om björklöven spelar just nu så aktivera scenen löven och om tvn är av så släng igång lajv björklöven för fan plus säg nu börjar match klant"
];
};
};
time_based = {
tv_scraping = {
enable = true;
description = "Scrape TV-guide";
# 🦆 says ⮞ 03:30 AM everyday
schedule = {
start = "03:30";
days = ["mon" "tue" "wed" "thu" "fri" "sat" "sun"];
};
# 🦆 says ⮞ scrape & save so frontend can read it (from zigduck user)
actions = [ "skrapa webben efter tv guiden och spara i ${zigduck.stateDir}" ];
};
};
};
};
};}
Example usage (automations written in Nix)
{
config,
lib,
pkgs,
...
} : {
house = {
zigbee = {
networkKeyFile = config.sops.secrets.z2m_network_key.path;
automations = {
mqtt_triggered = {
flash_lights = {
enable = true;
description = "Flash lights";
topic = "zigduck/effects/flash";
actions = [
{ type = "snapshot"; snapshot_name = "before_timer"; }
{ type = "scene"; scene = "max"; }
{ type = "wait"; duration = 2; }
{ type = "scene"; scene = "dark-fast"; }
{ type = "wait"; duration = 2; }
{ type = "scene"; scene = "max"; }
{ type = "wait"; duration = 2; }
{ type = "scene"; scene = "dark-fast"; }
{ type = "wait"; duration = 2; }
{ type = "scene"; scene = "max"; }
{ type = "wait"; duration = 2; }
{ type = "restore"; snapshot_name = "before_timer"; }
];
};
alarm_wakeup = {
enable = true;
description = "Time to wake up!";
topic = "zigduck/alarm/triggered";
actions = [
{ type = "mqtt"; topic = "zigduck/effects/flash"; message = " "; }
# 🦆 says ⮞ TTS time to wake up
{ type = "shell"; command = "yo say 'wakieee wakiee dags att vaknaaaaaaa'"; }
# 🦆 says ⮞ fuck up bed (neck up + feet up)
{ type = "mqtt"; topic = "zigduck/Robot Arm 3/set"; message = ''{"state":"OFF"}''; }
{ type = "mqtt"; topic = "zigduck/Robot Arm 4/set"; message = ''{"state":"OFF"}''; }
{ type = "wait"; duration = 10; }
# 🦆 says ⮞ FLASH!
{ type = "mqtt"; topic = "zigduck/effects/flash"; message = " "; }
# 🦆 ⮞ play sound on bedroom esp32 assistant
{ type = "shell"; command = "curl http://192.168.1.13/api/settings/speaker/play/ding"; }
{ type = "wait"; duration = 2; }
# 🦆 says ⮞ ping watch with a ding
{ type = "shell"; command = "curl http://192.168.1.15/api/settings/speaker/play/ding"; }
# 🦆 says ⮞ gib me a sec pls...
{ type = "wait"; duration = 10; }
# 🦆 says ⮞ roll up da blindz let da sun come in
{ type = "mqtt"; topic = "zigduck/Roller Shade/set"; message = ''{"state":"ON"}''; }
# 🦆 says ⮞ check if im up yet....
{ type = "shell"; command = ''
motion=$(jq -r '."Motion Sensor Sovrum".occupancy' /var/lib/zigduck/state.json)
# 🦆 says ⮞ if my lazy ass is still in bed, try calling the TV remote!
if [[ "$motion" == "false" ]]; then
tv --typ call
fi
''; }
];
};
};
};
};
};}
Supported Languages
For language grammar contributions , see CONTRIBUTING.md
| Language | Scripts | Voice scripts | Voice script coverage | Patterns | Phrases |
|---|---|---|---|---|---|
| 🇸🇪 Swedish | 22 | 22 | ████████████████████░ 100% |
6880 | 292198967 |
| 🇬🇧 English | 22 | 20 | ██████████████████░░ 90% |
2653 | 77536841 |
| 🇩🇪 German | 22 | 13 | ███████████░░░░░░░░░ 59% |
1472 | 2797158 |
| 🇪🇸 Spanish | 22 | 6 | █████░░░░░░░░░░░░░░░ 27% |
1153 | 786374 |
| 🇫🇷 French | 22 | 2 | █░░░░░░░░░░░░░░░░░░░ 9% |
0 | 0 |
| Total | 22 | 63 | 12158 | 373319340 |
License
This project is licensed under the terms of the MIT license.
See the LICENSE file in the repository for full details.
Contributions are welcomed.
Ähnliche Projekte entdecken
Wird geladen…