{"id":"9561f3fb-f843-418c-80b3-7cc3086edaf9","entityType":"agent","slug":"clawhub-13681882136-kami-fall-detection","name":"Kami Fall Detection","canonicalUrl":"https://www.xpersona.co/agent/clawhub-13681882136-kami-fall-detection","canonicalPath":"/agent/clawhub-13681882136-kami-fall-detection","generatedAt":"2026-10-11T07:40:12.056Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":null},"description":"Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.","descriptionLabel":"Source description","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.","installCommand":"clawhub skill install s170wja1qf8kmkzj5brvhsj1r185a522:kami-fall-detection","sourceUrl":"https://clawhub.ai/13681882136/kami-fall-detection","homepage":"https://clawhub.ai/13681882136/skills/kami-fall-detection","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/13681882136/kami-fall-detection","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/13681882136/skills/kami-fall-detection","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":61,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Kami Fall Detection technical dossier on Xpersona with agent coverage, OPENCLEW support, and live trust metadata."},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":null},"stars":null,"forks":null,"downloads":1147,"packageName":null,"latestVersion":"1.1.2","tractionLabel":"1.1K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T05:25:22.161Z","emptyReason":null},"lastUpdatedAt":"2026-10-11T05:25:22.175Z","lastCrawledAt":"2026-10-11T05:25:22.161Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-12T05:25:22.161Z","lastVerifiedAt":null,"highlights":[{"version":"1.1.2","createdAt":"2026-06-10T06:31:38.896Z","changelog":"Version 1.1.2 - Updated documentation to instruct users to always show the RTSP URL template table during camera configuration. - No changes to core logic or functionality; only SKILL.md documentation was modified.","fileCount":11,"zipByteSize":34937},{"version":"1.1.0","createdAt":"2026-06-10T01:28:03.318Z","changelog":"- Added a table of common RTSP URL patterns for major camera brands to assist with camera setup. - Removed redundant file skill-card.md. - Various minor updates in config files and notification script. - No changes to core detection or notification logic.","fileCount":11,"zipByteSize":34815},{"version":"1.0.9","createdAt":"2026-06-09T09:43:06.819Z","changelog":"Version 1.0.9 - Updated notification modules for Feishu, Telegram, and Discord. - Adjusted config options and improved notifier setup/handling. - Removed obsolete skill-card.md file. - Documentation updates in SKILL.md for clarity and latest changes.","fileCount":11,"zipByteSize":32908},{"version":"1.0.8","createdAt":"2026-05-29T03:18:53.104Z","changelog":"**Multi-camera support added with new configuration approach.** - Now supports monitoring multiple RTSP cameras; all camera streams are configured via a `cameras` array in `config.json`. - Each camera can be assigned a unique `name` (required for multi-camera setups) for easier identification in notifications and logs. - Deprecated single `rtsp_url` field; all streams must be listed under the `cameras` array. - Alarms and notifications now include the `camera_name` field for clear source identification. - Skill setup, agent guidance, and documentation updated to reflect new configuration and usage patterns. - Removed deprecated `skill-card.md` file.","fileCount":11,"zipByteSize":31559},{"version":"1.0.7","createdAt":"2026-05-27T07:21:12.786Z","changelog":"**Added multi-channel alarm notifications and updated configuration options.** - Added support for Telegram and Discord notifications alongside existing Feishu channel - Introduced new config fields for Telegram and Discord (bot tokens, chat/channel IDs, webhook URLs) - Updated agent setup instructions and config management to optionally handle multiple notification channels - Improved documentation: streamlined quick-start, clarified privacy & agent workflow, detailed cloud vs. local data handling - Dropped obsolete file: logs/last-check-state.json - Other minor documentation and setup improvements","fileCount":11,"zipByteSize":27889},{"version":"1.0.6","createdAt":"2026-05-13T07:00:40.672Z","changelog":"- Updated skill name from kami-fall-detection-cloud to kami-fall-detection. - Bumped version number to 1.0.6. - No functional or behavior changes; documentation (SKILL.md) updated only.","fileCount":9,"zipByteSize":18730},{"version":"1.0.5","createdAt":"2026-05-13T06:22:57.466Z","changelog":"- Updated version to 1.0.5 and revised metadata for clarity and compatibility. - Added displayName field and improved the description for better discoverability. - No functional or code logic changes; documentation updates only. - The setup, configuration, and agent instructions remain the same.","fileCount":9,"zipByteSize":18729},{"version":"1.0.4","createdAt":"2026-05-13T05:47:26.830Z","changelog":"- Added a notice about new users receiving 200 free credits when registering at the KamiClaw portal. - No functional changes to the skill itself; documentation update only. - No changes to configuration, installation, usage, or API interfaces.","fileCount":9,"zipByteSize":18728}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s170wja1qf8kmkzj5brvhsj1r185a522:kami-fall-detection","setupComplexity":"low","setupSteps":["Install using `clawhub skill install s170wja1qf8kmkzj5brvhsj1r185a522:kami-fall-detection` in an isolated environment before connecting it to live workloads.","No published capability contract is available yet, so validate auth and request/response behavior manually.","Review the upstream CLAWHUB listing at https://clawhub.ai/13681882136/kami-fall-detection before using production credentials."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-11T07:40:12.052Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-13681882136-kami-fall-detection/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":null},"readme":"Skill: Kami Fall Detection\n\nOwner: 13681882136\n\nSummary: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\n\nTags: latest:1.1.2\n\nVersion history:\n\nv1.1.2 | 2026-06-10T06:31:38.896Z | auto\n\nVersion 1.1.2\n\n- Updated documentation to instruct users to always show the RTSP URL template table during camera configuration.\n- No changes to core logic or functionality; only SKILL.md documentation was modified.\n\nv1.1.0 | 2026-06-10T01:28:03.318Z | auto\n\n- Added a table of common RTSP URL patterns for major camera brands to assist with camera setup.\n- Removed redundant file skill-card.md.\n- Various minor updates in config files and notification script.\n- No changes to core detection or notification logic.\n\nv1.0.9 | 2026-06-09T09:43:06.819Z | auto\n\nVersion 1.0.9\n\n- Updated notification modules for Feishu, Telegram, and Discord.\n- Adjusted config options and improved notifier setup/handling.\n- Removed obsolete skill-card.md file.\n- Documentation updates in SKILL.md for clarity and latest changes.\n\nv1.0.8 | 2026-05-29T03:18:53.104Z | auto\n\n**Multi-camera support added with new configuration approach.**\n\n- Now supports monitoring multiple RTSP cameras; all camera streams are configured via a `cameras` array in `config.json`.\n- Each camera can be assigned a unique `name` (required for multi-camera setups) for easier identification in notifications and logs.\n- Deprecated single `rtsp_url` field; all streams must be listed under the `cameras` array.\n- Alarms and notifications now include the `camera_name` field for clear source identification.\n- Skill setup, agent guidance, and documentation updated to reflect new configuration and usage patterns.\n- Removed deprecated `skill-card.md` file.\n\nv1.0.7 | 2026-05-27T07:21:12.786Z | auto\n\n**Added multi-channel alarm notifications and updated configuration options.**\n\n- Added support for Telegram and Discord notifications alongside existing Feishu channel\n- Introduced new config fields for Telegram and Discord (bot tokens, chat/channel IDs, webhook URLs)\n- Updated agent setup instructions and config management to optionally handle multiple notification channels\n- Improved documentation: streamlined quick-start, clarified privacy & agent workflow, detailed cloud vs. local data handling\n- Dropped obsolete file: logs/last-check-state.json\n- Other minor documentation and setup improvements\n\nv1.0.6 | 2026-05-13T07:00:40.672Z | auto\n\n- Updated skill name from kami-fall-detection-cloud to kami-fall-detection.\n- Bumped version number to 1.0.6.\n- No functional or behavior changes; documentation (SKILL.md) updated only.\n\nv1.0.5 | 2026-05-13T06:22:57.466Z | auto\n\n- Updated version to 1.0.5 and revised metadata for clarity and compatibility.\n- Added displayName field and improved the description for better discoverability.\n- No functional or code logic changes; documentation updates only.\n- The setup, configuration, and agent instructions remain the same.\n\nv1.0.4 | 2026-05-13T05:47:26.830Z | auto\n\n- Added a notice about new users receiving 200 free credits when registering at the KamiClaw portal.\n- No functional changes to the skill itself; documentation update only.\n- No changes to configuration, installation, usage, or API interfaces.\n\nv1.0.2 | 2026-05-13T05:04:53.058Z | auto\n\n- Added persistent state tracking by introducing logs/last-check-state.json.\n- Updated fall_detect_cloud_skill.py to support storing or referencing the last check state.\n- No changes to the user interface or configuration process.\n- Logging and monitoring improvements to enhance reliability and support troubleshooting.\n\nv1.0.1 | 2026-05-11T05:34:33.350Z | auto\n\n- Bug fix release with internal improvements.\n- Minor updates to fall_detect_cloud_skill.py for stability or correctness.\n- No changes to user-facing features or configuration.\n\nv1.0.0 | 2026-05-11T05:20:53.236Z | auto\n\n**Cloud-based RTSP fall detection skill with API-key configuration, Feishu notifications, and auto-reconnect.**\n\n- Adds KamiClaw cloud API support: no local GPU required, all inference done server-side.\n- New agent-guided configuration flow: agent must prompt user for API key, RTSP URL, and optional Feishu webhook, and auto-save all values in config.json.\n- Supports Feishu group bot notifications for fall alarms (optional, with guided setup).\n- Auto-reconnects to RTSP stream if connection drops.\n- Flexible configuration via CLI, environment variables, or config.json (with agent always managing config.json).\n- Structured JSON logging for alarms, transitions, and analysis with logs directory.\n\nArchive index:\n\nArchive v1.1.2: 11 files, 34937 bytes\n\nFiles: config.json (398b), discord_notifier.py (20800b), fall_detect_cloud_skill.py (28953b), feishu_notifier.py (21011b), README.md (13861b), requirements.txt (61b), setup.sh (4166b), skill-card.md (2887b), SKILL.md (11093b), telegram_notifier.py (9526b), _meta.json (138b)\n\nFile v1.1.2:SKILL.md\n\n---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.9\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `cameras` | `[]` | **Required.** Array of `{name, rtsp_url}` entries. Single entry: `name` optional, defaults to `\"default\"`. Two or more entries: every entry must have a unique non-empty `name`. |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL for alarm notifications |\n| `telegram_bot_token` | `\"\"` | Telegram bot token for alarm notifications |\n| `telegram_chat_id` | `\"\"` | Telegram chat ID (user or group) |\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\n\n### Camera Setup\n\nAll cameras are declared in the `cameras` array. Each entry has just two fields: `name` and `rtsp_url`.\n\n**Single camera (one entry).** `name` is optional — if omitted it defaults to `\"default\"`:\n\n```json\n{\n  \"cameras\": [\n    { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" }\n  ]\n}\n```\n\n**Multiple cameras (two or more entries).** Every entry **must** have a unique, non-empty `name`. Strongly recommended: pick a meaningful location label so the operator immediately knows which camera triggered.\n\n```json\n{\n  \"cameras\": [\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\n  ]\n}\n```\n\n- `name` is shown in every Feishu / Telegram / Discord push and tags every log line.\n- One worker thread per camera; a single stream loss does not affect the others.\n- The skill refuses to start if `cameras` is empty, or if multiple entries are missing/sharing a `name`.\n\n### Common Brand RTSP Templates\n\n**MUST show this table to the user** when configuring cameras, so they can pick a URL pattern based on their brand:\n\n| Brand key | Brand | URL pattern |\n|-----------|-------|-------------|\n| `hikvision` | Hikvision | `rtsp://{user}:{pwd}@{ip}:554/Streaming/Channels/101` (`101`=ch1 main, `102`=ch1 sub) |\n| `dahua` | Dahua | `rtsp://{user}:{pwd}@{ip}:554/cam/realmonitor?channel=1&subtype=0` (`subtype=0` main, `1` sub) |\n| `tplink` | TP-Link | `rtsp://{user}:{pwd}@{ip}:554/stream1` (`stream1` main, `stream2` sub) |\n| `ezviz` | EZVIZ | `rtsp://admin:{verify_code}@{ip}:554/H264/ch1/main/av_stream` |\n| `uniview` | Uniview | `rtsp://{user}:{pwd}@{ip}:554/media/video1` |\n| `reolink` | Reolink | `rtsp://{user}:{pwd}@{ip}:554/h264Preview_01_main` |\n\n### Advanced Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `3.0` | Seconds buffered before motion trigger |\n| `post_seconds` | `3.0` | Seconds collected after motion trigger |\n\n---\n\n## Notification Setup\n\nTell the agent which channels you want. They'll guide you through setup.\n\n### Quick Guide\n\n| Channel | Push Only | Two-Way Capable |\n|---------|-----------|----------------|\n| **Feishu** | Webhook URL | Group Bot (same config) |\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\n| **Discord** | Webhook URL | Bot Token + Channel ID |\n\n> 💡 **Discord:** Bot token + channel ID gives you full two-way capability. Webhook is simpler for push-only.\n\n> 💡 **Need help?** Ask OpenClaw for guidance.\n\n---\n\n## Running\n\n```bash\n# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or override the API key on the CLI\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --api_key sk_live_xxxxxxxx\n```\n\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\n\nThe skill runs continuously. It does NOT stop after an alarm — it resets and keeps monitoring.\n\n---\n\n## Output Format\n\n**Fall detected:**\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"camera_name\": \"front_door\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Normal exit (run time reached):**\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Normal exit (run time reached) |\n| `1`  | Error (invalid API key, missing config, etc.) |\n\n---\n\n## Advanced: How It Works\n\n<details>\n<summary>Click to expand technical details</summary>\n\n### Stage 1 — Change Detection (Local, CPU-only)\n- Lightweight frame-differencing on 128×128 grayscale\n- Maintains rolling pre-buffer (default 4s)\n- Triggers Stage 2 on significant temporal change\n\n### Stage 2 — Cloud Analysis\n- Collects post-transition frames (default 4s)\n- Resizes clip to 360×360, writes to temp file\n- Sends to KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`)\n- On fall detected: outputs JSON alarm, optionally saves clip, resets to Stage 1\n\n### Auto-Reconnect\n- If RTSP stream drops, retries connection every 5 seconds\n- Resumes monitoring seamlessly after reconnection\n\n</details>\n\n---\n\n## Agent Setup Flow\n\n**For agents configuring this skill:**\n\n1. Read `config.json` — check whether `api_key` is set and whether `cameras` is a non-empty array.\n2. If `api_key` is empty, ask the user: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill.kamihome.com\".\n3. If `cameras` is empty, ask: \"How many RTSP cameras do you want to monitor?\"\n   - **One camera:** ask only for the RTSP URL. Write `[ { \"rtsp_url\": \"...\" } ]` — `name` will default to `\"default\"` automatically.\n   - **Two or more cameras:** for each one, ask both the RTSP URL **and** a unique short location label (e.g. `front_door`, `backyard`, `living_room`). Strongly recommend the user picks meaningful labels — they are shown in every alarm notification. Write `[ { \"name\": \"front_door\", \"rtsp_url\": \"...\" }, { \"name\": \"backyard\", \"rtsp_url\": \"...\" } ]`.\n4. Ask: \"Save alarm video clips? (yes/no, default: yes)\" → set `save_alarm_clips`.\n5. Ask about each notification channel (Feishu / Telegram / Discord) — guide setup if yes.\n6. Write all values to `config.json` (read existing, merge, write back).\n7. Optionally run `python fall_detect_cloud_skill.py --list_cameras` to confirm the resolved camera list.\n8. Run the skill.\n\n**Never run with an empty `api_key`. Never run with `cameras` empty. When the user has multiple cameras, never accept missing/duplicate names — re-prompt until each camera has a unique label. Never ask the user to manually edit config.json.**\n\n---\n\n## Troubleshooting & Analysis\n\n### Log Files\n\n| File | Content |\n|------|---------|\n| `logs/app.log` | Application log (rotates daily, keeps 30 days) |\n| `logs/alarms.jsonl` | All alarm events + clip analysis results |\n| `logs/transitions.jsonl` | All motion trigger events |\n\n### Quick Analysis Commands\n\n```bash\n# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\"\n```\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| No alarms detected | Check RTSP stream is active; verify camera angle covers monitoring area |\n| Too many false alarms | Adjust camera position; reduce motion sensitivity area |\n| API errors | Verify API key is valid; check internet connection |\n| Stream disconnects | Check network stability; camera may need reboot |\n\n---\n\n## File Structure\n\n```\nkami-fall-detection/\n├── SKILL.md                      # Documentation\n├── config.json                   # Configuration (auto-managed by agent)\n├── fall_detect_cloud_skill.py    # Production entry point\n├── setup.sh                      # Installer\n└── requirements.txt              # Dependencies\n```\n\nFile v1.1.2:README.md\n\n# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [Cameras](#cameras)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- **Python 3.8+**\r\n- **OS**: Linux (primary), macOS / Windows supported for development\r\n- **KamiClaw API key** — register at <https://kamiclaw-skill.kamihome.com>\r\n- **RTSP camera** or local video file for input\r\n\r\nPython dependencies (installed via `setup.sh`):\r\n\r\n- `requests>=2.28.0`\r\n- `opencv-python-headless>=4.7.0`\r\n- `numpy>=1.23.0`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nbash setup.sh\r\n```\r\n\r\nThis will:\r\n\r\n1. Detect system Python (`python3` → `python` → auto-install via `apt`)\r\n2. Create a `.venv/` virtual environment in the project root\r\n3. Install `requests`, `opencv-python-headless`, and `numpy`\r\n\r\nNo GPU or heavy ML libraries are required.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nAll runtime parameters live in [`config.json`](./config.json). CLI arguments and environment variables override config values with the following priority:\r\n\r\n> **CLI args > environment variables > `config.json` > built-in defaults**\r\n\r\n### KamiClaw API Key\r\n\r\n1. Register at <https://kamiclaw-skill.kamihome.com>.\r\n2. Copy your API key from the dashboard (format: `sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`).\r\n3. Set it via one of:\r\n   - `config.json` → `\"api_key\": \"sk_live_...\"`\r\n   - CLI: `--api_key sk_live_...`\r\n   - Environment: `export KAMICLAW_API_KEY=sk_live_...`\r\n\r\n### Cameras\r\n\r\nAll RTSP cameras are declared in the `cameras` array. Each entry has just two fields:\r\n\r\n```json\r\n{\r\n  \"cameras\": [\r\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\r\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\r\n  ]\r\n}\r\n```\r\n\r\nFields:\r\n\r\n| Field | Required | Description |\r\n|-------|----------|-------------|\r\n| `name` | see rule below | Unique identifier and display label shown in every alarm push and log line. |\r\n| `rtsp_url` | yes | RTSP stream URL (or local video file path) for that camera. |\r\n\r\n**Naming rule.**\r\n\r\n- **Single camera (one entry):** `name` is optional. If omitted, it defaults to `\"default\"`.\r\n  ```json\r\n  { \"cameras\": [ { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" } ] }\r\n  ```\r\n- **Multiple cameras (two or more entries):** every entry **must** have a unique, non-empty `name` (e.g. `front_door`, `backyard`, `living_room`, `garage`). The skill refuses to start otherwise. The name is what your operator sees on Feishu / Telegram / Discord, so pick something that immediately tells them where the fall happened.\r\n\r\n**Onboarding flow.** For each camera you want to monitor:\r\n\r\n1. Verify the RTSP URL is reachable (e.g. `ffplay rtsp://...` or VLC).\r\n2. Add an entry to `cameras` with a meaningful `name` and the `rtsp_url`.\r\n3. Run `python fall_detect_cloud_skill.py --list_cameras` to print the resolved list and confirm.\r\n\r\n**Concurrency model.** Each camera runs on its own daemon thread; a stream loss on one camera triggers reconnect for that camera only — the others keep monitoring uninterrupted. Pressing `Ctrl+C` signals all workers to stop gracefully.\r\n\r\n### Feishu Notifications (Webhook)\r\n\r\nGet instant alarm messages in a Feishu group chat.\r\n\r\n**Step 1 — Create a Feishu bot in your group**\r\n\r\n1. Open the Feishu group chat.\r\n2. Group settings (⋮) → **Add Bot** → **Custom Bot**.\r\n3. Set a name (e.g. `Fall Detection Alert`).\r\n4. Copy the **Webhook URL** — it looks like:\r\n   `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`\r\n\r\n**Step 2 — Add to `config.json`**\r\n\r\n```json\r\n{\r\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\r\n}\r\n```\r\n\r\nLeave the field as `\"\"` to disable Feishu notifications.\r\n\r\n---\r\n\r\n### Telegram Notifications\r\n\r\n1. Create bot via **@BotFather** → get bot token\r\n2. Get chat ID:\r\n   - For private chat: Message the bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`\r\n   - For group: Add bot to group, send a message, use the same URL to get group ID (starts with `-`)\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"telegram_bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\r\n  \"telegram_chat_id\": \"123456789\"\r\n}\r\n```\r\n\r\n> 💡 **Note:** Same config works for both push notifications and (optionally) two-way communication if you run the `telegram-gateway` service.\r\n\r\n---\r\n\r\n### Discord Notifications\r\n\r\n**Option A: Webhook (Push Only)** — Simplest, no bot required\r\n\r\n1. Channel Settings (⚙️) → **Integrations** → **Webhooks** → **New Webhook**\r\n2. Copy Webhook URL\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_webhook_url\": \"https://discord.com/api/webhooks/123456789/abcdefghijklmnop\"\r\n}\r\n```\r\n\r\n**Option B: Bot API (Two-Way Capable)** — Full features\r\n\r\n1. Go to https://discord.com/developers/applications\r\n2. Create New Application → Bot → Reset Token (copy it)\r\n3. Enable \"Message Content Intent\" in Bot settings\r\n4. Invite bot to your server with proper permissions\r\n5. Get channel ID (enable Developer Mode in Discord, right-click channel → Copy ID)\r\n6. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_bot_token\": \"MTUwNzI2MTY4MTQ1NjExOTgxMQ.G13TXv.xxx\",\r\n  \"discord_channel_id\": \"1507263377909481666\"\r\n}\r\n```\r\n\r\n> ⚠️ **Note:** Bot token + channel ID requires running a gateway service for two-way communication.\r\n\r\n---\r\n\r\n### Quick Comparison\r\n\r\n### Quick Comparison\r\n\r\n| Channel | Push Only | Two-Way Capable |\r\n|---------|-----------|----------------|\r\n| **Feishu** | Webhook URL | Group Bot (same config) |\r\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\r\n| **Discord** | Webhook URL | Bot Token + Channel ID |\r\n\r\n> 💡 **Discord:** Use webhook for simple push notifications. Use bot token + channel ID if you want two-way interaction capability.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n| Field | Default | Description |\r\n|-------|---------|-------------|\r\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\r\n| `cameras` | `[]` | Array of `{name, rtsp_url}` entries. Required (must contain at least one entry). For a single entry, `name` is optional and defaults to `\"default\"`; for multiple entries each must have a unique non-empty `name`. |\r\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\r\n| `pre_seconds` | `3.0` | Seconds buffered **before** a transition (applies to every camera) |\r\n| `post_seconds` | `3.0` | Seconds collected **after** a transition (applies to every camera) |\r\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\r\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL (push notifications) |\r\n| `telegram_bot_token` | `\"\"` | Telegram bot token |\r\n| `telegram_chat_id` | `\"\"` | Telegram chat ID |\r\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\r\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\r\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\r\n\r\n---\r\n\r\n## Usage\r\n\r\n**Run with config.json only:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py\r\n```\r\n\r\n**Override via CLI arguments:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py \\\r\n    --api_key sk_live_xxxxxxxx \\\r\n    --pre_seconds 4 \\\r\n    --post_seconds 4 \\\r\n    --run_time 0\r\n```\r\n\r\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\r\n\r\nThe skill runs continuously and prints a JSON alarm line to **stdout** for every detected fall. It does **not** stop after an alarm — it resets state and keeps monitoring. Stream disconnects are handled automatically via auto-reconnect.\r\n\r\n---\r\n\r\n## Output Format\r\n\r\nEach fall alarm is emitted as a single-line JSON object on stdout:\r\n\r\n```json\r\n{\r\n  \"alarm\": true,\r\n  \"type\": \"fall\",\r\n  \"camera_name\": \"front_door\",\r\n  \"fall_type\": \"active_falling\",\r\n  \"num_persons\": 1,\r\n  \"confidence\": 0.92,\r\n  \"reason\": \"Person collapsed from standing to floor near bed\",\r\n  \"frame\": 87,\r\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\r\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\r\n}\r\n```\r\n\r\nThe `camera_name` field is populated for every alarm and is rendered into every push notification (Feishu, Telegram, Discord) so the operator immediately sees which location triggered.\r\n\r\nWhen `run_time` is reached without any detected fall:\r\n\r\n```json\r\n{\r\n  \"alarm\": false,\r\n  \"type\": null,\r\n  \"detail\": \"Run time limit reached, no fall detected\",\r\n  \"frames_processed\": 3600,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\r\n}\r\n```\r\n\r\n`fall_type` values: `\"active_falling\"` (visible transition) or `\"fallen_posture\"` (person at floor level in a fallen pose).\r\n\r\n---\r\n\r\n## Logs\r\n\r\nAll logs are written under `logs/`:\r\n\r\n| File | Format | Content |\r\n|------|--------|---------|\r\n| `logs/app.log` | Human-readable | Application log (rotates daily, keeps 30 days) |\r\n| `logs/alarms.jsonl` | JSON Lines | Every alarm + every clip analysis result |\r\n| `logs/transitions.jsonl` | JSON Lines | Every Stage-1 transition event |\r\n| `logs/clips/` | MP4 | Saved alarm video clips (when `save_alarm_clips=true`) |\r\n\r\n**alarms.jsonl — alarm entry:**\r\n\r\n```json\r\n{\"event\": \"alarm\", \"alarm\": true, \"type\": \"fall\", \"fall_type\": \"active_falling\", \"num_persons\": 1, \"confidence\": 0.92, \"reason\": \"...\", \"frame\": 87, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**alarms.jsonl — clip analyzed, no alarm:**\r\n\r\n```json\r\n{\"event\": \"clip_analyzed\", \"frame\": 120, \"source\": \"rtsp://...\", \"fall_detected\": false, \"confidence\": 0.97, \"reason\": \"...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**transitions.jsonl:**\r\n\r\n```json\r\n{\"event\": \"transition\", \"frame\": 83, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:31:58+0800\"}\r\n```\r\n\r\n**Quick analysis tips:**\r\n\r\n```bash\r\n# Count alarms today\r\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\r\n\r\n# Compare transitions vs alarms (false-positive rate)\r\nwc -l logs/transitions.jsonl logs/alarms.jsonl\r\n```\r\n\r\n---\r\n\r\n## Exit Codes\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| `0`  | Run time limit reached (normal exit) |\r\n| `1`  | Invalid API key, missing config, or fatal error |\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`KamiClaw API key required`** — Provide it via `--api_key`, `KAMICLAW_API_KEY`, or `config.json`.\r\n- **`No cameras configured`** — Add at least one entry to `cameras` in `config.json`.\r\n- **`Invalid or expired API key`** — Regenerate the key at <https://kamiclaw-skill.kamihome.com>.\r\n- **`Cannot open stream, retrying...`** — The skill auto-retries every 5 seconds. Verify the RTSP URL and network reachability.\r\n- **Feishu notifications not delivered** — Confirm the webhook URL is complete, the custom bot is enabled in the group, and no IP allowlist/keyword restrictions are blocking the payload.\r\n- **Too many false positives** — Increase `pre_seconds` / `post_seconds` for longer clips, or review `logs/transitions.jsonl` vs `logs/alarms.jsonl` to tune thresholds.\n\nFile v1.1.2:_meta.json\n\n{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.1.2\",\n  \"publishedAt\": 1781073098896\n}\n\nFile v1.1.2:skill-card.md\n\n## Description:\n\nDetects fall events from RTSP camera streams using the KamiClaw cloud API without requiring a local GPU.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[13681882136](https://clawhub.ai/user/13681882136)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal users and smart-home operators use this skill to configure and run RTSP camera fall monitoring, receive fall alerts, and review saved alarm clips.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: RTSP URLs and camera credentials may expose private camera access if placed directly in config files or logs.\n\nMitigation: Use camera-owner consent, prefer secret handling that avoids credentials in RTSP URLs when possible, and keep config.json and logs private.\n\nRisk: Alarm clips are sent to the KamiClaw cloud API for fall analysis and may be retained according to the provider policy.\n\nMitigation: Tell operators that alarm clips leave the local environment, review the provider privacy policy, and disable saved clips when local retention is not needed.\n\nRisk: Configured Feishu, Telegram, or Discord notifications can send fall-event details and optional media to third-party services.\n\nMitigation: Enable only required channels, restrict webhook and bot access, and confirm recipients before monitoring live cameras.\n\nRisk: The Feishu webhook fallback can upload an image to sm.ms when Feishu app credentials are not configured.\n\nMitigation: Configure Feishu OpenAPI image upload credentials when inline images are needed, or disable posture image sharing for sensitive deployments.\n\nRisk: The installer may recreate an existing conda environment named kami-fall.\n\nMitigation: Review the local environment before running setup.sh and preserve any existing kami-fall environment that should not be replaced.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/13681882136/skills/kami-fall-detection)\n- [KamiClaw API Registration](https://kamiclaw-skill.kamihome.com)\n- [KamiClaw Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy)\n\n## Skill Output:\n\n**Output Type(s):** [guidance, configuration, shell commands, json, markdown]\n\n**Output Format:** [Markdown guidance with configuration edits, shell commands, JSON alarm records, and notification setup details]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Runtime output may include stdout JSON, JSON Lines logs, optional MP4 alarm clips, and Feishu, Telegram, or Discord notifications.]\n\n## Skill Version(s):\n\n1.1.2 (source: server release metadata; artifact frontmatter reports 1.0.9)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.1.2:config.json\n\n{\n  \"api_key\": \"\",\n  \"cameras\": [],\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"feishu_app_id\": \"\",\n  \"feishu_app_secret\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\",\n  \"fall_posture_image\": \"resources/fall_postures.png\"\n}\n\nFile v1.1.2:requirements.txt\n\nrequests>=2.28.0\nopencv-python-headless>=4.7.0\nnumpy>=1.23.0\n\nArchive v1.1.0: 11 files, 34815 bytes\n\nFiles: config.json (398b), discord_notifier.py (20800b), fall_detect_cloud_skill.py (28953b), feishu_notifier.py (21011b), README.md (13861b), requirements.txt (61b), setup.sh (4166b), skill-card.md (2605b), SKILL.md (11072b), telegram_notifier.py (9526b), _meta.json (138b)\n\nFile v1.1.0:SKILL.md\n\n---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.9\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `cameras` | `[]` | **Required.** Array of `{name, rtsp_url}` entries. Single entry: `name` optional, defaults to `\"default\"`. Two or more entries: every entry must have a unique non-empty `name`. |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL for alarm notifications |\n| `telegram_bot_token` | `\"\"` | Telegram bot token for alarm notifications |\n| `telegram_chat_id` | `\"\"` | Telegram chat ID (user or group) |\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\n\n### Camera Setup\n\nAll cameras are declared in the `cameras` array. Each entry has just two fields: `name` and `rtsp_url`.\n\n**Single camera (one entry).** `name` is optional — if omitted it defaults to `\"default\"`:\n\n```json\n{\n  \"cameras\": [\n    { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" }\n  ]\n}\n```\n\n**Multiple cameras (two or more entries).** Every entry **must** have a unique, non-empty `name`. Strongly recommended: pick a meaningful location label so the operator immediately knows which camera triggered.\n\n```json\n{\n  \"cameras\": [\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\n  ]\n}\n```\n\n- `name` is shown in every Feishu / Telegram / Discord push and tags every log line.\n- One worker thread per camera; a single stream loss does not affect the others.\n- The skill refuses to start if `cameras` is empty, or if multiple entries are missing/sharing a `name`.\n\n### Common Brand RTSP Templates\n\nIf the user is unsure about the RTSP URL, suggest one of these patterns based on camera brand:\n\n| Brand key | Brand | URL pattern |\n|-----------|-------|-------------|\n| `hikvision` | Hikvision | `rtsp://{user}:{pwd}@{ip}:554/Streaming/Channels/101` (`101`=ch1 main, `102`=ch1 sub) |\n| `dahua` | Dahua | `rtsp://{user}:{pwd}@{ip}:554/cam/realmonitor?channel=1&subtype=0` (`subtype=0` main, `1` sub) |\n| `tplink` | TP-Link | `rtsp://{user}:{pwd}@{ip}:554/stream1` (`stream1` main, `stream2` sub) |\n| `ezviz` | EZVIZ | `rtsp://admin:{verify_code}@{ip}:554/H264/ch1/main/av_stream` |\n| `uniview` | Uniview | `rtsp://{user}:{pwd}@{ip}:554/media/video1` |\n| `reolink` | Reolink | `rtsp://{user}:{pwd}@{ip}:554/h264Preview_01_main` |\n\n### Advanced Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `3.0` | Seconds buffered before motion trigger |\n| `post_seconds` | `3.0` | Seconds collected after motion trigger |\n\n---\n\n## Notification Setup\n\nTell the agent which channels you want. They'll guide you through setup.\n\n### Quick Guide\n\n| Channel | Push Only | Two-Way Capable |\n|---------|-----------|----------------|\n| **Feishu** | Webhook URL | Group Bot (same config) |\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\n| **Discord** | Webhook URL | Bot Token + Channel ID |\n\n> 💡 **Discord:** Bot token + channel ID gives you full two-way capability. Webhook is simpler for push-only.\n\n> 💡 **Need help?** Ask OpenClaw for guidance.\n\n---\n\n## Running\n\n```bash\n# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or override the API key on the CLI\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --api_key sk_live_xxxxxxxx\n```\n\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\n\nThe skill runs continuously. It does NOT stop after an alarm — it resets and keeps monitoring.\n\n---\n\n## Output Format\n\n**Fall detected:**\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"camera_name\": \"front_door\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Normal exit (run time reached):**\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Normal exit (run time reached) |\n| `1`  | Error (invalid API key, missing config, etc.) |\n\n---\n\n## Advanced: How It Works\n\n<details>\n<summary>Click to expand technical details</summary>\n\n### Stage 1 — Change Detection (Local, CPU-only)\n- Lightweight frame-differencing on 128×128 grayscale\n- Maintains rolling pre-buffer (default 4s)\n- Triggers Stage 2 on significant temporal change\n\n### Stage 2 — Cloud Analysis\n- Collects post-transition frames (default 4s)\n- Resizes clip to 360×360, writes to temp file\n- Sends to KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`)\n- On fall detected: outputs JSON alarm, optionally saves clip, resets to Stage 1\n\n### Auto-Reconnect\n- If RTSP stream drops, retries connection every 5 seconds\n- Resumes monitoring seamlessly after reconnection\n\n</details>\n\n---\n\n## Agent Setup Flow\n\n**For agents configuring this skill:**\n\n1. Read `config.json` — check whether `api_key` is set and whether `cameras` is a non-empty array.\n2. If `api_key` is empty, ask the user: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill.kamihome.com\".\n3. If `cameras` is empty, ask: \"How many RTSP cameras do you want to monitor?\"\n   - **One camera:** ask only for the RTSP URL. Write `[ { \"rtsp_url\": \"...\" } ]` — `name` will default to `\"default\"` automatically.\n   - **Two or more cameras:** for each one, ask both the RTSP URL **and** a unique short location label (e.g. `front_door`, `backyard`, `living_room`). Strongly recommend the user picks meaningful labels — they are shown in every alarm notification. Write `[ { \"name\": \"front_door\", \"rtsp_url\": \"...\" }, { \"name\": \"backyard\", \"rtsp_url\": \"...\" } ]`.\n4. Ask: \"Save alarm video clips? (yes/no, default: yes)\" → set `save_alarm_clips`.\n5. Ask about each notification channel (Feishu / Telegram / Discord) — guide setup if yes.\n6. Write all values to `config.json` (read existing, merge, write back).\n7. Optionally run `python fall_detect_cloud_skill.py --list_cameras` to confirm the resolved camera list.\n8. Run the skill.\n\n**Never run with an empty `api_key`. Never run with `cameras` empty. When the user has multiple cameras, never accept missing/duplicate names — re-prompt until each camera has a unique label. Never ask the user to manually edit config.json.**\n\n---\n\n## Troubleshooting & Analysis\n\n### Log Files\n\n| File | Content |\n|------|---------|\n| `logs/app.log` | Application log (rotates daily, keeps 30 days) |\n| `logs/alarms.jsonl` | All alarm events + clip analysis results |\n| `logs/transitions.jsonl` | All motion trigger events |\n\n### Quick Analysis Commands\n\n```bash\n# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\"\n```\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| No alarms detected | Check RTSP stream is active; verify camera angle covers monitoring area |\n| Too many false alarms | Adjust camera position; reduce motion sensitivity area |\n| API errors | Verify API key is valid; check internet connection |\n| Stream disconnects | Check network stability; camera may need reboot |\n\n---\n\n## File Structure\n\n```\nkami-fall-detection/\n├── SKILL.md                      # Documentation\n├── config.json                   # Configuration (auto-managed by agent)\n├── fall_detect_cloud_skill.py    # Production entry point\n├── setup.sh                      # Installer\n└── requirements.txt              # Dependencies\n```\n\nFile v1.1.0:README.md\n\n# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [Cameras](#cameras)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- **Python 3.8+**\r\n- **OS**: Linux (primary), macOS / Windows supported for development\r\n- **KamiClaw API key** — register at <https://kamiclaw-skill.kamihome.com>\r\n- **RTSP camera** or local video file for input\r\n\r\nPython dependencies (installed via `setup.sh`):\r\n\r\n- `requests>=2.28.0`\r\n- `opencv-python-headless>=4.7.0`\r\n- `numpy>=1.23.0`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nbash setup.sh\r\n```\r\n\r\nThis will:\r\n\r\n1. Detect system Python (`python3` → `python` → auto-install via `apt`)\r\n2. Create a `.venv/` virtual environment in the project root\r\n3. Install `requests`, `opencv-python-headless`, and `numpy`\r\n\r\nNo GPU or heavy ML libraries are required.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nAll runtime parameters live in [`config.json`](./config.json). CLI arguments and environment variables override config values with the following priority:\r\n\r\n> **CLI args > environment variables > `config.json` > built-in defaults**\r\n\r\n### KamiClaw API Key\r\n\r\n1. Register at <https://kamiclaw-skill.kamihome.com>.\r\n2. Copy your API key from the dashboard (format: `sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`).\r\n3. Set it via one of:\r\n   - `config.json` → `\"api_key\": \"sk_live_...\"`\r\n   - CLI: `--api_key sk_live_...`\r\n   - Environment: `export KAMICLAW_API_KEY=sk_live_...`\r\n\r\n### Cameras\r\n\r\nAll RTSP cameras are declared in the `cameras` array. Each entry has just two fields:\r\n\r\n```json\r\n{\r\n  \"cameras\": [\r\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\r\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\r\n  ]\r\n}\r\n```\r\n\r\nFields:\r\n\r\n| Field | Required | Description |\r\n|-------|----------|-------------|\r\n| `name` | see rule below | Unique identifier and display label shown in every alarm push and log line. |\r\n| `rtsp_url` | yes | RTSP stream URL (or local video file path) for that camera. |\r\n\r\n**Naming rule.**\r\n\r\n- **Single camera (one entry):** `name` is optional. If omitted, it defaults to `\"default\"`.\r\n  ```json\r\n  { \"cameras\": [ { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" } ] }\r\n  ```\r\n- **Multiple cameras (two or more entries):** every entry **must** have a unique, non-empty `name` (e.g. `front_door`, `backyard`, `living_room`, `garage`). The skill refuses to start otherwise. The name is what your operator sees on Feishu / Telegram / Discord, so pick something that immediately tells them where the fall happened.\r\n\r\n**Onboarding flow.** For each camera you want to monitor:\r\n\r\n1. Verify the RTSP URL is reachable (e.g. `ffplay rtsp://...` or VLC).\r\n2. Add an entry to `cameras` with a meaningful `name` and the `rtsp_url`.\r\n3. Run `python fall_detect_cloud_skill.py --list_cameras` to print the resolved list and confirm.\r\n\r\n**Concurrency model.** Each camera runs on its own daemon thread; a stream loss on one camera triggers reconnect for that camera only — the others keep monitoring uninterrupted. Pressing `Ctrl+C` signals all workers to stop gracefully.\r\n\r\n### Feishu Notifications (Webhook)\r\n\r\nGet instant alarm messages in a Feishu group chat.\r\n\r\n**Step 1 — Create a Feishu bot in your group**\r\n\r\n1. Open the Feishu group chat.\r\n2. Group settings (⋮) → **Add Bot** → **Custom Bot**.\r\n3. Set a name (e.g. `Fall Detection Alert`).\r\n4. Copy the **Webhook URL** — it looks like:\r\n   `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`\r\n\r\n**Step 2 — Add to `config.json`**\r\n\r\n```json\r\n{\r\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\r\n}\r\n```\r\n\r\nLeave the field as `\"\"` to disable Feishu notifications.\r\n\r\n---\r\n\r\n### Telegram Notifications\r\n\r\n1. Create bot via **@BotFather** → get bot token\r\n2. Get chat ID:\r\n   - For private chat: Message the bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`\r\n   - For group: Add bot to group, send a message, use the same URL to get group ID (starts with `-`)\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"telegram_bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\r\n  \"telegram_chat_id\": \"123456789\"\r\n}\r\n```\r\n\r\n> 💡 **Note:** Same config works for both push notifications and (optionally) two-way communication if you run the `telegram-gateway` service.\r\n\r\n---\r\n\r\n### Discord Notifications\r\n\r\n**Option A: Webhook (Push Only)** — Simplest, no bot required\r\n\r\n1. Channel Settings (⚙️) → **Integrations** → **Webhooks** → **New Webhook**\r\n2. Copy Webhook URL\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_webhook_url\": \"https://discord.com/api/webhooks/123456789/abcdefghijklmnop\"\r\n}\r\n```\r\n\r\n**Option B: Bot API (Two-Way Capable)** — Full features\r\n\r\n1. Go to https://discord.com/developers/applications\r\n2. Create New Application → Bot → Reset Token (copy it)\r\n3. Enable \"Message Content Intent\" in Bot settings\r\n4. Invite bot to your server with proper permissions\r\n5. Get channel ID (enable Developer Mode in Discord, right-click channel → Copy ID)\r\n6. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_bot_token\": \"MTUwNzI2MTY4MTQ1NjExOTgxMQ.G13TXv.xxx\",\r\n  \"discord_channel_id\": \"1507263377909481666\"\r\n}\r\n```\r\n\r\n> ⚠️ **Note:** Bot token + channel ID requires running a gateway service for two-way communication.\r\n\r\n---\r\n\r\n### Quick Comparison\r\n\r\n### Quick Comparison\r\n\r\n| Channel | Push Only | Two-Way Capable |\r\n|---------|-----------|----------------|\r\n| **Feishu** | Webhook URL | Group Bot (same config) |\r\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\r\n| **Discord** | Webhook URL | Bot Token + Channel ID |\r\n\r\n> 💡 **Discord:** Use webhook for simple push notifications. Use bot token + channel ID if you want two-way interaction capability.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n| Field | Default | Description |\r\n|-------|---------|-------------|\r\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\r\n| `cameras` | `[]` | Array of `{name, rtsp_url}` entries. Required (must contain at least one entry). For a single entry, `name` is optional and defaults to `\"default\"`; for multiple entries each must have a unique non-empty `name`. |\r\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\r\n| `pre_seconds` | `3.0` | Seconds buffered **before** a transition (applies to every camera) |\r\n| `post_seconds` | `3.0` | Seconds collected **after** a transition (applies to every camera) |\r\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\r\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL (push notifications) |\r\n| `telegram_bot_token` | `\"\"` | Telegram bot token |\r\n| `telegram_chat_id` | `\"\"` | Telegram chat ID |\r\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\r\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\r\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\r\n\r\n---\r\n\r\n## Usage\r\n\r\n**Run with config.json only:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py\r\n```\r\n\r\n**Override via CLI arguments:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py \\\r\n    --api_key sk_live_xxxxxxxx \\\r\n    --pre_seconds 4 \\\r\n    --post_seconds 4 \\\r\n    --run_time 0\r\n```\r\n\r\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\r\n\r\nThe skill runs continuously and prints a JSON alarm line to **stdout** for every detected fall. It does **not** stop after an alarm — it resets state and keeps monitoring. Stream disconnects are handled automatically via auto-reconnect.\r\n\r\n---\r\n\r\n## Output Format\r\n\r\nEach fall alarm is emitted as a single-line JSON object on stdout:\r\n\r\n```json\r\n{\r\n  \"alarm\": true,\r\n  \"type\": \"fall\",\r\n  \"camera_name\": \"front_door\",\r\n  \"fall_type\": \"active_falling\",\r\n  \"num_persons\": 1,\r\n  \"confidence\": 0.92,\r\n  \"reason\": \"Person collapsed from standing to floor near bed\",\r\n  \"frame\": 87,\r\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\r\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\r\n}\r\n```\r\n\r\nThe `camera_name` field is populated for every alarm and is rendered into every push notification (Feishu, Telegram, Discord) so the operator immediately sees which location triggered.\r\n\r\nWhen `run_time` is reached without any detected fall:\r\n\r\n```json\r\n{\r\n  \"alarm\": false,\r\n  \"type\": null,\r\n  \"detail\": \"Run time limit reached, no fall detected\",\r\n  \"frames_processed\": 3600,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\r\n}\r\n```\r\n\r\n`fall_type` values: `\"active_falling\"` (visible transition) or `\"fallen_posture\"` (person at floor level in a fallen pose).\r\n\r\n---\r\n\r\n## Logs\r\n\r\nAll logs are written under `logs/`:\r\n\r\n| File | Format | Content |\r\n|------|--------|---------|\r\n| `logs/app.log` | Human-readable | Application log (rotates daily, keeps 30 days) |\r\n| `logs/alarms.jsonl` | JSON Lines | Every alarm + every clip analysis result |\r\n| `logs/transitions.jsonl` | JSON Lines | Every Stage-1 transition event |\r\n| `logs/clips/` | MP4 | Saved alarm video clips (when `save_alarm_clips=true`) |\r\n\r\n**alarms.jsonl — alarm entry:**\r\n\r\n```json\r\n{\"event\": \"alarm\", \"alarm\": true, \"type\": \"fall\", \"fall_type\": \"active_falling\", \"num_persons\": 1, \"confidence\": 0.92, \"reason\": \"...\", \"frame\": 87, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**alarms.jsonl — clip analyzed, no alarm:**\r\n\r\n```json\r\n{\"event\": \"clip_analyzed\", \"frame\": 120, \"source\": \"rtsp://...\", \"fall_detected\": false, \"confidence\": 0.97, \"reason\": \"...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**transitions.jsonl:**\r\n\r\n```json\r\n{\"event\": \"transition\", \"frame\": 83, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:31:58+0800\"}\r\n```\r\n\r\n**Quick analysis tips:**\r\n\r\n```bash\r\n# Count alarms today\r\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\r\n\r\n# Compare transitions vs alarms (false-positive rate)\r\nwc -l logs/transitions.jsonl logs/alarms.jsonl\r\n```\r\n\r\n---\r\n\r\n## Exit Codes\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| `0`  | Run time limit reached (normal exit) |\r\n| `1`  | Invalid API key, missing config, or fatal error |\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`KamiClaw API key required`** — Provide it via `--api_key`, `KAMICLAW_API_KEY`, or `config.json`.\r\n- **`No cameras configured`** — Add at least one entry to `cameras` in `config.json`.\r\n- **`Invalid or expired API key`** — Regenerate the key at <https://kamiclaw-skill.kamihome.com>.\r\n- **`Cannot open stream, retrying...`** — The skill auto-retries every 5 seconds. Verify the RTSP URL and network reachability.\r\n- **Feishu notifications not delivered** — Confirm the webhook URL is complete, the custom bot is enabled in the group, and no IP allowlist/keyword restrictions are blocking the payload.\r\n- **Too many false positives** — Increase `pre_seconds` / `post_seconds` for longer clips, or review `logs/transitions.jsonl` vs `logs/alarms.jsonl` to tune thresholds.\n\nFile v1.1.0:_meta.json\n\n{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.1.0\",\n  \"publishedAt\": 1781054883318\n}\n\nFile v1.1.0:skill-card.md\n\n## Description: <br>\nDetects fall events from RTSP camera streams using the KamiClaw cloud API without requiring a local GPU. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[13681882136](https://clawhub.ai/user/13681882136) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal users, caregivers, and smart-home operators use this skill to configure RTSP camera fall monitoring, receive alarm notifications, and review structured alarm output. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Selected camera clips are sent to KamiClaw for cloud analysis. <br>\nMitigation: Use only in environments where that data flow is acceptable, review the provider privacy policy, and make camera users aware of the monitoring. <br>\nRisk: API keys, RTSP URLs, logs, and saved alarm clips can remain on disk. <br>\nMitigation: Prefer the KAMICLAW_API_KEY environment variable, avoid RTSP URLs with embedded passwords, restrict config and log permissions, and disable save_alarm_clips when local retention is not needed. <br>\nRisk: Alarm metadata or media may be sent to configured chat platforms or the sm.ms image-host fallback. <br>\nMitigation: Configure only trusted notification destinations and remove or gate the sm.ms fallback before use in sensitive settings. <br>\nRisk: The setup script can create or recreate a Python or conda environment. <br>\nMitigation: Inspect setup.sh before running it and execute installation in an isolated environment. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/13681882136/kami-fall-detection) <br>\n- [KamiClaw API portal](https://kamiclaw-skill.kamihome.com) <br>\n- [KamiClaw privacy policy](https://kamiclaw-skill.kamihome.com/privacy) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, JSON, shell commands, configuration, guidance] <br>\n**Output Format:** [Markdown guidance, shell commands, configuration updates, and JSON runtime events] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May configure config.json, emit JSON alarm events, write JSON Lines logs, and save optional MP4 alarm clips when executed.] <br>\n\n## Skill Version(s): <br>\n1.1.0 (source: ClawHub release evidence; artifact frontmatter says 1.0.9) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.1.0:config.json\n\n{\n  \"api_key\": \"\",\n  \"cameras\": [],\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"feishu_app_id\": \"\",\n  \"feishu_app_secret\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\",\n  \"fall_posture_image\": \"resources/fall_postures.png\"\n}\n\nFile v1.1.0:requirements.txt\n\nrequests>=2.28.0\nopencv-python-headless>=4.7.0\nnumpy>=1.23.0\n\nArchive v1.0.9: 11 files, 32908 bytes\n\nFiles: config.json (348b), discord_notifier.py (20800b), fall_detect_cloud_skill.py (28604b), feishu_notifier.py (15884b), README.md (13861b), requirements.txt (61b), setup.sh (4166b), skill-card.md (2458b), SKILL.md (10310b), telegram_notifier.py (9526b), _meta.json (138b)\n\nFile v1.0.9:SKILL.md\n\n---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.9\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `cameras` | `[]` | **Required.** Array of `{name, rtsp_url}` entries. Single entry: `name` optional, defaults to `\"default\"`. Two or more entries: every entry must have a unique non-empty `name`. |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL for alarm notifications |\n| `telegram_bot_token` | `\"\"` | Telegram bot token for alarm notifications |\n| `telegram_chat_id` | `\"\"` | Telegram chat ID (user or group) |\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\n\n### Camera Setup\n\nAll cameras are declared in the `cameras` array. Each entry has just two fields: `name` and `rtsp_url`.\n\n**Single camera (one entry).** `name` is optional — if omitted it defaults to `\"default\"`:\n\n```json\n{\n  \"cameras\": [\n    { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" }\n  ]\n}\n```\n\n**Multiple cameras (two or more entries).** Every entry **must** have a unique, non-empty `name`. Strongly recommended: pick a meaningful location label so the operator immediately knows which camera triggered.\n\n```json\n{\n  \"cameras\": [\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\n  ]\n}\n```\n\n- `name` is shown in every Feishu / Telegram / Discord push and tags every log line.\n- One worker thread per camera; a single stream loss does not affect the others.\n- The skill refuses to start if `cameras` is empty, or if multiple entries are missing/sharing a `name`.\n\n### Advanced Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `3.0` | Seconds buffered before motion trigger |\n| `post_seconds` | `3.0` | Seconds collected after motion trigger |\n\n---\n\n## Notification Setup\n\nTell the agent which channels you want. They'll guide you through setup.\n\n### Quick Guide\n\n| Channel | Push Only | Two-Way Capable |\n|---------|-----------|----------------|\n| **Feishu** | Webhook URL | Group Bot (same config) |\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\n| **Discord** | Webhook URL | Bot Token + Channel ID |\n\n> 💡 **Discord:** Bot token + channel ID gives you full two-way capability. Webhook is simpler for push-only.\n\n> 💡 **Need help?** Ask OpenClaw for guidance.\n\n---\n\n## Running\n\n```bash\n# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or override the API key on the CLI\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --api_key sk_live_xxxxxxxx\n```\n\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\n\nThe skill runs continuously. It does NOT stop after an alarm — it resets and keeps monitoring.\n\n---\n\n## Output Format\n\n**Fall detected:**\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"camera_name\": \"front_door\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Normal exit (run time reached):**\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Normal exit (run time reached) |\n| `1`  | Error (invalid API key, missing config, etc.) |\n\n---\n\n## Advanced: How It Works\n\n<details>\n<summary>Click to expand technical details</summary>\n\n### Stage 1 — Change Detection (Local, CPU-only)\n- Lightweight frame-differencing on 128×128 grayscale\n- Maintains rolling pre-buffer (default 4s)\n- Triggers Stage 2 on significant temporal change\n\n### Stage 2 — Cloud Analysis\n- Collects post-transition frames (default 4s)\n- Resizes clip to 360×360, writes to temp file\n- Sends to KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`)\n- On fall detected: outputs JSON alarm, optionally saves clip, resets to Stage 1\n\n### Auto-Reconnect\n- If RTSP stream drops, retries connection every 5 seconds\n- Resumes monitoring seamlessly after reconnection\n\n</details>\n\n---\n\n## Agent Setup Flow\n\n**For agents configuring this skill:**\n\n1. Read `config.json` — check whether `api_key` is set and whether `cameras` is a non-empty array.\n2. If `api_key` is empty, ask the user: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill.kamihome.com\".\n3. If `cameras` is empty, ask: \"How many RTSP cameras do you want to monitor?\"\n   - **One camera:** ask only for the RTSP URL. Write `[ { \"rtsp_url\": \"...\" } ]` — `name` will default to `\"default\"` automatically.\n   - **Two or more cameras:** for each one, ask both the RTSP URL **and** a unique short location label (e.g. `front_door`, `backyard`, `living_room`). Strongly recommend the user picks meaningful labels — they are shown in every alarm notification. Write `[ { \"name\": \"front_door\", \"rtsp_url\": \"...\" }, { \"name\": \"backyard\", \"rtsp_url\": \"...\" } ]`.\n4. Ask: \"Save alarm video clips? (yes/no, default: yes)\" → set `save_alarm_clips`.\n5. Ask about each notification channel (Feishu / Telegram / Discord) — guide setup if yes.\n6. Write all values to `config.json` (read existing, merge, write back).\n7. Optionally run `python fall_detect_cloud_skill.py --list_cameras` to confirm the resolved camera list.\n8. Run the skill.\n\n**Never run with an empty `api_key`. Never run with `cameras` empty. When the user has multiple cameras, never accept missing/duplicate names — re-prompt until each camera has a unique label. Never ask the user to manually edit config.json.**\n\n---\n\n## Troubleshooting & Analysis\n\n### Log Files\n\n| File | Content |\n|------|---------|\n| `logs/app.log` | Application log (rotates daily, keeps 30 days) |\n| `logs/alarms.jsonl` | All alarm events + clip analysis results |\n| `logs/transitions.jsonl` | All motion trigger events |\n\n### Quick Analysis Commands\n\n```bash\n# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\"\n```\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| No alarms detected | Check RTSP stream is active; verify camera angle covers monitoring area |\n| Too many false alarms | Adjust camera position; reduce motion sensitivity area |\n| API errors | Verify API key is valid; check internet connection |\n| Stream disconnects | Check network stability; camera may need reboot |\n\n---\n\n## File Structure\n\n```\nkami-fall-detection/\n├── SKILL.md                      # Documentation\n├── config.json                   # Configuration (auto-managed by agent)\n├── fall_detect_cloud_skill.py    # Production entry point\n├── setup.sh                      # Installer\n└── requirements.txt              # Dependencies\n```\n\nFile v1.0.9:README.md\n\n# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [Cameras](#cameras)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- **Python 3.8+**\r\n- **OS**: Linux (primary), macOS / Windows supported for development\r\n- **KamiClaw API key** — register at <https://kamiclaw-skill.kamihome.com>\r\n- **RTSP camera** or local video file for input\r\n\r\nPython dependencies (installed via `setup.sh`):\r\n\r\n- `requests>=2.28.0`\r\n- `opencv-python-headless>=4.7.0`\r\n- `numpy>=1.23.0`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nbash setup.sh\r\n```\r\n\r\nThis will:\r\n\r\n1. Detect system Python (`python3` → `python` → auto-install via `apt`)\r\n2. Create a `.venv/` virtual environment in the project root\r\n3. Install `requests`, `opencv-python-headless`, and `numpy`\r\n\r\nNo GPU or heavy ML libraries are required.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nAll runtime parameters live in [`config.json`](./config.json). CLI arguments and environment variables override config values with the following priority:\r\n\r\n> **CLI args > environment variables > `config.json` > built-in defaults**\r\n\r\n### KamiClaw API Key\r\n\r\n1. Register at <https://kamiclaw-skill.kamihome.com>.\r\n2. Copy your API key from the dashboard (format: `sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`).\r\n3. Set it via one of:\r\n   - `config.json` → `\"api_key\": \"sk_live_...\"`\r\n   - CLI: `--api_key sk_live_...`\r\n   - Environment: `export KAMICLAW_API_KEY=sk_live_...`\r\n\r\n### Cameras\r\n\r\nAll RTSP cameras are declared in the `cameras` array. Each entry has just two fields:\r\n\r\n```json\r\n{\r\n  \"cameras\": [\r\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\r\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\r\n  ]\r\n}\r\n```\r\n\r\nFields:\r\n\r\n| Field | Required | Description |\r\n|-------|----------|-------------|\r\n| `name` | see rule below | Unique identifier and display label shown in every alarm push and log line. |\r\n| `rtsp_url` | yes | RTSP stream URL (or local video file path) for that camera. |\r\n\r\n**Naming rule.**\r\n\r\n- **Single camera (one entry):** `name` is optional. If omitted, it defaults to `\"default\"`.\r\n  ```json\r\n  { \"cameras\": [ { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" } ] }\r\n  ```\r\n- **Multiple cameras (two or more entries):** every entry **must** have a unique, non-empty `name` (e.g. `front_door`, `backyard`, `living_room`, `garage`). The skill refuses to start otherwise. The name is what your operator sees on Feishu / Telegram / Discord, so pick something that immediately tells them where the fall happened.\r\n\r\n**Onboarding flow.** For each camera you want to monitor:\r\n\r\n1. Verify the RTSP URL is reachable (e.g. `ffplay rtsp://...` or VLC).\r\n2. Add an entry to `cameras` with a meaningful `name` and the `rtsp_url`.\r\n3. Run `python fall_detect_cloud_skill.py --list_cameras` to print the resolved list and confirm.\r\n\r\n**Concurrency model.** Each camera runs on its own daemon thread; a stream loss on one camera triggers reconnect for that camera only — the others keep monitoring uninterrupted. Pressing `Ctrl+C` signals all workers to stop gracefully.\r\n\r\n### Feishu Notifications (Webhook)\r\n\r\nGet instant alarm messages in a Feishu group chat.\r\n\r\n**Step 1 — Create a Feishu bot in your group**\r\n\r\n1. Open the Feishu group chat.\r\n2. Group settings (⋮) → **Add Bot** → **Custom Bot**.\r\n3. Set a name (e.g. `Fall Detection Alert`).\r\n4. Copy the **Webhook URL** — it looks like:\r\n   `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`\r\n\r\n**Step 2 — Add to `config.json`**\r\n\r\n```json\r\n{\r\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\r\n}\r\n```\r\n\r\nLeave the field as `\"\"` to disable Feishu notifications.\r\n\r\n---\r\n\r\n### Telegram Notifications\r\n\r\n1. Create bot via **@BotFather** → get bot token\r\n2. Get chat ID:\r\n   - For private chat: Message the bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`\r\n   - For group: Add bot to group, send a message, use the same URL to get group ID (starts with `-`)\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"telegram_bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\r\n  \"telegram_chat_id\": \"123456789\"\r\n}\r\n```\r\n\r\n> 💡 **Note:** Same config works for both push notifications and (optionally) two-way communication if you run the `telegram-gateway` service.\r\n\r\n---\r\n\r\n### Discord Notifications\r\n\r\n**Option A: Webhook (Push Only)** — Simplest, no bot required\r\n\r\n1. Channel Settings (⚙️) → **Integrations** → **Webhooks** → **New Webhook**\r\n2. Copy Webhook URL\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_webhook_url\": \"https://discord.com/api/webhooks/123456789/abcdefghijklmnop\"\r\n}\r\n```\r\n\r\n**Option B: Bot API (Two-Way Capable)** — Full features\r\n\r\n1. Go to https://discord.com/developers/applications\r\n2. Create New Application → Bot → Reset Token (copy it)\r\n3. Enable \"Message Content Intent\" in Bot settings\r\n4. Invite bot to your server with proper permissions\r\n5. Get channel ID (enable Developer Mode in Discord, right-click channel → Copy ID)\r\n6. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_bot_token\": \"MTUwNzI2MTY4MTQ1NjExOTgxMQ.G13TXv.xxx\",\r\n  \"discord_channel_id\": \"1507263377909481666\"\r\n}\r\n```\r\n\r\n> ⚠️ **Note:** Bot token + channel ID requires running a gateway service for two-way communication.\r\n\r\n---\r\n\r\n### Quick Comparison\r\n\r\n### Quick Comparison\r\n\r\n| Channel | Push Only | Two-Way Capable |\r\n|---------|-----------|----------------|\r\n| **Feishu** | Webhook URL | Group Bot (same config) |\r\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\r\n| **Discord** | Webhook URL | Bot Token + Channel ID |\r\n\r\n> 💡 **Discord:** Use webhook for simple push notifications. Use bot token + channel ID if you want two-way interaction capability.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n| Field | Default | Description |\r\n|-------|---------|-------------|\r\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\r\n| `cameras` | `[]` | Array of `{name, rtsp_url}` entries. Required (must contain at least one entry). For a single entry, `name` is optional and defaults to `\"default\"`; for multiple entries each must have a unique non-empty `name`. |\r\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\r\n| `pre_seconds` | `3.0` | Seconds buffered **before** a transition (applies to every camera) |\r\n| `post_seconds` | `3.0` | Seconds collected **after** a transition (applies to every camera) |\r\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\r\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL (push notifications) |\r\n| `telegram_bot_token` | `\"\"` | Telegram bot token |\r\n| `telegram_chat_id` | `\"\"` | Telegram chat ID |\r\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\r\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\r\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\r\n\r\n---\r\n\r\n## Usage\r\n\r\n**Run with config.json only:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py\r\n```\r\n\r\n**Override via CLI arguments:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py \\\r\n    --api_key sk_live_xxxxxxxx \\\r\n    --pre_seconds 4 \\\r\n    --post_seconds 4 \\\r\n    --run_time 0\r\n```\r\n\r\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\r\n\r\nThe skill runs continuously and prints a JSON alarm line to **stdout** for every detected fall. It does **not** stop after an alarm — it resets state and keeps monitoring. Stream disconnects are handled automatically via auto-reconnect.\r\n\r\n---\r\n\r\n## Output Format\r\n\r\nEach fall alarm is emitted as a single-line JSON object on stdout:\r\n\r\n```json\r\n{\r\n  \"alarm\": true,\r\n  \"type\": \"fall\",\r\n  \"camera_name\": \"front_door\",\r\n  \"fall_type\": \"active_falling\",\r\n  \"num_persons\": 1,\r\n  \"confidence\": 0.92,\r\n  \"reason\": \"Person collapsed from standing to floor near bed\",\r\n  \"frame\": 87,\r\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\r\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\r\n}\r\n```\r\n\r\nThe `camera_name` field is populated for every alarm and is rendered into every push notification (Feishu, Telegram, Discord) so the operator immediately sees which location triggered.\r\n\r\nWhen `run_time` is reached without any detected fall:\r\n\r\n```json\r\n{\r\n  \"alarm\": false,\r\n  \"type\": null,\r\n  \"detail\": \"Run time limit reached, no fall detected\",\r\n  \"frames_processed\": 3600,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\r\n}\r\n```\r\n\r\n`fall_type` values: `\"active_falling\"` (visible transition) or `\"fallen_posture\"` (person at floor level in a fallen pose).\r\n\r\n---\r\n\r\n## Logs\r\n\r\nAll logs are written under `logs/`:\r\n\r\n| File | Format | Content |\r\n|------|--------|---------|\r\n| `logs/app.log` | Human-readable | Application log (rotates daily, keeps 30 days) |\r\n| `logs/alarms.jsonl` | JSON Lines | Every alarm + every clip analysis result |\r\n| `logs/transitions.jsonl` | JSON Lines | Every Stage-1 transition event |\r\n| `logs/clips/` | MP4 | Saved alarm video clips (when `save_alarm_clips=true`) |\r\n\r\n**alarms.jsonl — alarm entry:**\r\n\r\n```json\r\n{\"event\": \"alarm\", \"alarm\": true, \"type\": \"fall\", \"fall_type\": \"active_falling\", \"num_persons\": 1, \"confidence\": 0.92, \"reason\": \"...\", \"frame\": 87, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**alarms.jsonl — clip analyzed, no alarm:**\r\n\r\n```json\r\n{\"event\": \"clip_analyzed\", \"frame\": 120, \"source\": \"rtsp://...\", \"fall_detected\": false, \"confidence\": 0.97, \"reason\": \"...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**transitions.jsonl:**\r\n\r\n```json\r\n{\"event\": \"transition\", \"frame\": 83, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:31:58+0800\"}\r\n```\r\n\r\n**Quick analysis tips:**\r\n\r\n```bash\r\n# Count alarms today\r\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\r\n\r\n# Compare transitions vs alarms (false-positive rate)\r\nwc -l logs/transitions.jsonl logs/alarms.jsonl\r\n```\r\n\r\n---\r\n\r\n## Exit Codes\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| `0`  | Run time limit reached (normal exit) |\r\n| `1`  | Invalid API key, missing config, or fatal error |\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`KamiClaw API key required`** — Provide it via `--api_key`, `KAMICLAW_API_KEY`, or `config.json`.\r\n- **`No cameras configured`** — Add at least one entry to `cameras` in `config.json`.\r\n- **`Invalid or expired API key`** — Regenerate the key at <https://kamiclaw-skill.kamihome.com>.\r\n- **`Cannot open stream, retrying...`** — The skill auto-retries every 5 seconds. Verify the RTSP URL and network reachability.\r\n- **Feishu notifications not delivered** — Confirm the webhook URL is complete, the custom bot is enabled in the group, and no IP allowlist/keyword restrictions are blocking the payload.\r\n- **Too many false positives** — Increase `pre_seconds` / `post_seconds` for longer clips, or review `logs/transitions.jsonl` vs `logs/alarms.jsonl` to tune thresholds.\n\nFile v1.0.9:_meta.json\n\n{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.0.9\",\n  \"publishedAt\": 1780998186819\n}\n\nFile v1.0.9:skill-card.md\n\n## Description: <br>\nDetect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[13681882136](https://clawhub.ai/user/13681882136) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal users and smart-home operators use this skill to configure and run RTSP camera fall monitoring with KamiClaw cloud analysis and optional Feishu, Telegram, or Discord alerts. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The installer can destructively change an existing local conda environment named kami-fall. <br>\nMitigation: Review setup.sh before installation and avoid running it where an existing kami-fall environment matters. <br>\nRisk: Camera URLs, API keys, bot tokens, logs, and saved clips may expose sensitive home-monitoring data or credentials. <br>\nMitigation: Prefer environment-based secrets, restrict permissions on config.json and logs, and disable saved alarm clips when local retention is not needed. <br>\nRisk: The skill may send alarm clips to cloud analysis and notifications to enabled messaging channels. <br>\nMitigation: Confirm cloud upload behavior and exactly which Feishu, Telegram, or Discord notification channels are configured before continuous monitoring. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/13681882136/kami-fall-detection) <br>\n- [Publisher profile](https://clawhub.ai/user/13681882136) <br>\n- [KamiClaw API registration](https://kamiclaw-skill.kamihome.com) <br>\n- [KamiClaw privacy policy](https://kamiclaw-skill.kamihome.com/privacy) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [guidance, configuration, shell commands, JSON] <br>\n**Output Format:** [Markdown guidance with JSON configuration examples and runtime JSON alarm records] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Requires a KamiClaw API key, RTSP camera access, ffmpeg, and notification credentials when alerts are enabled.] <br>\n\n## Skill Version(s): <br>\n1.0.9 (source: frontmatter and server release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.9:config.json\n\n{\n  \"api_key\": \"\",\n  \"cameras\": [],\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\",\n  \"fall_posture_image\": \"resources/fall_postures.png\"\n}\n\nFile v1.0.9:requirements.txt\n\nrequests>=2.28.0\nopencv-python-headless>=4.7.0\nnumpy>=1.23.0\n\nArchive v1.0.8: 11 files, 31559 bytes\n\nFiles: config.json (293b), discord_notifier.py (15103b), fall_detect_cloud_skill.py (28051b), feishu_notifier.py (12407b), README.md (13861b), requirements.txt (61b), setup.sh (4166b), skill-card.md (2572b), SKILL.md (10310b), telegram_notifier.py (7503b), _meta.json (138b)\n\nFile v1.0.8:SKILL.md\n\n---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.8\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `cameras` | `[]` | **Required.** Array of `{name, rtsp_url}` entries. Single entry: `name` optional, defaults to `\"default\"`. Two or more entries: every entry must have a unique non-empty `name`. |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL for alarm notifications |\n| `telegram_bot_token` | `\"\"` | Telegram bot token for alarm notifications |\n| `telegram_chat_id` | `\"\"` | Telegram chat ID (user or group) |\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\n\n### Camera Setup\n\nAll cameras are declared in the `cameras` array. Each entry has just two fields: `name` and `rtsp_url`.\n\n**Single camera (one entry).** `name` is optional — if omitted it defaults to `\"default\"`:\n\n```json\n{\n  \"cameras\": [\n    { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" }\n  ]\n}\n```\n\n**Multiple cameras (two or more entries).** Every entry **must** have a unique, non-empty `name`. Strongly recommended: pick a meaningful location label so the operator immediately knows which camera triggered.\n\n```json\n{\n  \"cameras\": [\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\n  ]\n}\n```\n\n- `name` is shown in every Feishu / Telegram / Discord push and tags every log line.\n- One worker thread per camera; a single stream loss does not affect the others.\n- The skill refuses to start if `cameras` is empty, or if multiple entries are missing/sharing a `name`.\n\n### Advanced Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `3.0` | Seconds buffered before motion trigger |\n| `post_seconds` | `3.0` | Seconds collected after motion trigger |\n\n---\n\n## Notification Setup\n\nTell the agent which channels you want. They'll guide you through setup.\n\n### Quick Guide\n\n| Channel | Push Only | Two-Way Capable |\n|---------|-----------|----------------|\n| **Feishu** | Webhook URL | Group Bot (same config) |\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\n| **Discord** | Webhook URL | Bot Token + Channel ID |\n\n> 💡 **Discord:** Bot token + channel ID gives you full two-way capability. Webhook is simpler for push-only.\n\n> 💡 **Need help?** Ask OpenClaw for guidance.\n\n---\n\n## Running\n\n```bash\n# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or override the API key on the CLI\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --api_key sk_live_xxxxxxxx\n```\n\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\n\nThe skill runs continuously. It does NOT stop after an alarm — it resets and keeps monitoring.\n\n---\n\n## Output Format\n\n**Fall detected:**\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"camera_name\": \"front_door\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Normal exit (run time reached):**\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Normal exit (run time reached) |\n| `1`  | Error (invalid API key, missing config, etc.) |\n\n---\n\n## Advanced: How It Works\n\n<details>\n<summary>Click to expand technical details</summary>\n\n### Stage 1 — Change Detection (Local, CPU-only)\n- Lightweight frame-differencing on 128×128 grayscale\n- Maintains rolling pre-buffer (default 4s)\n- Triggers Stage 2 on significant temporal change\n\n### Stage 2 — Cloud Analysis\n- Collects post-transition frames (default 4s)\n- Resizes clip to 360×360, writes to temp file\n- Sends to KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`)\n- On fall detected: outputs JSON alarm, optionally saves clip, resets to Stage 1\n\n### Auto-Reconnect\n- If RTSP stream drops, retries connection every 5 seconds\n- Resumes monitoring seamlessly after reconnection\n\n</details>\n\n---\n\n## Agent Setup Flow\n\n**For agents configuring this skill:**\n\n1. Read `config.json` — check whether `api_key` is set and whether `cameras` is a non-empty array.\n2. If `api_key` is empty, ask the user: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill.kamihome.com\".\n3. If `cameras` is empty, ask: \"How many RTSP cameras do you want to monitor?\"\n   - **One camera:** ask only for the RTSP URL. Write `[ { \"rtsp_url\": \"...\" } ]` — `name` will default to `\"default\"` automatically.\n   - **Two or more cameras:** for each one, ask both the RTSP URL **and** a unique short location label (e.g. `front_door`, `backyard`, `living_room`). Strongly recommend the user picks meaningful labels — they are shown in every alarm notification. Write `[ { \"name\": \"front_door\", \"rtsp_url\": \"...\" }, { \"name\": \"backyard\", \"rtsp_url\": \"...\" } ]`.\n4. Ask: \"Save alarm video clips? (yes/no, default: yes)\" → set `save_alarm_clips`.\n5. Ask about each notification channel (Feishu / Telegram / Discord) — guide setup if yes.\n6. Write all values to `config.json` (read existing, merge, write back).\n7. Optionally run `python fall_detect_cloud_skill.py --list_cameras` to confirm the resolved camera list.\n8. Run the skill.\n\n**Never run with an empty `api_key`. Never run with `cameras` empty. When the user has multiple cameras, never accept missing/duplicate names — re-prompt until each camera has a unique label. Never ask the user to manually edit config.json.**\n\n---\n\n## Troubleshooting & Analysis\n\n### Log Files\n\n| File | Content |\n|------|---------|\n| `logs/app.log` | Application log (rotates daily, keeps 30 days) |\n| `logs/alarms.jsonl` | All alarm events + clip analysis results |\n| `logs/transitions.jsonl` | All motion trigger events |\n\n### Quick Analysis Commands\n\n```bash\n# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\"\n```\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| No alarms detected | Check RTSP stream is active; verify camera angle covers monitoring area |\n| Too many false alarms | Adjust camera position; reduce motion sensitivity area |\n| API errors | Verify API key is valid; check internet connection |\n| Stream disconnects | Check network stability; camera may need reboot |\n\n---\n\n## File Structure\n\n```\nkami-fall-detection/\n├── SKILL.md                      # Documentation\n├── config.json                   # Configuration (auto-managed by agent)\n├── fall_detect_cloud_skill.py    # Production entry point\n├── setup.sh                      # Installer\n└── requirements.txt              # Dependencies\n```\n\nFile v1.0.8:README.md\n\n# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [Cameras](#cameras)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- **Python 3.8+**\r\n- **OS**: Linux (primary), macOS / Windows supported for development\r\n- **KamiClaw API key** — register at <https://kamiclaw-skill.kamihome.com>\r\n- **RTSP camera** or local video file for input\r\n\r\nPython dependencies (installed via `setup.sh`):\r\n\r\n- `requests>=2.28.0`\r\n- `opencv-python-headless>=4.7.0`\r\n- `numpy>=1.23.0`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nbash setup.sh\r\n```\r\n\r\nThis will:\r\n\r\n1. Detect system Python (`python3` → `python` → auto-install via `apt`)\r\n2. Create a `.venv/` virtual environment in the project root\r\n3. Install `requests`, `opencv-python-headless`, and `numpy`\r\n\r\nNo GPU or heavy ML libraries are required.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nAll runtime parameters live in [`config.json`](./config.json). CLI arguments and environment variables override config values with the following priority:\r\n\r\n> **CLI args > environment variables > `config.json` > built-in defaults**\r\n\r\n### KamiClaw API Key\r\n\r\n1. Register at <https://kamiclaw-skill.kamihome.com>.\r\n2. Copy your API key from the dashboard (format: `sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`).\r\n3. Set it via one of:\r\n   - `config.json` → `\"api_key\": \"sk_live_...\"`\r\n   - CLI: `--api_key sk_live_...`\r\n   - Environment: `export KAMICLAW_API_KEY=sk_live_...`\r\n\r\n### Cameras\r\n\r\nAll RTSP cameras are declared in the `cameras` array. Each entry has just two fields:\r\n\r\n```json\r\n{\r\n  \"cameras\": [\r\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\r\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\r\n  ]\r\n}\r\n```\r\n\r\nFields:\r\n\r\n| Field | Required | Description |\r\n|-------|----------|-------------|\r\n| `name` | see rule below | Unique identifier and display label shown in every alarm push and log line. |\r\n| `rtsp_url` | yes | RTSP stream URL (or local video file path) for that camera. |\r\n\r\n**Naming rule.**\r\n\r\n- **Single camera (one entry):** `name` is optional. If omitted, it defaults to `\"default\"`.\r\n  ```json\r\n  { \"cameras\": [ { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" } ] }\r\n  ```\r\n- **Multiple cameras (two or more entries):** every entry **must** have a unique, non-empty `name` (e.g. `front_door`, `backyard`, `living_room`, `garage`). The skill refuses to start otherwise. The name is what your operator sees on Feishu / Telegram / Discord, so pick something that immediately tells them where the fall happened.\r\n\r\n**Onboarding flow.** For each camera you want to monitor:\r\n\r\n1. Verify the RTSP URL is reachable (e.g. `ffplay rtsp://...` or VLC).\r\n2. Add an entry to `cameras` with a meaningful `name` and the `rtsp_url`.\r\n3. Run `python fall_detect_cloud_skill.py --list_cameras` to print the resolved list and confirm.\r\n\r\n**Concurrency model.** Each camera runs on its own daemon thread; a stream loss on one camera triggers reconnect for that camera only — the others keep monitoring uninterrupted. Pressing `Ctrl+C` signals all workers to stop gracefully.\r\n\r\n### Feishu Notifications (Webhook)\r\n\r\nGet instant alarm messages in a Feishu group chat.\r\n\r\n**Step 1 — Create a Feishu bot in your group**\r\n\r\n1. Open the Feishu group chat.\r\n2. Group settings (⋮) → **Add Bot** → **Custom Bot**.\r\n3. Set a name (e.g. `Fall Detection Alert`).\r\n4. Copy the **Webhook URL** — it looks like:\r\n   `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`\r\n\r\n**Step 2 — Add to `config.json`**\r\n\r\n```json\r\n{\r\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\r\n}\r\n```\r\n\r\nLeave the field as `\"\"` to disable Feishu notifications.\r\n\r\n---\r\n\r\n### Telegram Notifications\r\n\r\n1. Create bot via **@BotFather** → get bot token\r\n2. Get chat ID:\r\n   - For private chat: Message the bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`\r\n   - For group: Add bot to group, send a message, use the same URL to get group ID (starts with `-`)\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"telegram_bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\r\n  \"telegram_chat_id\": \"123456789\"\r\n}\r\n```\r\n\r\n> 💡 **Note:** Same config works for both push notifications and (optionally) two-way communication if you run the `telegram-gateway` service.\r\n\r\n---\r\n\r\n### Discord Notifications\r\n\r\n**Option A: Webhook (Push Only)** — Simplest, no bot required\r\n\r\n1. Channel Settings (⚙️) → **Integrations** → **Webhooks** → **New Webhook**\r\n2. Copy Webhook URL\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_webhook_url\": \"https://discord.com/api/webhooks/123456789/abcdefghijklmnop\"\r\n}\r\n```\r\n\r\n**Option B: Bot API (Two-Way Capable)** — Full features\r\n\r\n1. Go to https://discord.com/developers/applications\r\n2. Create New Application → Bot → Reset Token (copy it)\r\n3. Enable \"Message Content Intent\" in Bot settings\r\n4. Invite bot to your server with proper permissions\r\n5. Get channel ID (enable Developer Mode in Discord, right-click channel → Copy ID)\r\n6. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_bot_token\": \"MTUwNzI2MTY4MTQ1NjExOTgxMQ.G13TXv.xxx\",\r\n  \"discord_channel_id\": \"1507263377909481666\"\r\n}\r\n```\r\n\r\n> ⚠️ **Note:** Bot token + channel ID requires running a gateway service for two-way communication.\r\n\r\n---\r\n\r\n### Quick Comparison\r\n\r\n### Quick Comparison\r\n\r\n| Channel | Push Only | Two-Way Capable |\r\n|---------|-----------|----------------|\r\n| **Feishu** | Webhook URL | Group Bot (same config) |\r\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\r\n| **Discord** | Webhook URL | Bot Token + Channel ID |\r\n\r\n> 💡 **Discord:** Use webhook for simple push notifications. Use bot token + channel ID if you want two-way interaction capability.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n| Field | Default | Description |\r\n|-------|---------|-------------|\r\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\r\n| `cameras` | `[]` | Array of `{name, rtsp_url}` entries. Required (must contain at least one entry). For a single entry, `name` is optional and defaults to `\"default\"`; for multiple entries each must have a unique non-empty `name`. |\r\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\r\n| `pre_seconds` | `3.0` | Seconds buffered **before** a transition (applies to every camera) |\r\n| `post_seconds` | `3.0` | Seconds collected **after** a transition (applies to every camera) |\r\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\r\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL (push notifications) |\r\n| `telegram_bot_token` | `\"\"` | Telegram bot token |\r\n| `telegram_chat_id` | `\"\"` | Telegram chat ID |\r\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\r\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\r\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\r\n\r\n---\r\n\r\n## Usage\r\n\r\n**Run with config.json only:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py\r\n```\r\n\r\n**Override via CLI arguments:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py \\\r\n    --api_key sk_live_xxxxxxxx \\\r\n    --pre_seconds 4 \\\r\n    --post_seconds 4 \\\r\n    --run_time 0\r\n```\r\n\r\nCameras are always declared in `config.json` under the `cameras` array — there is no CLI flag for the RTSP URL.\r\n\r\nThe skill runs continuously and prints a JSON alarm line to **stdout** for every detected fall. It does **not** stop after an alarm — it resets state and keeps monitoring. Stream disconnects are handled automatically via auto-reconnect.\r\n\r\n---\r\n\r\n## Output Format\r\n\r\nEach fall alarm is emitted as a single-line JSON object on stdout:\r\n\r\n```json\r\n{\r\n  \"alarm\": true,\r\n  \"type\": \"fall\",\r\n  \"camera_name\": \"front_door\",\r\n  \"fall_type\": \"active_falling\",\r\n  \"num_persons\": 1,\r\n  \"confidence\": 0.92,\r\n  \"reason\": \"Person collapsed from standing to floor near bed\",\r\n  \"frame\": 87,\r\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\r\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\r\n}\r\n```\r\n\r\nThe `camera_name` field is populated for every alarm and is rendered into every push notification (Feishu, Telegram, Discord) so the operator immediately sees which location triggered.\r\n\r\nWhen `run_time` is reached without any detected fall:\r\n\r\n```json\r\n{\r\n  \"alarm\": false,\r\n  \"type\": null,\r\n  \"detail\": \"Run time limit reached, no fall detected\",\r\n  \"frames_processed\": 3600,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\r\n}\r\n```\r\n\r\n`fall_type` values: `\"active_falling\"` (visible transition) or `\"fallen_posture\"` (person at floor level in a fallen pose).\r\n\r\n---\r\n\r\n## Logs\r\n\r\nAll logs are written under `logs/`:\r\n\r\n| File | Format | Content |\r\n|------|--------|---------|\r\n| `logs/app.log` | Human-readable | Application log (rotates daily, keeps 30 days) |\r\n| `logs/alarms.jsonl` | JSON Lines | Every alarm + every clip analysis result |\r\n| `logs/transitions.jsonl` | JSON Lines | Every Stage-1 transition event |\r\n| `logs/clips/` | MP4 | Saved alarm video clips (when `save_alarm_clips=true`) |\r\n\r\n**alarms.jsonl — alarm entry:**\r\n\r\n```json\r\n{\"event\": \"alarm\", \"alarm\": true, \"type\": \"fall\", \"fall_type\": \"active_falling\", \"num_persons\": 1, \"confidence\": 0.92, \"reason\": \"...\", \"frame\": 87, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**alarms.jsonl — clip analyzed, no alarm:**\r\n\r\n```json\r\n{\"event\": \"clip_analyzed\", \"frame\": 120, \"source\": \"rtsp://...\", \"fall_detected\": false, \"confidence\": 0.97, \"reason\": \"...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**transitions.jsonl:**\r\n\r\n```json\r\n{\"event\": \"transition\", \"frame\": 83, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:31:58+0800\"}\r\n```\r\n\r\n**Quick analysis tips:**\r\n\r\n```bash\r\n# Count alarms today\r\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\r\n\r\n# Compare transitions vs alarms (false-positive rate)\r\nwc -l logs/transitions.jsonl logs/alarms.jsonl\r\n```\r\n\r\n---\r\n\r\n## Exit Codes\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| `0`  | Run time limit reached (normal exit) |\r\n| `1`  | Invalid API key, missing config, or fatal error |\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`KamiClaw API key required`** — Provide it via `--api_key`, `KAMICLAW_API_KEY`, or `config.json`.\r\n- **`No cameras configured`** — Add at least one entry to `cameras` in `config.json`.\r\n- **`Invalid or expired API key`** — Regenerate the key at <https://kamiclaw-skill.kamihome.com>.\r\n- **`Cannot open stream, retrying...`** — The skill auto-retries every 5 seconds. Verify the RTSP URL and network reachability.\r\n- **Feishu notifications not delivered** — Confirm the webhook URL is complete, the custom bot is enabled in the group, and no IP allowlist/keyword restrictions are blocking the payload.\r\n- **Too many false positives** — Increase `pre_seconds` / `post_seconds` for longer clips, or review `logs/transitions.jsonl` vs `logs/alarms.jsonl` to tune thresholds.\n\nFile v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1780024733104\n}\n\nFile v1.0.8:skill-card.md\n\n## Description: <br>\nDetect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[13681882136](https://clawhub.ai/user/13681882136) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal smart-home users and care teams use this skill to configure RTSP camera monitoring for potential fall events and route alerts through enabled notification services. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill sends short home-camera alarm clips to the KamiClaw cloud API and may send alert details to configured chat services. <br>\nMitigation: Install only when that data sharing is acceptable, review the provider privacy policy, and configure only the notification channels that are needed. <br>\nRisk: The skill requires sensitive credentials, including a KamiClaw API key and optional notification service tokens or webhooks. <br>\nMitigation: Use dedicated least-privilege tokens, store credentials outside source control, and avoid embedding RTSP passwords in camera URLs where possible. <br>\nRisk: Alarm clips are saved locally by default. <br>\nMitigation: Set save_alarm_clips to false when local retention is not needed, or define a cleanup policy for saved clips. <br>\nRisk: The setup script may interact with an existing conda environment named kami-fall. <br>\nMitigation: Review setup.sh before running it, especially on systems that already use a conda environment with that name. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Page](https://clawhub.ai/13681882136/kami-fall-detection) <br>\n- [KamiClaw API Portal](https://kamiclaw-skill.kamihome.com) <br>\n- [KamiClaw Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [guidance, configuration, shell commands, JSON] <br>\n**Output Format:** [Markdown guidance with shell commands and JSON alarm records] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Configures one or more RTSP camera streams and optional Feishu, Telegram, or Discord notifications.] <br>\n\n## Skill Version(s): <br>\n1.0.8 (source: server release evidence and skill frontmatter) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.8:config.json\n\n{\n  \"api_key\": \"\",\n  \"cameras\": [],\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\"\n}\n\nFile v1.0.8:requirements.txt\n\nrequests>=2.28.0\nopencv-python-headless>=4.7.0\nnumpy>=1.23.0\n\nArchive v1.0.7: 11 files, 27889 bytes\n\nFiles: config.json (294b), discord_notifier.py (14773b), fall_detect_cloud_skill.py (22090b), feishu_notifier.py (12073b), README.md (11892b), requirements.txt (61b), setup.sh (4166b), skill-card.md (2537b), SKILL.md (8411b), telegram_notifier.py (7328b), _meta.json (138b)\n\nFile v1.0.7:SKILL.md\n\n---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.7\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `rtsp_url` | `\"\"` | **Required.** RTSP stream URL or local video file path |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL for alarm notifications |\n| `telegram_bot_token` | `\"\"` | Telegram bot token for alarm notifications |\n| `telegram_chat_id` | `\"\"` | Telegram chat ID (user or group) |\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\n\n### Advanced Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `3.0` | Seconds buffered before motion trigger |\n| `post_seconds` | `3.0` | Seconds collected after motion trigger |\n\n---\n\n## Notification Setup\n\nTell the agent which channels you want. They'll guide you through setup.\n\n### Quick Guide\n\n| Channel | Push Only | Two-Way Capable |\n|---------|-----------|----------------|\n| **Feishu** | Webhook URL | Group Bot (same config) |\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\n| **Discord** | Webhook URL | Bot Token + Channel ID |\n\n> 💡 **Discord:** Bot token + channel ID gives you full two-way capability. Webhook is simpler for push-only.\n\n> 💡 **Need help?** Ask OpenClaw for guidance.\n\n---\n\n## Running\n\n```bash\n# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or with CLI arguments\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --rtsp_url rtsp://192.168.1.100/live/stream \\\n    --api_key sk_live_xxxxxxxx\n```\n\nThe skill runs continuously. It does NOT stop after an alarm — it resets and keeps monitoring.\n\n---\n\n## Output Format\n\n**Fall detected:**\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.100/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Normal exit (run time reached):**\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n---\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Normal exit (run time reached) |\n| `1`  | Error (invalid API key, missing config, etc.) |\n\n---\n\n## Advanced: How It Works\n\n<details>\n<summary>Click to expand technical details</summary>\n\n### Stage 1 — Change Detection (Local, CPU-only)\n- Lightweight frame-differencing on 128×128 grayscale\n- Maintains rolling pre-buffer (default 4s)\n- Triggers Stage 2 on significant temporal change\n\n### Stage 2 — Cloud Analysis\n- Collects post-transition frames (default 4s)\n- Resizes clip to 360×360, writes to temp file\n- Sends to KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`)\n- On fall detected: outputs JSON alarm, optionally saves clip, resets to Stage 1\n\n### Auto-Reconnect\n- If RTSP stream drops, retries connection every 5 seconds\n- Resumes monitoring seamlessly after reconnection\n\n</details>\n\n---\n\n## Agent Setup Flow\n\n**For agents configuring this skill:**\n\n1. Read `config.json` — check if `api_key` and `rtsp_url` are non-empty\n2. If empty, ask user:\n   - API key: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill-api.kamihome.com/v1/detect\"\n   - RTSP URL: \"Please provide your RTSP camera URL (e.g., rtsp://192.168.1.100/live/stream)\"\n3. Ask: \"Save alarm video clips? (yes/no, default: yes)\" → set `save_alarm_clips`\n4. Ask about each notification channel (Feishu/Telegram/Discord) — guide setup if yes\n5. Write all values to `config.json` (read existing, merge, write back)\n6. Run the skill\n\n**Never run with empty `api_key` or `rtsp_url`. Never ask user to manually edit config.json.**\n\n---\n\n## Troubleshooting & Analysis\n\n### Log Files\n\n| File | Content |\n|------|---------|\n| `logs/app.log` | Application log (rotates daily, keeps 30 days) |\n| `logs/alarms.jsonl` | All alarm events + clip analysis results |\n| `logs/transitions.jsonl` | All motion trigger events |\n\n### Quick Analysis Commands\n\n```bash\n# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\"\n```\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| No alarms detected | Check RTSP stream is active; verify camera angle covers monitoring area |\n| Too many false alarms | Adjust camera position; reduce motion sensitivity area |\n| API errors | Verify API key is valid; check internet connection |\n| Stream disconnects | Check network stability; camera may need reboot |\n\n---\n\n## File Structure\n\n```\nkami-fall-detection/\n├── SKILL.md                      # Documentation\n├── config.json                   # Configuration (auto-managed by agent)\n├── fall_detect_cloud_skill.py    # Production entry point\n├── fall_detect_cloud.py          # Development/debug version\n├── setup.sh                      # Installer\n└── requirements.txt              # Dependencies\n```\n\nFile v1.0.7:README.md\n\n# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [RTSP Source](#rtsp-source)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- **Python 3.8+**\r\n- **OS**: Linux (primary), macOS / Windows supported for development\r\n- **KamiClaw API key** — register at <https://kamiclaw-skill.kamihome.com>\r\n- **RTSP camera** or local video file for input\r\n\r\nPython dependencies (installed via `setup.sh`):\r\n\r\n- `requests>=2.28.0`\r\n- `opencv-python-headless>=4.7.0`\r\n- `numpy>=1.23.0`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nbash setup.sh\r\n```\r\n\r\nThis will:\r\n\r\n1. Detect system Python (`python3` → `python` → auto-install via `apt`)\r\n2. Create a `.venv/` virtual environment in the project root\r\n3. Install `requests`, `opencv-python-headless`, and `numpy`\r\n\r\nNo GPU or heavy ML libraries are required.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nAll runtime parameters live in [`config.json`](./config.json). CLI arguments and environment variables override config values with the following priority:\r\n\r\n> **CLI args > environment variables > `config.json` > built-in defaults**\r\n\r\n### KamiClaw API Key\r\n\r\n1. Register at <https://kamiclaw-skill.kamihome.com>.\r\n2. Copy your API key from the dashboard (format: `sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`).\r\n3. Set it via one of:\r\n   - `config.json` → `\"api_key\": \"sk_live_...\"`\r\n   - CLI: `--api_key sk_live_...`\r\n   - Environment: `export KAMICLAW_API_KEY=sk_live_...`\r\n\r\n### RTSP Source\r\n\r\nProvide a camera RTSP URL or a local video file path:\r\n\r\n- `config.json` → `\"rtsp_url\": \"rtsp://192.168.1.100/live/stream\"`\r\n- CLI: `--rtsp_url rtsp://192.168.1.100/live/stream`\r\n\r\n### Feishu Notifications (Webhook)\r\n\r\nGet instant alarm messages in a Feishu group chat.\r\n\r\n**Step 1 — Create a Feishu bot in your group**\r\n\r\n1. Open the Feishu group chat.\r\n2. Group settings (⋮) → **Add Bot** → **Custom Bot**.\r\n3. Set a name (e.g. `Fall Detection Alert`).\r\n4. Copy the **Webhook URL** — it looks like:\r\n   `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`\r\n\r\n**Step 2 — Add to `config.json`**\r\n\r\n```json\r\n{\r\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\r\n}\r\n```\r\n\r\nLeave the field as `\"\"` to disable Feishu notifications.\r\n\r\n---\r\n\r\n### Telegram Notifications\r\n\r\n1. Create bot via **@BotFather** → get bot token\r\n2. Get chat ID:\r\n   - For private chat: Message the bot, then visit `https://api.telegram.org/bot<TOKEN>/getUpdates`\r\n   - For group: Add bot to group, send a message, use the same URL to get group ID (starts with `-`)\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"telegram_bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\r\n  \"telegram_chat_id\": \"123456789\"\r\n}\r\n```\r\n\r\n> 💡 **Note:** Same config works for both push notifications and (optionally) two-way communication if you run the `telegram-gateway` service.\r\n\r\n---\r\n\r\n### Discord Notifications\r\n\r\n**Option A: Webhook (Push Only)** — Simplest, no bot required\r\n\r\n1. Channel Settings (⚙️) → **Integrations** → **Webhooks** → **New Webhook**\r\n2. Copy Webhook URL\r\n3. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_webhook_url\": \"https://discord.com/api/webhooks/123456789/abcdefghijklmnop\"\r\n}\r\n```\r\n\r\n**Option B: Bot API (Two-Way Capable)** — Full features\r\n\r\n1. Go to https://discord.com/developers/applications\r\n2. Create New Application → Bot → Reset Token (copy it)\r\n3. Enable \"Message Content Intent\" in Bot settings\r\n4. Invite bot to your server with proper permissions\r\n5. Get channel ID (enable Developer Mode in Discord, right-click channel → Copy ID)\r\n6. Add to `config.json`:\r\n```json\r\n{\r\n  \"discord_bot_token\": \"MTUwNzI2MTY4MTQ1NjExOTgxMQ.G13TXv.xxx\",\r\n  \"discord_channel_id\": \"1507263377909481666\"\r\n}\r\n```\r\n\r\n> ⚠️ **Note:** Bot token + channel ID requires running a gateway service for two-way communication.\r\n\r\n---\r\n\r\n### Quick Comparison\r\n\r\n### Quick Comparison\r\n\r\n| Channel | Push Only | Two-Way Capable |\r\n|---------|-----------|----------------|\r\n| **Feishu** | Webhook URL | Group Bot (same config) |\r\n| **Telegram** | Bot Token + Chat ID | + Gateway Service |\r\n| **Discord** | Webhook URL | Bot Token + Channel ID |\r\n\r\n> 💡 **Discord:** Use webhook for simple push notifications. Use bot token + channel ID if you want two-way interaction capability.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n| Field | Default | Description |\r\n|-------|---------|-------------|\r\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\r\n| `rtsp_url` | `\"\"` | RTSP stream URL or path to a local video file |\r\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\r\n| `pre_seconds` | `3.0` | Seconds buffered **before** a transition |\r\n| `post_seconds` | `3.0` | Seconds collected **after** a transition |\r\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\r\n| `feishu_webhook_url` | `\"\"` | Feishu webhook URL (push notifications) |\r\n| `telegram_bot_token` | `\"\"` | Telegram bot token |\r\n| `telegram_chat_id` | `\"\"` | Telegram chat ID |\r\n| `discord_webhook_url` | `\"\"` | Discord webhook URL (push notifications) |\r\n| `discord_bot_token` | `\"\"` | Discord bot token (two-way capable) |\r\n| `discord_channel_id` | `\"\"` | Discord channel ID (for bot) |\r\n\r\n---\r\n\r\n## Usage\r\n\r\n**Run with config.json only:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py\r\n```\r\n\r\n**Override via CLI arguments:**\r\n\r\n```bash\r\n.venv/bin/python fall_detect_cloud_skill.py \\\r\n    --rtsp_url rtsp://192.168.1.100/live/stream \\\r\n    --api_key sk_live_xxxxxxxx \\\r\n    --pre_seconds 4 \\\r\n    --post_seconds 4 \\\r\n    --run_time 0\r\n```\r\n\r\nThe skill runs continuously and prints a JSON alarm line to **stdout** for every detected fall. It does **not** stop after an alarm — it resets state and keeps monitoring. Stream disconnects are handled automatically via auto-reconnect.\r\n\r\n---\r\n\r\n## Output Format\r\n\r\nEach fall alarm is emitted as a single-line JSON object on stdout:\r\n\r\n```json\r\n{\r\n  \"alarm\": true,\r\n  \"type\": \"fall\",\r\n  \"fall_type\": \"active_falling\",\r\n  \"num_persons\": 1,\r\n  \"confidence\": 0.92,\r\n  \"reason\": \"Person collapsed from standing to floor near bed\",\r\n  \"frame\": 87,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\",\r\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\r\n}\r\n```\r\n\r\nWhen `run_time` is reached without any detected fall:\r\n\r\n```json\r\n{\r\n  \"alarm\": false,\r\n  \"type\": null,\r\n  \"detail\": \"Run time limit reached, no fall detected\",\r\n  \"frames_processed\": 3600,\r\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\r\n}\r\n```\r\n\r\n`fall_type` values: `\"active_falling\"` (visible transition) or `\"fallen_posture\"` (person at floor level in a fallen pose).\r\n\r\n---\r\n\r\n## Logs\r\n\r\nAll logs are written under `logs/`:\r\n\r\n| File | Format | Content |\r\n|------|--------|---------|\r\n| `logs/app.log` | Human-readable | Application log (rotates daily, keeps 30 days) |\r\n| `logs/alarms.jsonl` | JSON Lines | Every alarm + every clip analysis result |\r\n| `logs/transitions.jsonl` | JSON Lines | Every Stage-1 transition event |\r\n| `logs/clips/` | MP4 | Saved alarm video clips (when `save_alarm_clips=true`) |\r\n\r\n**alarms.jsonl — alarm entry:**\r\n\r\n```json\r\n{\"event\": \"alarm\", \"alarm\": true, \"type\": \"fall\", \"fall_type\": \"active_falling\", \"num_persons\": 1, \"confidence\": 0.92, \"reason\": \"...\", \"frame\": 87, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**alarms.jsonl — clip analyzed, no alarm:**\r\n\r\n```json\r\n{\"event\": \"clip_analyzed\", \"frame\": 120, \"source\": \"rtsp://...\", \"fall_detected\": false, \"confidence\": 0.97, \"reason\": \"...\", \"_ts\": \"2026-04-27T14:33:15+0800\"}\r\n```\r\n\r\n**transitions.jsonl:**\r\n\r\n```json\r\n{\"event\": \"transition\", \"frame\": 83, \"source\": \"rtsp://...\", \"_ts\": \"2026-04-27T14:31:58+0800\"}\r\n```\r\n\r\n**Quick analysis tips:**\r\n\r\n```bash\r\n# Count alarms today\r\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\r\n\r\n# Compare transitions vs alarms (false-positive rate)\r\nwc -l logs/transitions.jsonl logs/alarms.jsonl\r\n```\r\n\r\n---\r\n\r\n## Exit Codes\r\n\r\n| Code | Meaning |\r\n|------|---------|\r\n| `0`  | Run time limit reached (normal exit) |\r\n| `1`  | Invalid API key, missing config, or fatal error |\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`KamiClaw API key required`** — Provide it via `--api_key`, `KAMICLAW_API_KEY`, or `config.json`.\r\n- **`RTSP URL required`** — Set `rtsp_url` in `config.json` or pass `--rtsp_url`.\r\n- **`Invalid or expired API key`** — Regenerate the key at <https://kamiclaw-skill.kamihome.com>.\r\n- **`Cannot open stream, retrying...`** — The skill auto-retries every 5 seconds. Verify the RTSP URL and network reachability.\r\n- **Feishu notifications not delivered** — Confirm the webhook URL is complete, the custom bot is enabled in the group, and no IP allowlist/keyword restrictions are blocking the payload.\r\n- **Too many false positives** — Increase `pre_seconds` / `post_seconds` for longer clips, or review `logs/transitions.jsonl` vs `logs/alarms.jsonl` to tune thresholds.\n\nFile v1.0.7:_meta.json\n\n{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.0.7\",\n  \"publishedAt\": 1779866472786\n}\n\nFile v1.0.7:skill-card.md\n\n## Description: <br>\nDetect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[13681882136](https://clawhub.ai/user/13681882136) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nExternal users and care-monitoring operators use this skill to configure and run RTSP-camera fall detection with KamiClaw cloud analysis and optional Feishu, Telegram, or Discord alerts. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Private fall-event camera clips are sent to KamiClaw, and alert details may be sent to configured Feishu, Telegram, or Discord destinations. <br>\nMitigation: Install only after confirming that these data flows are acceptable; review provider retention terms and disable saved clips when local clip storage is not needed. <br>\nRisk: The skill handles sensitive credentials including the KamiClaw API key, notification tokens, webhooks, and RTSP connection details. <br>\nMitigation: Prefer environment variables or tightly scoped configuration, avoid passwords in RTSP URLs, prefer webhook-only notifications over bot tokens, and restrict access to config.json and logs. <br>\nRisk: The installer can remove an existing conda environment named kami-fall. <br>\nMitigation: Review setup.sh before execution and rename or back up any existing environment that should be preserved. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill listing](https://clawhub.ai/13681882136/kami-fall-detection) <br>\n- [KamiClaw service and API key registration](https://kamiclaw-skill.kamihome.com) <br>\n- [KamiClaw privacy policy](https://kamiclaw-skill.kamihome.com/privacy) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance, JSON] <br>\n**Output Format:** [Markdown guidance with inline shell commands, configuration values, and JSON runtime events] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Emits JSON alarm lines, writes JSONL logs, sends configured notifications, and may save MP4 alarm clips.] <br>\n\n## Skill Version(s): <br>\n1.0.7 (source: release evidence and skill frontmatter) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v1.0.7:config.json\n\n{\n  \"api_key\": \"\",\n  \"rtsp_url\": \"\",\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\"\n}\n\nFile v1.0.7:requirements.txt\n\nrequests>=2.28.0\nopencv-python-headless>=4.7.0\nnumpy>=1.23.0\n\nArchive v1.0.6: 9 files, 18730 bytes\n\nFiles: config.json (156b), fall_detect_cloud_skill.py (20047b), feishu_notifier.py (12073b), logs/last-check-state.json (182b), README.md (9548b), requirements.txt (61b), setup.sh (980b), SKILL.md (8837b), _meta.json (138b)\n\nFile v1.0.6:SKILL.md\n\n---\nname: kami-fall-detection\nversion: \"1.0.6\"\ndisplayName: \"Kami Fall Detection — Cloud-Based Fall Monitoring\"\ndescription: >\n  Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed — all inference runs server-side. Ideal for elderly care, smart home monitoring, and emergency response.\nmetadata: {\"openclaw\": {\"emoji\": \"🚨\", \"requires\": {\"bins\": [\"python3\"], \"env\": [\"KAMICLAW_API_KEY\"]}, \"primaryEnv\": \"KAMICLAW_API_KEY\", \"os\": [\"linux\"]}}\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n## How it works\n\n1. **Stage 1 — Change detection** (local, CPU-only): Lightweight frame-differencing on 128×128 grayscale. Keeps a rolling pre-buffer (default 4s). When a significant temporal change is detected, triggers Stage 2.\n2. **Stage 2 — KamiClaw cloud analysis**: Collects post-transition frames (default 4s), resizes the clip to 360×360, writes to a temp file, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, outputs a JSON alarm line and optionally saves the clip. Then resets and returns to Stage 1.\n3. **Auto-reconnect**: If the RTSP stream drops, the skill automatically retries connection every 5 seconds and resumes monitoring seamlessly.\n\n## API Key Setup Guide\n\nThis skill requires a KamiClaw API key to authenticate with the cloud service.\n\n### Step 1 — Register\n\nGo to https://kamiclaw-skill.kamihome.com and create an account. Choose a plan that fits your usage.\n> **Notice:** New users who sign up at https://kamiclaw-skill.kamihome.com automatically receive **200 free credits** to get started — no payment required. \n\n### Step 2 — Get your API key\n\nAfter registration, copy your API key from the dashboard. It looks like:\n```\nsk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\n\n### Step 3 — Provide your key and RTSP URL\n\nTell the agent your API key and RTSP URL. The agent will automatically save them to `config.json`.\n\n**Agent instructions:**\n\n1. Before running this skill, read `config.json` and check if `api_key` and `rtsp_url` are both non-empty.\n2. If either is empty, ask the user to provide the missing value(s). Do NOT proceed until both are provided.\n   - If `api_key` is empty: \"Please provide your KamiClaw API key. Register at https://kamiclaw-skill.kamihome.com to get one.\"\n   - If `rtsp_url` is empty: \"Please provide your RTSP camera URL (e.g. rtsp://192.168.1.100/live/stream) or a local video file path.\"\n3. Also ask: \"Would you like to save video clips when a fall is detected? (yes/no, default: yes)\" — set `save_alarm_clips` to `true` or `false` accordingly.\n4. **Ask about Feishu notifications**: \"Would you like to receive fall alarms via Feishu? (yes/no)\"\n   - If yes: Guide user to create a Feishu group bot and get the webhook URL\n   - Fill `feishu_webhook_url` in config.json with the webhook URL (e.g., `https://open.feishu.cn/open-apis/bot/v2/hook/xxx`)\n   - If no: Leave `feishu_webhook_url` as empty string `\"\"`\n5. Once the user provides all values, write them into `config.json` (read existing, merge, write back).\n6. Then run the skill.\n\n**Do NOT ask the user to manually edit config.json. Always write it for them.**\n\n## Installation\n\n```bash\nbash setup.sh\n```\n\nThis will:\n1. Detect system Python (`python3` → `python` → auto-install)\n2. Create `.venv/` virtual environment\n3. Install: `requests`, `opencv-python-headless`, `numpy`\n\nNo GPU or heavy ML libraries needed.\n\n## Running\n\n```bash\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --rtsp_url rtsp://192.168.1.100/live/stream \\\n    --api_key sk_live_xxxxxxxx\n```\n\nOr set values in `config.json` and run without arguments:\n```bash\n.venv/bin/python fall_detect_cloud_skill.py\n```\n\n## Configuration\n\nAll parameters are in `config.json`. **The agent auto-fills this when the user provides values in chat.**\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | KamiClaw API key (sent as `X-API-Key` header) |\n| `rtsp_url` | `\"\"` | RTSP stream URL or path to video file |\n| `run_time` | `0` | Max run time in seconds; `0` = unlimited |\n| `pre_seconds` | `4.0` | Seconds buffered before transition |\n| `post_seconds` | `4.0` | Seconds collected after transition |\n| `save_alarm_clips` | `true` | Save alarm video clips to `logs/clips/` |\n| `feishu_webhook_url` | `\"\"` | **Feishu Bot Webhook URL** for alarm notifications |\n\n### Feishu Notification Setup (Webhook)\n\nTo enable automatic alarm notifications via Feishu Webhook:\n\n**Step 1: Create a Feishu Bot in your group**\n\n1. Open your Feishu group chat\n2. Click group settings (⋮) → **Add Bot**\n3. Choose **Custom Bot**\n4. Set a name (e.g., \"Fall Detection Alert\")\n5. Copy the **Webhook URL** (format: `https://open.feishu.cn/open-apis/bot/v2/hook/xxx`)\n\n**Step 2: Add to config.json**\n\n```json\n{\n  \"feishu_webhook_url\": \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\n}\n```\n\n**Step 3: Test the notification**\n\n```bash\n.venv/bin/python fall_detect_cloud_skill.py\n```\n\nThe system will send a test message to confirm the webhook works.\n\n**Agent instructions:** When configuring this skill, ask the user if they want Feishu alarm notifications. If yes, guide them to create a Feishu group bot and provide the webhook URL.\n\nCLI args and env vars still work as overrides (priority: CLI > env > config.json > defaults).\n\n**Agent: If `api_key` or `rtsp_url` is empty in config.json, you MUST ask the user to provide both before running. Never run the skill with either field empty.**\n\n## Output Format (stdout JSON)\n\nWhen alarm triggers:\n```json\n{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.100/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}\n```\n\n**Agent: When a fall alarm is detected (alarm: true), you MUST notify the user through the connected channel (e.g. chat, Feishu, WeChat) with the alarm details, including fall_type, confidence, reason, and clip path (if available).**\n\nWhen no alarm (run_time reached):\n```json\n{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}\n```\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| `0`  | Run time limit reached (normal exit) |\n| `1`  | Invalid API key, missing config, or fatal error |\n\nThe skill runs continuously and prints a JSON alarm line to stdout each time a fall is detected. It does NOT stop after an alarm — it resets and keeps monitoring. Stream disconnections are handled automatically via auto-reconnect.\n\n## Logs\n\nAll logs are saved in the `logs/` directory:\n\n| File | Format | Content |\n|------|--------|---------|\n| `logs/app.log` | Human-readable | General application log (rotates daily, keeps 30 days) |\n\n\nArchive v1.0.5: 9 files, 18729 bytes\n\nFiles: config.json (156b), fall_detect_cloud_skill.py (20047b), feishu_notifier.py (12073b), logs/last-check-state.json (182b), README.md (9548b), requirements.txt (61b), setup.sh (980b), SKILL.md (8843b), _meta.json (138b)\n\nArchive v1.0.4: 9 files, 18728 bytes\n\nFiles: config.json (156b), fall_detect_cloud_skill.py (20047b), feishu_notifier.py (12073b), logs/last-check-state.json (182b), README.md (9548b), requirements.txt (61b), setup.sh (980b), SKILL.md (8913b), _meta.json (138b)\n\nArchive v1.0.2: 9 files, 18667 bytes\n\nFiles: config.json (156b), fall_detect_cloud_skill.py (20047b), feishu_notifier.py (12073b), logs/last-check-state.json (182b), README.md (9548b), requirements.txt (61b), setup.sh (980b), SKILL.md (8754b), _meta.json (138b)\n\nArchive v1.0.1: 8 files, 22131 bytes\n\nFiles: config.json (156b), fall_detect_cloud_skill.py (29980b), feishu_notifier.py (12073b), README.md (9548b), requirements.txt (61b), setup.sh (980b), SKILL.md (8754b), _meta.json (138b)","readmeExcerpt":"Skill: Kami Fall Detection Owner: 13681882136 Summary: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed. Tags: latest:1.1.2 Version history: v1.1.2 | 2026-06-10T06:31:38.896Z | auto Version 1.1.2 - Updated documentation to instruct users to always show the RTSP URL template table during camera configuration. - No changes to core logic or functionality; only SKILL.md documentat","codeSnippets":[],"executableExamples":[{"language":"json","snippet":"{\n  \"cameras\": [\n    { \"rtsp_url\": \"rtsp://192.168.1.100/live/stream\" }\n  ]\n}"},{"language":"json","snippet":"{\n  \"cameras\": [\n    { \"name\": \"front_door\", \"rtsp_url\": \"rtsp://192.168.1.101/live/stream\" },\n    { \"name\": \"backyard\",   \"rtsp_url\": \"rtsp://192.168.1.102/live/stream\" }\n  ]\n}"},{"language":"bash","snippet":"# With config.json (recommended)\n.venv/bin/python fall_detect_cloud_skill.py\n\n# Or override the API key on the CLI\n.venv/bin/python fall_detect_cloud_skill.py \\\n    --api_key sk_live_xxxxxxxx"},{"language":"json","snippet":"{\n  \"alarm\": true,\n  \"type\": \"fall\",\n  \"camera_name\": \"front_door\",\n  \"fall_type\": \"active_falling\",\n  \"num_persons\": 1,\n  \"confidence\": 0.92,\n  \"reason\": \"Person collapsed from standing to floor near bed\",\n  \"frame\": 87,\n  \"source\": \"rtsp://192.168.1.101/live/stream\",\n  \"clip\": \"logs/clips/alarm_fall_20260429_143201.mp4\"\n}"},{"language":"json","snippet":"{\n  \"alarm\": false,\n  \"type\": null,\n  \"detail\": \"Run time limit reached, no fall detected\",\n  \"frames_processed\": 3600,\n  \"source\": \"rtsp://192.168.1.100/live/stream\"\n}"},{"language":"bash","snippet":"# Count alarms today\ngrep '\"alarm\"' logs/alarms.jsonl | grep \"$(date +%Y-%m-%d)\" | wc -l\n\n# Transitions vs alarms (false positive rate)\nwc -l logs/transitions.jsonl logs/alarms.jsonl\n\n# Export alarms as CSV\ncat logs/alarms.jsonl | python3 -c \"\nimport sys, json\nfor line in sys.stdin:\n    obj = json.loads(line)\n    if obj.get('event') == 'alarm':\n        print(f\\\"{obj['_ts']},{obj.get('type','')},{obj.get('fall_type','')},{obj.get('confidence',0)},{obj.get('frame',0)}\\\")\n\""}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: kami-fall-detection-cloud\ndescription: Detect fall events from RTSP camera streams using KamiClaw cloud API. No local GPU needed.\nversion: 1.0.9\nauthor: kami-smarthome\ntags:\n - smart-home\n - fall-detection\n - elderly-care\n - cloud-ai\n - rtsp\n - camera\ntriggers:\n - detect fall\n - fall detection cloud\n - check for falls\n - monitor elderly\n - cloud fall detection\n - home assistant\n - smart home\nmetadata:\n openclaw:\n  requires:\n   bins:\n   - python3\n   - ffmpeg\n   env:\n   - KAMICLAW_API_KEY\n  primaryEnv: KAMICLAW_API_KEY\n  emoji: \"🚨\"\n  hardware:\n   cpu: \"4+ cores (x86_64 / ARM64)\"\n   memory: \"8 GB+\"\n   storage: \"20 GB+\"\n   gpu: \"optional (speed up ONNX inference)\"\n   network:\n   - \"RTSP camera access (LAN)\"\n   - \"Internet (KamiClaw API)\"\n   devices:\n   - \"RTSP IP camera\"\n---\n\n# Kami Fall Detection (Cloud)\n\nDetect fall events from RTSP camera streams using the KamiClaw cloud API. No local GPU needed — all inference runs server-side.\n\n---\n\n## 🚀 Quick Start\n\n1. **Get API key** → https://kamiclaw-skill.kamihome.com (200 free credits for new users)\n2. **Tell the agent**: Your API key + RTSP camera URL\n3. **Choose notifications**: Feishu / Telegram / Discord (any combination)\n4. **Agent configures everything** automatically\n5. **Run!** → Monitors 24/7, alerts instantly on fall detection\n\n---\n\n## What It Does\n\n- 🎥 Monitors RTSP camera streams continuously\n- 🧠 Uses cloud AI to detect fall events (active falling, fallen posture, etc.)\n- 📱 Sends instant notifications via Feishu, Telegram, or Discord\n- 💾 Saves alarm video clips for review (optional)\n- 🔄 Auto-reconnects if stream drops\n\n---\n\n## 🔒 Privacy & Data Policy\n\n**In short:** Only 8-second alarm clips are sent to the cloud for AI analysis. No continuous streaming, no audio, no full video.\n\n| What | Local | Cloud |\n|------|-------|-------|\n| Video stream / file | ✅ Processed locally | ❌ Never sent |\n| 8-second alarm clips | ✅ Saved (optional) | ✅ Sent for AI analysis |\n| Audio | ❌ Not collected | ❌ Not collected |\n\n> 📄 **Full details:** Read our [Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy) for complete information on data handling, retention, and your rights.\n\n### Quick Tips\n\n- **Disable local storage:** Set `save_alarm_clips: false` to not save clips locally\n- **Clean up old files:** `find logs/clips/ -type f -mtime +30 -delete`\n- **Protect your API key:** Never commit `config.json` to git\n\n> ℹ️ AI analysis requires sending alarm clips to the cloud API. Processed clips are retained per the provider's data retention policy.\n\n---\n\n## Configuration\n\nAll settings are in `config.json`. The agent auto-fills this when you provide values in chat.\n\n### Essential Settings\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `api_key` | `\"\"` | **Required.** KamiClaw API key |\n| `cameras` | `[]` | **Required.** Array of `{name, rtsp_url}` entries. Single entry: `name` optional, defaults to `\"default\"`. Two or more entries: every entry must have a unique non-empty "},{"path":"README.md","content":"# Kami Fall Detection (Cloud)\r\n\r\nDetect fall events from RTSP camera streams using the **KamiClaw cloud API**. No local GPU required — all heavy inference runs server-side. Designed for elderly-care monitoring with optional Feishu alarm notifications.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Features](#features)\r\n- [How It Works](#how-it-works)\r\n- [Project Structure](#project-structure)\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [Configuration](#configuration)\r\n  - [KamiClaw API Key](#kamiclaw-api-key)\r\n  - [Cameras](#cameras)\r\n  - [Feishu Notifications (Webhook)](#feishu-notifications-webhook)\r\n  - [Full Config Reference](#full-config-reference)\r\n- [Usage](#usage)\r\n- [Output Format](#output-format)\r\n- [Logs](#logs)\r\n- [Exit Codes](#exit-codes)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n---\r\n\r\n## Features\r\n\r\n- 🚨 **Real-time fall detection** from RTSP camera streams\r\n- ☁️ **Cloud-based inference** — no local GPU or heavy ML libraries needed\r\n- 🔁 **Auto-reconnect** when the RTSP stream drops\r\n- 🎬 **Automatic alarm clip saving** (MP4) on fall events\r\n- 📩 **Feishu webhook notifications** for instant alerts\r\n- 📝 **Structured logs** (JSON Lines) for alarms and transitions\r\n- ⚙️ **Flexible configuration** via `config.json`, CLI args, or environment variables\r\n\r\n---\r\n\r\n## How It Works\r\n\r\nA two-stage pipeline keeps cloud usage low while maintaining high detection quality:\r\n\r\n1. **Stage 1 — Local change detection (CPU only)**\r\n   Lightweight frame-differencing on 128×128 grayscale frames. A rolling pre-buffer (default 4s) is maintained. When a significant temporal change is detected, Stage 2 is triggered.\r\n\r\n2. **Stage 2 — KamiClaw cloud analysis**\r\n   The skill collects post-transition frames (default 4s), resizes the clip to a 640×360 letterboxed canvas, writes it to a temp MP4, and sends it to the KamiClaw API (`detectType: FALL`, `detectSubType: SK_FALL_DETECTION`). If a fall is detected, a JSON alarm line is emitted and the clip is optionally saved.\r\n\r\n3. **Auto-reconnect**\r\n   If the RTSP stream disconnects, the skill retries every 5 seconds and seamlessly resumes monitoring.\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nkami-fall-detection-cloud/\r\n├── SKILL.md                      # Skill metadata & agent instructions\r\n├── README.md                     # This file\r\n├── config.json                   # Runtime config (api_key, rtsp_url, etc.)\r\n├── fall_detect_cloud_skill.py    # Main entry point\r\n├── feishu_notifier.py            # Feishu webhook/API notification module\r\n├── setup.sh                      # Virtualenv + dependencies installer\r\n└── requirements.txt              # Python dependencies\r\n```\r\n\r\nGenerated at runtime:\r\n\r\n```\r\nlogs/\r\n├── app.log                       # Rotating daily application log\r\n├── alarms.jsonl                  # Alarm & clip-analysis events (JSON Lines)\r\n├── transitions.jsonl             # Stage-1 transition events (JSON Lines)\r\n└── clips/                        # Saved alarm MP4 clips\r\n```\r\n\r\n---\r\n\r\n"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7e9156e1awf00v1sas2wkdfd85a4zh\",\n  \"slug\": \"kami-fall-detection\",\n  \"version\": \"1.1.2\",\n  \"publishedAt\": 1781073098896\n}"},{"path":"skill-card.md","content":"## Description:\n\nDetects fall events from RTSP camera streams using the KamiClaw cloud API without requiring a local GPU.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[13681882136](https://clawhub.ai/user/13681882136)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nExternal users and smart-home operators use this skill to configure and run RTSP camera fall monitoring, receive fall alerts, and review saved alarm clips.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: RTSP URLs and camera credentials may expose private camera access if placed directly in config files or logs.\n\nMitigation: Use camera-owner consent, prefer secret handling that avoids credentials in RTSP URLs when possible, and keep config.json and logs private.\n\nRisk: Alarm clips are sent to the KamiClaw cloud API for fall analysis and may be retained according to the provider policy.\n\nMitigation: Tell operators that alarm clips leave the local environment, review the provider privacy policy, and disable saved clips when local retention is not needed.\n\nRisk: Configured Feishu, Telegram, or Discord notifications can send fall-event details and optional media to third-party services.\n\nMitigation: Enable only required channels, restrict webhook and bot access, and confirm recipients before monitoring live cameras.\n\nRisk: The Feishu webhook fallback can upload an image to sm.ms when Feishu app credentials are not configured.\n\nMitigation: Configure Feishu OpenAPI image upload credentials when inline images are needed, or disable posture image sharing for sensitive deployments.\n\nRisk: The installer may recreate an existing conda environment named kami-fall.\n\nMitigation: Review the local environment before running setup.sh and preserve any existing kami-fall environment that should not be replaced.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/13681882136/skills/kami-fall-detection)\n- [KamiClaw API Registration](https://kamiclaw-skill.kamihome.com)\n- [KamiClaw Privacy Policy](https://kamiclaw-skill.kamihome.com/privacy)\n\n## Skill Output:\n\n**Output Type(s):** [guidance, configuration, shell commands, json, markdown]\n\n**Output Format:** [Markdown guidance with configuration edits, shell commands, JSON alarm records, and notification setup details]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Runtime output may include stdout JSON, JSON Lines logs, optional MP4 alarm clips, and Feishu, Telegram, or Discord notifications.]\n\n## Skill Version(s):\n\n1.1.2 (source: server release metadata; artifact frontmatter reports 1.0.9)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."},{"path":"config.json","content":"{\n  \"api_key\": \"\",\n  \"cameras\": [],\n  \"run_time\": 0,\n  \"pre_seconds\": 3.0,\n  \"post_seconds\": 3.0,\n  \"save_alarm_clips\": true,\n  \"feishu_webhook_url\": \"\",\n  \"feishu_app_id\": \"\",\n  \"feishu_app_secret\": \"\",\n  \"telegram_bot_token\": \"\",\n  \"telegram_chat_id\": \"\",\n  \"discord_webhook_url\": \"\",\n  \"discord_bot_token\": \"\",\n  \"discord_channel_id\": \"\",\n  \"fall_posture_image\": \"resources/fall_postures.png\"\n}"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":null,"editorialQuality":{"score":100,"threshold":65,"status":"thin","wordCount":1819,"uniquenessScore":42,"reasons":["uniqueness-below-45"]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-11T05:25:22.175Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-11T07:40:12.056Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}