Weather Open‑Meteo Skill
This skill provides current weather and simple forecasts by querying the open‑meteo.com public API. If the geocoding lookup or weather request fails, the skill can fall back to wttr.in as a lightweight alternative.
📌 Scope & Caveats
- * The skill requires
curl and jq. - Location parameters are encoded before being sent to the API.
- Examples below demonstrate safe query construction using jq @uri.
✅ When to Use
✔
The user asks for weather, forecast, temperature, or rain probability for a location.
✖ Not for historical data, severe alerts, or detailed climatology.
📋 Commands
The skill accepts a single argument: a location name (city, region, or coordinates in
lat,lon).
Open‑Meteo (primary, JSON)
Geocoding (co‑ordinates for a place):
CODEBLOCK0
Current weather (by co‑ordinates):
CODEBLOCK1
7‑day forecast (by co‑ordinates):
CODEBLOCK2
Example JSON excerpt
CODEBLOCK3
📖 Open‑Meteo API docs
wttr.in (fallback)
One‑liner (HTML text):
CODEBLOCK4
Compact plain‑text:
CODEBLOCK5
PNG image (for terminals or embeds):
CODEBLOCK6
📚 Example (User Query)
User: What's the weather in São Paulo?
Agent:
INLINECODE3
Tips
curl -s "https://geocoding-api.open-meteo.com/v1/search?name=$(echo São Paulo | jq -sRr @uri)"
- - Use
jq to build the query dynamically:
city="São Paulo"
lat=$(curl -s "https://geocoding-api.open-meteo.com/v1/search?name=$(echo $city | jq -sRr @uri)" | jq -r '.results[0].latitude')
lon=$(curl -s "https://geocoding-api.open-meteo.com/v1/search?name=$(echo $city | jq -sRr @uri)" | jq -r '.results[0].longitude')
- - You can pass
latitude and longitude directly if you know them. - The API is rate‑limited (≈100 requests/min). Keep scripts cached or use short intervals.
天气 Open‑Meteo 技能
该技能通过查询 open‑meteo.com 公共 API 提供当前天气和简单预报。如果地理编码查询或天气请求失败,该技能可回退到 wttr.in 作为轻量级替代方案。
📌 适用范围与注意事项
- * 该技能需要 curl 和 jq。
- 位置参数在发送到 API 之前会进行编码。
- 以下示例演示了使用 jq @uri 进行安全查询构建。
✅ 何时使用
✔
用户询问某个地点的天气、预报、温度或降雨概率。
✖ 不适用于历史数据、严重警报或详细气候学信息。
📋 命令
该技能接受单个参数:位置名称(城市、地区或 lat,lon 格式的坐标)。
Open‑Meteo(主要,JSON)
地理编码(地点的坐标):
bash
curl -s https://geocoding-api.open-meteo.com/v1/search?name=São+Paulo\u0026count=1 | jq .results[0] | {name, latitude, longitude}
当前天气(按坐标):
bash
curl -s https://api.open-meteo.com/v1/forecast?latitude=-23.55\u0026longitude=-46.63\u0026currentweather=true | jq .currentweather
7 天预报(按坐标):
bash
curl -s https://api.open-meteo.com/v1/forecast?latitude=-23.55\u0026longitude=-46.63\u0026daily=temperature2mmax,temperature2mmin,precipitationsum\u0026forecastdays=7 | jq .daily
JSON 示例片段
json
{
latitude: -23.55,
longitude: -46.63,
current_weather: {
temperature: -5.3,
windspeed: 3.9,
winddirection: 200,
weathercode: 80,
time: 2024-02-18T14:00
}
}
📖 Open‑Meteo API 文档
wttr.in(回退方案)
单行命令(HTML 文本):
bash
curl -s wttr.in/São+Paulo?format=3
紧凑纯文本:
bash
curl -s wttr.in/São+Paulo?format=1
PNG 图像(用于终端或嵌入):
bash
curl -s -o sp.png http://wttr.in/São+Paulo?format=1
📚 示例(用户查询)
用户: 圣保罗的天气怎么样?
智能体:
圣保罗当前天气:🌤️ +10 °C,降雨概率 20%
提示
bash
curl -s https://geocoding-api.open-meteo.com/v1/search?name=$(echo São Paulo | jq -sRr @uri)
bash
city=São Paulo
lat=$(curl -s https://geocoding-api.open-meteo.com/v1/search?name=$(echo $city | jq -sRr @uri) | jq -r .results[0].latitude)
lon=$(curl -s https://geocoding-api.open-meteo.com/v1/search?name=$(echo $city | jq -sRr @uri) | jq -r .results[0].longitude)
- - 如果您知道经纬度,可以直接传递 latitude 和 longitude。
- API 有速率限制(约 100 次请求/分钟)。请缓存脚本或使用短间隔。