when-clock-skill (OpenClaw Skill Description)
1. Skill Overview
- - Entry script: INLINECODE0
- Runtime: Python 3.9+, standard library only, no pip required
- Target devices: WHEN / WHEN Voice clock (LAN HTTP, auto-detected)
- Config file:
config.json in script directory (fill devices array with id and clock_ip)
2. Invocation Format
CODEBLOCK0
INLINECODE5 defaults to default (for backward compatibility with single-device config).
3. Mode Quick Reference
| Mode | Description | Required Args | Device Support |
|---|
| INLINECODE7 | Voice time announcement | — | WHEN Voice only |
| INLINECODE8 |
Voice weather broadcast | — | WHEN Voice only |
|
get_alarm | Query all alarms | — | Both |
|
set_alarm | Add new alarm |
--alarm-time | Both |
|
edit_alarm | Modify alarm (partial update) |
--alarm-index | Both |
|
delete_alarm | Delete alarm |
--alarm-index | Both |
|
set_timer | Countdown timer (single alarm) |
--timer-offset | Both |
4. Mode Details
4.1 chime — Voice Time Announcement (WHEN Voice only)
Announces current time. WHEN devices do not support this mode.
CODEBLOCK1
Optional: --volume 1~30 (uses device current volume if not specified)
Output:
{"ok": true, "mode": "chime", "action": "voice_announce_preview", "result": "success", "status": 0, "message": "succ"}
4.2 weather — Weather Broadcast (WHEN Voice only)
WHEN devices do not support this mode.
Note: Weather broadcast currently only supports China region. More regions will be added in future updates.
CODEBLOCK3
Output:
{"ok": true, "mode": "weather", "action": "voice_weather_preview", "result": "success", "status": 0, "message": "succ"}
4.3 get_alarm — Query Alarm List
CODEBLOCK5
WHEN device alarm entries do not include volume field.
WHEN Voice output example (with volume):
CODEBLOCK6
INLINECODE20 is the --alarm-index value needed by edit_alarm / delete_alarm.
4.4 set_alarm — Add New Alarm
CODEBLOCK7
Optional params (use config.json alarm_defaults if not specified):
- -
--alarm-mode: once/weekly/workday/restday/off, default INLINECODE31 - INLINECODE32 : required for
weekly, e.g. 1,2,3,4,5 or INLINECODE35 - INLINECODE36 : ring ID (WHEN Voice: 1~50, WHEN: 1~6 beep1-beep6)
- INLINECODE37 : duration level (0-based, 0~11)
- INLINECODE38 : volume 1~30 (WHEN Voice only)
Maximum 10 alarms per device.
Output:
{"ok": true, "mode": "set_alarm", "action": "add_alarm", "result": "success", "status": 0, "message": "succ", "alarm_count": 3, "added_alarm": {"mode": "Once", "time": "07:30:00", "ring": "Reveille", "ring_duration_level": "2min", "volume": 20, "active_days": []}}
4.5 edit_alarm — Modify Alarm
Only specified fields are updated; other fields keep original values.
CODEBLOCK9
INLINECODE39 is required (use get_alarm to check indices first).
Output:
{"ok": true, "mode": "edit_alarm", "action": "update_alarm", "result": "success", "status": 0, "message": "succ", "alarm_count": 3, "updated_alarm": {"index": 1, "mode": "Once", "time": "07:45:00", "ring": "Reveille", "ring_duration_level": "2min", "volume": 20, "active_days": []}}
4.6 delete_alarm — Delete Alarm
CODEBLOCK11
INLINECODE41 is required.
Output:
{"ok": true, "mode": "delete_alarm", "action": "remove_alarm", "result": "success", "status": 0, "message": "succ", "alarm_count": 2, "removed_alarm": {"index": 2, "mode": "Once", "time": "09:00:00", "ring": "Weather(1x)", "ring_duration_level": "30S", "volume": 15, "active_days": []}}
4.7 set_timer — Countdown Timer
Takes current local time + offset, writes as a single-shot alarm to device.
CODEBLOCK13
INLINECODE42 format: 5m, 1h, 1h30m, 90s, 1h30m20s. Plain number treated as minutes.
Output:
{"ok": true, "mode": "set_timer", "action": "add_timer", "result": "success", "status": 0, "message": "succ", "alarm_count": 3, "timer": {"offset": "5m", "offset_seconds": 300, "trigger_at": "14:35:00", "ring": "Reveille", "ring_duration_level": "2min", "volume": 20}}
5. Ring Tone Reference
WHEN Voice (50 tones, common)
| ID | Name | ID | Name |
|---|
| 1 | Weather(1x) | 2 | Weather(2x) |
| 3 |
Weather(3x) | 4 | Beep-1 |
| 5 | Reveille | 6 | Rest Call |
| 43 | Morning | 44 | Evening |
| 49 | Chinese-style music-1 | 50 | Chinese-style music-2 |
WHEN (6 tones)
beep2 |
| 3 | beep3 |
| 4 | beep4 |
| 5 | beep5 |
| 6 | beep6 |
Full WHEN Voice list in config.json alarm_defaults_note.ring_id_name.
6. Important Conventions
- - Alarm index (
--alarm-index) is 1-based, starting from 1 - Ring ID (
--alarm-ring) is 1-based, internally converted to device 0-based - Volume range
1~30, sent as volume-1 (WHEN Voice only) - WHEN device has no volume parameter, ring fixed to beep1-beep6
- Maximum 10 alarms per device
- INLINECODE54
devices array must have valid id and clock_ip, or script exits with code 2 - Check success: prefer
ok == true, fallback to INLINECODE59 - Errors to
stderr, normal JSON to INLINECODE61
7. Exit Codes
Device returned failure status |
| 2 | Argument / config / response format error |
| 3 | HTTP error |
| 4 | Network error |
when-clock-skill (OpenClaw 技能描述)
1. 技能概述
- - 入口脚本: when-clock-skill.py
- 运行环境: Python 3.9+, 仅使用标准库,无需 pip 安装
- 目标设备: WHEN / WHEN Voice 时钟(局域网 HTTP,自动检测)
- 配置文件: 脚本目录下的 config.json(需在 devices 数组中填写 id 和 clock_ip)
2. 调用格式
python when-clock-skill.py --mode <模式> --device-id <设备ID> [选项...]
--device-id 默认为 default(为兼容单设备配置)。
3. 模式速查表
| 模式 | 描述 | 必需参数 | 设备支持 |
|---|
| chime | 语音报时 | — | 仅 WHEN Voice |
| weather |
语音播报天气 | — | 仅 WHEN Voice |
| get_alarm | 查询所有闹钟 | — | 两者皆可 |
| set_alarm | 添加新闹钟 | --alarm-time | 两者皆可 |
| edit_alarm | 修改闹钟(部分更新) | --alarm-index | 两者皆可 |
| delete_alarm | 删除闹钟 | --alarm-index | 两者皆可 |
| set_timer | 倒计时定时器(单次闹钟) | --timer-offset | 两者皆可 |
4. 模式详情
4.1 chime — 语音报时(仅 WHEN Voice)
播报当前时间。WHEN 设备不支持此模式。
bash
python when-clock-skill.py --mode chime --device-id device1
python when-clock-skill.py --mode chime --device-id device1 --volume 20
可选参数:--volume 1~30(未指定时使用设备当前音量)
输出:
json
{ok: true, mode: chime, action: voiceannouncepreview, result: success, status: 0, message: succ}
4.2 weather — 天气播报(仅 WHEN Voice)
WHEN 设备不支持此模式。
注意:天气播报目前仅支持中国地区。更多地区将在后续更新中添加。
bash
python when-clock-skill.py --mode weather --device-id device1
python when-clock-skill.py --mode weather --device-id device1 --volume 20
输出:
json
{ok: true, mode: weather, action: voiceweatherpreview, result: success, status: 0, message: succ}
4.3 get_alarm — 查询闹钟列表
bash
python when-clock-skill.py --mode get_alarm --device-id device1
WHEN 设备闹钟条目不包含 volume 字段。
WHEN Voice 输出示例(含音量):
json
{
ok: true,
mode: get_alarm,
alarm_count: 2,
alarms: [
{index: 1, mode: Workday, time: 07:30:00, ring: Reveille, ringdurationlevel: 2min, volume: 20},
{index: 2, mode: Weekly, time: 09:00:00, ring: Weather(1x), ringdurationlevel: 30S, volume: 15, active_days: [Mon, Wed]}
]
}
alarms[].index 是 editalarm / deletealarm 所需的 --alarm-index 值。
4.4 set_alarm — 添加新闹钟
bash
单次(默认)
python when-clock-skill.py --mode set_alarm --device-id device1 --alarm-time 07:30
工作日
python when-clock-skill.py --mode set_alarm --device-id device1 --alarm-mode workday --alarm-time 08:00
每周特定天数
python when-clock-skill.py --mode set_alarm --device-id device1 --alarm-mode weekly --alarm-week 1,2,3,4,5 --alarm-time 08:10
WHEN Voice - 完整参数
python when-clock-skill.py --mode set_alarm --device-id device1 --alarm-time 07:30 --alarm-ring 5 --alarm-delay 6 --alarm-volume 20
WHEN - 铃声仅 1-6
python when-clock-skill.py --mode set_alarm --device-id device1 --alarm-time 07:30 --alarm-ring 3
可选参数(未指定时使用 config.json 中的 alarm_defaults):
- - --alarm-mode:once/weekly/workday/restday/off,默认为 once
- --alarm-week:weekly 模式必需,例如 1,2,3,4,5 或 Mon,Wed,Fri
- --alarm-ring:铃声 ID(WHEN Voice:1~50,WHEN:1~6 beep1-beep6)
- --alarm-delay:持续时间等级(从0开始,0~11)
- --alarm-volume:音量 1~30(仅 WHEN Voice)
每台设备最多 10 个闹钟。
输出:
json
{ok: true, mode: setalarm, action: addalarm, result: success, status: 0, message: succ, alarmcount: 3, addedalarm: {mode: Once, time: 07:30:00, ring: Reveille, ringdurationlevel: 2min, volume: 20, active_days: []}}
4.5 edit_alarm — 修改闹钟
仅更新指定字段;其他字段保持原值。
bash
仅修改时间
python when-clock-skill.py --mode edit_alarm --device-id device1 --alarm-index 1 --alarm-time 07:45
修改时间和音量(WHEN Voice)
python when-clock-skill.py --mode edit_alarm --device-id device1 --alarm-index 2 --alarm-time 08:30 --alarm-volume 25
改为工作日模式
python when-clock-skill.py --mode edit_alarm --device-id device1 --alarm-index 1 --alarm-mode workday
--alarm-index 为必需参数(先使用 get_alarm 查看索引)。
输出:
json
{ok: true, mode: editalarm, action: updatealarm, result: success, status: 0, message: succ, alarmcount: 3, updatedalarm: {index: 1, mode: Once, time: 07:45:00, ring: Reveille, ringdurationlevel: 2min, volume: 20, active_days: []}}
4.6 delete_alarm — 删除闹钟
bash
python when-clock-skill.py --mode delete_alarm --device-id device1 --alarm-index 2
--alarm-index 为必需参数。
输出:
json
{ok: true, mode: deletealarm, action: removealarm, result: success, status: 0, message: succ, alarmcount: 2, removedalarm: {index: 2, mode: Once, time: 09:00:00, ring: Weather(1x), ringdurationlevel: 30S, volume: 15, active_days: []}}
4.7 set_timer — 倒计时定时器
获取当前本地时间加上偏移量,作为单次闹钟写入设备。
bash
5分钟后(使用配置默认铃声/音量)
python when-clock-skill.py --mode set_timer --device-id device1 --timer-offset 5m
1小时30分钟后
python when-clock-skill.py --mode set_timer --device-id device1 --timer-offset 1h30m
90秒,自定义铃声和音量(WHEN Voice)
python when-clock-skill.py --mode set_timer --device-id device1 --timer-offset 90s --alarm-ring 5 --alarm-volume 20
--