@ambitionax/weather-query
v1.0.4
Published
OpenClaw 天气智能提醒插件 - 支持自定义 API 与穿衣带伞建议
Maintainers
Readme
OpenClaw 天气智能提醒插件
提供 get_weather 工具,供 Agent 查询天气并生成穿衣、带伞等智能提醒。支持自定义天气 API 或免费 Open-Meteo。
安装
openclaw plugins install @ambitionax/weather-query
openclaw gateway restart可选:npm run build 仅用于类型检查,运行时直接加载 ./src/index.ts,无需预编译。
配置
在 ~/.openclaw/openclaw.json 中启用并配置,按需选择一种方式:
方式一:Open-Meteo(默认,免费无需 Key)
不填 apiUrl 即使用 Open-Meteo:
{
"plugins": {
"entries": {
"weather-query": {
"enabled": true,
"config": {
"defaultCity": "北京",
"units": "metric"
}
}
}
}
}方式二:自定义 API
填写 apiUrl、apiKey 等,URL 和鉴权方式按你使用的 API 文档配置:
{
"plugins": {
"entries": {
"weather-query": {
"enabled": true,
"config": {
"apiUrl": "https://your-api.com/weather",
"apiKey": "your-api-key",
"cityParam": "city",
"authMode": "query",
"defaultCity": "北京",
"extraParams": {}
}
}
}
}
}| 配置项 | 说明 | |--------|------| | apiUrl | 天气 API 地址(留空则用 Open-Meteo) | | apiKey | API Key(鉴权方式由 authMode 决定) | | cityParam | 城市参数名 | | authMode | query(URL 参数)或 header(Authorization: Bearer) | | defaultCity | 默认城市 | | extraParams | 附加参数,如 hourly、lang 等 | | units | metric(摄氏) / imperial(华氏) |
每日 8:00 智能提醒(Cron)
安装插件后,添加 Cron 任务实现每天 8:00 推送天气简报:
openclaw cron add \
--name "早安天气简报" \
--cron "0 8 * * *" \
--tz "Asia/Shanghai" \
--session isolated \
--message "调用 get_weather 查询【北京】天气,根据温度、降水、风力、紫外线等数据,生成今日早安简报,包含:1)当前气温和体感 2)要不要带伞 3)穿衣建议(加衣/减衣/防晒) 4)其他贴心提醒。控制在150字内,语气亲切自然。" \
--model "默认" \
--announce \
--channel feishu将 --channel feishu 和 --to 改为你的飞书配置。
工具说明
- get_weather(city?, days?)
- city: 城市名,如 北京、上海
- days: 预报天数 1-7,默认 1
Agent 在对话中也可直接调用,例如用户问「北京今天天气怎么样」时自动查天气并回复。
