Setup
On first use, read setup.md and align activation boundaries, control plane preferences, and write-safety defaults before sending SONOFF commands.
When to Use
Use this skill when the user needs practical SONOFF and eWeLink execution: cloud API operations, LAN control workflows, DIY mode RPC-like calls, or staged multi-device automations.
Use this instead of generic smart-home advice when outcomes depend on SONOFF-specific eWeLink modes, LAN support differences, and safe rollout behavior.
Architecture
Memory lives in ~/sonoff/. See memory-template.md for structure and status values.
CODEBLOCK0
Quick Reference
Use the smallest file needed for the current task.
| Topic | File |
|---|
| Setup and activation behavior | INLINECODE3 |
| Memory and workspace templates |
memory-template.md |
| Control plane selection |
control-planes.md |
| Access and auth models |
auth-and-access.md |
| Device command workflows |
device-operations.md |
| Multi-device rollout playbooks |
orchestration-playbooks.md |
| Diagnostics and recovery |
troubleshooting.md |
Requirements
- - SONOFF devices reachable in target network or eWeLink account access for cloud mode
- For cloud operations:
EWELINK_API_TOKEN in environment - For LAN and DIY mode operations: device supports LAN/DIY mode and local reachability
Never ask users to paste production secrets in chat logs. Prefer local environment variables and redacted examples.
Data Storage
Keep local operational notes in ~/sonoff/:
- - control plane decisions and endpoint mapping
- device capability notes by model and firmware
- automation constraints, canary scope, and rollback rules
- incident signatures and mitigations
Core Rules
1. Select Control Plane Before Any Command
- - Choose eWeLink cloud, LAN control, DIY mode, or iHost local API first.
- Block execution when plane is ambiguous because results and state consistency differ across planes.
2. Validate Device Capability and Mode Eligibility
- - Confirm if each device supports LAN control or DIY mode before local commands.
- Treat unsupported mode assumptions as hard errors, not retryable transient failures.
3. Discover Before Write
- - Read current status and device metadata before generating command payloads.
- Build writes only with model-valid fields and method paths.
4. Use Read-Before-Write and Read-After-Write Loops
- - Capture baseline state before every write action.
- Verify final observed state after command execution and stop rollout on mismatch.
5. Enforce Explicit Safety Gates for High-Impact Actions
- - Start in read-only inspection and dry-run planning mode.
- Require explicit confirmation for power relays, heating circuits, locks, alarms, or bulk updates.
6. Keep Cloud and LAN Views Reconciled
- - If cloud and LAN states diverge, resolve identity and sync assumptions before more writes.
- Prefer directly observed LAN state for immediate local decisions when reachable.
7. Design Automations as Idempotent and Observable
- - Use deterministic run ids, bounded retries, and hard stop conditions.
- Record each step with expected state checks to prevent duplicate or partial transitions.
8. Preserve Security and Privacy Boundaries
- - Use least-privilege credentials and only declared endpoints.
- Read
EWELINK_API_TOKEN from environment and never persist raw tokens in notes.
Common Traps
- - Assuming every SONOFF model supports LAN or DIY mode -> local calls fail by design.
- Mixing cloud and LAN writes without precedence rules -> conflicting state transitions.
- Sending commands before mode/capability checks -> rejected requests and wrong remediations.
- Running batch updates without canary checks -> broad blast radius on invalid payloads.
- Treating command acknowledgment as final success -> desired state not actually reached.
- Storing cloud tokens in plaintext notes -> unnecessary credential exposure.
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|
| http://<device-ip>:8081/zeroconf/ | Device id and command payload fields | SONOFF DIY mode local control and status retrieval |
| http://<ihost-ip>/open-api/v2/rest/ |
Local token and control payloads | SONOFF iHost eWeLink CUBE local API control |
| http://
/open-api/v2/sse/* | Event subscription parameters | Local iHost event stream and status updates |
| https://*.coolkit.cc | Account-scoped API requests and device command payloads | eWeLink cloud control for SONOFF devices |
| https://dev.ewelink.cc | Integration metadata and docs lookups | Validate eWeLink developer behavior and constraints |
| https://help.sonoff.tech | Documentation query terms | Validate SONOFF DIY and API protocol details |
No other data is sent externally.
Security & Privacy
Data that leaves your machine:
- - local LAN requests or cloud API payloads needed for requested SONOFF operations
- optional local event subscription traffic for iHost SSE workflows
Data that stays local:
- - environment mapping, device notes, and playbooks under INLINECODE13
- incident timelines and rollback decisions
This skill does NOT:
- - use undeclared third-party endpoints
- request bypass or evasion techniques
- store
EWELINK_API_TOKEN in local skill files - execute bulk writes without user confirmation and verification strategy
Trust
This skill sends operational data to SONOFF devices and optionally eWeLink cloud services when execution is approved.
Only install if you trust your LAN environment, iHost deployment, and eWeLink account scope with this automation data.
Related Skills
Install with clawhub install <slug> if user confirms:
- -
iot - Device connectivity and IoT system integration patterns - INLINECODE17 - Home automation architecture and reliability practices
- INLINECODE18 - API contract design and robust request handling
- INLINECODE19 - Messaging patterns for telemetry and event-driven orchestration
- INLINECODE20 - Self-hosted service operations and network reliability workflows
Feedback
- - If useful: INLINECODE21
- Stay updated: INLINECODE22
设置
首次使用时,请先阅读 setup.md,并在发送 SONOFF 命令前对齐激活边界、控制平面偏好及写入安全默认值。
使用时机
当用户需要实际的 SONOFF 和 eWeLink 执行操作时使用此技能:云 API 操作、局域网控制工作流、DIY 模式类 RPC 调用,或分阶段多设备自动化。
当结果取决于 SONOFF 特定的 eWeLink 模式、局域网支持差异及安全发布行为时,请使用此技能而非通用的智能家居建议。
架构
记忆文件位于 ~/sonoff/。结构和状态值请参见 memory-template.md。
text
~/sonoff/
|-- memory.md # 核心上下文和激活边界
|-- environments.md # 局域网段、iHost、云模式和端点映射
|-- devices.md # 设备注册表、功能及命令模式
|-- automations.md # 编排规则、调度和回滚计划
-- incidents.md # 故障特征及已验证的恢复方案
快速参考
根据当前任务使用所需的最小文件。
| 主题 | 文件 |
|---|
| 设置和激活行为 | setup.md |
| 记忆和工作区模板 |
memory-template.md |
| 控制平面选择 | control-planes.md |
| 访问和认证模型 | auth-and-access.md |
| 设备命令工作流 | device-operations.md |
| 多设备发布操作手册 | orchestration-playbooks.md |
| 诊断和恢复 | troubleshooting.md |
要求
- - SONOFF 设备在目标网络中可达,或拥有 eWeLink 账户访问权限以使用云模式
- 云操作:环境中需设置 EWELINKAPITOKEN
- 局域网和 DIY 模式操作:设备需支持局域网/DIY 模式且本地可达
切勿要求用户在聊天日志中粘贴生产环境密钥。优先使用本地环境变量和脱敏示例。
数据存储
将本地操作记录保存在 ~/sonoff/ 中:
- - 控制平面决策和端点映射
- 按型号和固件记录的设备功能说明
- 自动化约束、金丝雀范围和回滚规则
- 故障特征及缓解措施
核心规则
1. 在任何命令前选择控制平面
- - 首先选择 eWeLink 云、局域网控制、DIY 模式或 iHost 本地 API。
- 当平面不明确时阻止执行,因为不同平面的结果和状态一致性存在差异。
2. 验证设备功能和模式资格
- - 在本地命令前确认每个设备是否支持局域网控制或 DIY 模式。
- 将不支持的模式假设视为硬错误,而非可重试的临时故障。
3. 先发现再写入
- - 在生成命令载荷前读取当前状态和设备元数据。
- 仅使用经过模型验证的字段和方法路径构建写入操作。
4. 使用写入前读取和写入后读取循环
- - 在每次写入操作前捕获基线状态。
- 在命令执行后验证最终观察到的状态,并在不匹配时停止发布。
5. 对高影响操作强制执行明确的安全门控
- - 以只读检查和预演计划模式开始。
- 对电源继电器、加热电路、门锁、警报或批量更新要求明确确认。
6. 保持云和局域网视图一致
- - 如果云和局域网状态出现分歧,在更多写入前解决身份和同步假设问题。
- 当设备可达时,优先使用直接观察到的局域网状态进行即时本地决策。
7. 将自动化设计为幂等且可观察
- - 使用确定性运行 ID、有限重试和硬停止条件。
- 记录每一步并附带预期状态检查,以防止重复或部分转换。
8. 维护安全和隐私边界
- - 使用最小权限凭证和仅声明的端点。
- 从环境变量读取 EWELINKAPITOKEN,切勿在记录中持久化原始令牌。
常见陷阱
- - 假设每个 SONOFF 型号都支持局域网或 DIY 模式 -> 本地调用必然失败。
- 在没有优先级规则的情况下混合云和局域网写入 -> 状态转换冲突。
- 在模式/功能检查前发送命令 -> 请求被拒绝且补救措施错误。
- 在没有金丝雀检查的情况下运行批量更新 -> 无效载荷导致广泛影响范围。
- 将命令确认视为最终成功 -> 实际未达到期望状态。
- 在明文记录中存储云令牌 -> 不必要的凭证暴露。
外部端点
| 端点 | 发送的数据 | 用途 |
|---|
| http://<设备-ip>:8081/zeroconf/ | 设备 ID 和命令载荷字段 | SONOFF DIY 模式本地控制和状态获取 |
| http://<ihost-ip>/open-api/v2/rest/ |
本地令牌和控制载荷 | SONOFF iHost eWeLink CUBE 本地 API 控制 |
| http://
/open-api/v2/sse/* | 事件订阅参数 | 本地 iHost 事件流和状态更新 |
| https://*.coolkit.cc | 账户级 API 请求和设备命令载荷 | SONOFF 设备的 eWeLink 云控制 |
| https://dev.ewelink.cc | 集成元数据和文档查询 | 验证 eWeLink 开发者行为和约束 |
| https://help.sonoff.tech | 文档查询词条 | 验证 SONOFF DIY 和 API 协议细节 |
不向外部发送其他数据。
安全与隐私
离开您机器的数据:
- - 执行请求的 SONOFF 操作所需的本地局域网请求或云 API 载荷
- iHost SSE 工作流的可选本地事件订阅流量
保留在本地机器的数据:
- - ~/sonoff/ 下的环境映射、设备记录和操作手册
- 事件时间线和回滚决策
此技能不会:
- - 使用未声明的第三方端点
- 请求绕过或规避技术
- 在本地技能文件中存储 EWELINKAPITOKEN
- 在未经用户确认和验证策略的情况下执行批量写入
信任
此技能在执行获批准时,将操作数据发送到 SONOFF 设备,并可选择发送到 eWeLink 云服务。
仅当您信任您的局域网环境、iHost 部署和 eWeLink 账户范围与此自动化数据交互时,才进行安装。
相关技能
如果用户确认,使用 clawhub install 安装:
- - iot - 设备连接和物联网系统集成模式
- smart-home - 家庭自动化架构和可靠性实践
- api - API 合约设计和稳健的请求处理
- mqtt - 遥测和事件驱动编排的消息传递模式
- home-server - 自托管服务运维和网络可靠性工作流
反馈
- - 如果有用:clawhub star sonoff
- 保持更新:clawhub sync