KNX Gateway Automation
v1.0.1Create, edit, validate, and manage KNX Gateway automation workflows and scenes via REST API. Covers device listing, device control, scene CRUD/execution, wor...
Like a lobster shell, security has layers — review code before you run it.
YCZNWL KNX Gateway Automation Agent Skill
Connection
| Parameter | Default | Description |
|---|---|---|
| Base URL | http://ycznwl.local/api/v1 | Default mDNS address — use as-is unless the user provides their own gateway address or IP |
| Auth | Authorization: Bearer <token> | See token instructions below |
Getting an API Token
- Open the KNX Gateway web UI
- Click your avatar (top-right) → Get API Token
- Copy the token
Safe token handling:
- Store the token in your platform's secret store or a local environment variable (
export KNX_TOKEN=...) — never paste it directly into a chat conversation, as conversation logs may be persisted - Reference it in requests via the environment variable, not inline
- Never hardcode the token in shared scripts or commit it to version control
Reference Documents
This skill is organized into progressive reference files. Read them in order when you need detailed information:
| File | Content |
|---|---|
| ref/devices.md | Device types, subtypes, capabilities, actions, params |
| ref/scenes.md | Scene data model, actions structure, KNX binding, execution behavior |
| ref/triggers.md | Trigger types and their exact configuration |
| ref/nodes.md | Node types, subtypes (incl. scene_exec), config structs, validation rules |
| ref/api.md | Complete REST API endpoint reference (devices, scenes, automation) |
| ref/examples.md | Realistic, validated workflow examples (incl. scene-based) |
Quick Start — Agent Workflow
Creating a new scene
- Discover devices:
GET /devices→ noteuuid,name,type,capabilities - Build actions array: Each action targets a device:
{ "id": "a1", "device_uuid": "light-uuid", "device_name": "Living Room Light", "action": "turn_off", "params": {}, "delay": 0 }action+paramsmust match the device's capability (see ref/devices.md)delayis in milliseconds (0 = immediate, 500 = 0.5s delay before this action)idis a unique string per action (e.g."a1","a2")
- Create:
POST /sceneswithname,actions, optionalicon,color,description,enabled - Test:
POST /scenes/:uuid/execute→ verify execution result
Editing an existing scene
- Get current state:
GET /scenes/:uuid - Update:
PUT /scenes/:uuidwith partial fields:
Only include fields you want to change. The{ "name": "Updated Scene Name", "actions": [ ... ], "enabled": true }actionsarray replaces the existing one entirely. - Test:
POST /scenes/:uuid/execute
Managing scenes
| Operation | Method | Endpoint |
|---|---|---|
| List all scenes | GET | /scenes (optional ?enabled=true) |
| Get scene | GET | /scenes/:uuid |
| Create | POST | /scenes |
| Update | PUT | /scenes/:uuid |
| Delete | DELETE | /scenes/:uuid |
| Execute | POST | /scenes/:uuid/execute |
| Toggle enabled | POST | /scenes/:uuid/toggle |
| Reorder | PUT | /scenes/sort |
| View logs | GET | /scenes/logs?scene_uuid=xxx |
See ref/api.md for full request/response details.
Using scenes in automations
Scenes can be triggered from automation workflows in two ways:
scene_execnode (recommended):{ "node_subtype": "scene_exec", "config": { "scene_uuid": "..." } }device_controlnode with virtual device:{ "config": { "device_uuid": "scene-<scene_uuid>", "action": "activate_scene" } }
See ref/examples.md Examples 7 & 8 for complete workflow payloads.
Creating a new automation
- Discover devices:
GET /devices→ noteuuid,type,sub_type,capabilities - Discover scenes (if needed):
GET /scenes→ note sceneuuidforscene_execnodes - Build import JSON using the format documented in ref/api.md section "Import"
- Import:
POST /automation/workflows/import→ returns new workflow with server-generated UUIDs - Validate:
POST /automation/workflows/:uuid/validate - Enable:
POST /automation/workflows/:uuid/enable
Editing an existing automation
- Get current state:
GET /automation/workflows/:uuid - Modify triggers/nodes/edges — keep existing UUIDs for unchanged elements, generate new UUIDs for additions
- Save:
PUT /automation/workflows/:uuid - Validate:
POST /automation/workflows/:uuid/validate
Security Notes
- Imported workflows: Always inspect imported workflow JSON before enabling. Look for
unexpected
http_requestnodes pointing to external URLs,mqtt_publishnodes targeting remote brokers, orwebhooktriggers that expose the gateway to the internet. Only import workflows from sources you trust. - External connections:
http_request,mqtt_publish, andnotify (email)nodes transmit data outside the local network. Prefer locally-scoped workflows unless external connectivity is intentional and the endpoint is verified. - Webhook triggers: Exposing a webhook URL makes the gateway reachable from external networks. Use only when network exposure is deliberate and the token is kept secret.
- Base URL: Verify the gateway address resolves to your local network before running any control commands.
Critical Rules
-
Device actions are NOT generic "set" or "toggle". Each device type has specific actions. Always check ref/devices.md for the exact action name and required params for each device type/subtype combination.
-
UUIDs on import are placeholders. The server remaps ALL UUIDs. Use simple placeholder values like
"t1","n1","e1"— the server will replace them with real UUIDs. -
Imported workflows start in
draft+disabledstate. Always validate then enable after import. -
Node configs are strictly typed. A
device_controlnode with wrong params will fail at execution time even if import succeeds. Always match action + params to the device's capability. -
Edge handle names: Triggers use
source_handle: "output". Condition/logic nodes use"true"and"false"as source_handle. Action, delay, and transform nodes usesource_handle: "output". All target handles are"input". -
source_typein edges: Use"trigger"when source is a trigger UUID, use"node"when source is any node UUID.
Common Pitfalls (MUST READ)
Pitfall 1: node_subtype vs sub_type — DIFFERENT fields!
- Devices use
sub_type(e.g."sub_type": "light_dimmer") - Nodes use
node_subtype(e.g."node_subtype": "device_control") - If you use
sub_typein a node definition, it will be silently ignored. The node will have an empty subtype and validation will report "未知节点类型 action:" (unknown node type). Always usenode_subtypefor nodes.
Pitfall 2: Validate response — check errors array, NOT just valid
The /validate endpoint may return "valid": true even when errors is non-empty.
Node config errors (e.g. missing subtype, wrong params) appear in errors but do not
flip valid to false. Always check the errors array is null or empty.
✗ BAD: if response.data.valid == true → proceed
✓ GOOD: if response.data.valid == true AND response.data.errors is null/empty → proceed
Pitfall 3: After import, verify the response data
Always inspect the import response body. Confirm that:
node_subtypefields are non-empty for action nodessource_handle/target_handlehave the expected valuesconfigobjects contain the correct action/params
If any field is missing or empty, the import JSON had a wrong field name.
System Limits
| Limit | Value |
|---|---|
| Max workflows | 200 |
| Max nodes per flow | 50 |
| Max edges per flow | 200 |
| Max triggers per workflow | 5 |
| Timeout range | 5–3600 seconds |
| Max parallel | 10 |
| Max retry count | 5 |
| Max name length | 128 chars |
| Max description length | 1024 chars |
Retrieve current limits: GET /automation/limits
Comments
Loading comments...
