Shuzhi Weather Skill
This skill enables querying weather forecasts using the Shuzhi Weather API with HMAC-SHA256 authentication, providing hourly weather data for any location.
Configuration Requirements
IMPORTANT: Before using this skill, you must configure your API credentials:
Create the configuration file at ~/.openclaw/skills/shuzhi-weather/config.json with the following content:
CODEBLOCK0
Replace your_app_key_here and your_app_secret_here with your actual Shuzhi API credentials.
Configuration Priority
The skill follows this configuration priority order:
- 1. User's config.json at
~/.openclaw/skills/shuzhi-weather/config.json (highest priority) - Platform environment variables (if available)
- Default values (if any exist)
When to Use This Skill
Activate this skill when:
- - Users ask for weather forecasts or weather information
- Users inquire about temperatures at specific locations
- Users mention weather-related queries that require current or future data
- Users provide location names and expect weather details
Skill Components
Scripts
The scripts/get_weather.py script provides a reliable way to fetch weather data from the Shuzhi Weather API with HMAC-SHA256 authentication. This script:
- - Loads credentials from the user's config.json file
- Generates dual HMAC-SHA256 signatures (URL signature + body signature)
- Makes authenticated POST requests to the Shuzhi API
- Returns structured weather data including hourly temperatures
References
The references/api_response_format.md contains documentation about the Shuzhi Weather API, including:
- - Request parameters (longitude, latitude, hourly data types)
- Response format and field meanings
- HMAC-SHA256 authentication mechanism
- Error handling and response codes
Workflow
When this skill is activated:
- 1. Check configuration - Verify that
~/.openclaw/skills/shuzhi-weather/config.json exists and contains valid credentials. If not, prompt the user to configure it.
- 2. Extract location information from the user's query. This may include:
- City names (e.g., "Beijing", "Shanghai", "Guangzhou")
- Specific coordinates (latitude, longitude)
- Descriptive locations
- 3. Convert location to coordinates:
- If city name is provided, use geocoding to get latitude and longitude
- If coordinates are provided directly, use them as-is
- Common city coordinates: Beijing (39.9042, 116.4074), Shanghai (31.2304, 121.4737), Guangzhou (23.1291, 113.2644)
- 4. Execute the weather script using the coordinates:
- Run
scripts/get_weather.py with longitude and latitude parameters
- The script loads credentials from config.json
- Returns structured weather data including hourly temperatures
- 5. Present results to the user in a natural, readable format:
- Summarize key information (current temperature, high/low, forecast)
- Include relevant time information (next 24 hours or specific times mentioned)
- Use units appropriate to the context (Celsius by default)
Important Notes
- - The Shuzhi Weather API requires HMAC-SHA256 authentication with dual signatures
- Credentials must be configured in
~/.openclaw/skills/shuzhi-weather/config.json before use - Coordinate format: longitude first, then latitude
- The API endpoint uses POST method with JSON body
- Response code 200 indicates success
- If credentials are missing or invalid, inform the user to check their config.json file
Example Interactions
User: "What's the weather like in Beijing?"
Action: Check config exists, extract "Beijing", use coordinates (39.9042, 116.4074), run script, present forecast
User: "Will it be cold in Shanghai tomorrow?"
Action: Extract "Shanghai" and "tomorrow", use coordinates (31.2304, 121.4737), run script, present tomorrow's temperature
User: "Get the temperature for longitude 116.4074 and latitude 39.9042"
Action: Use provided coordinates directly, run script, present hourly data
User: "How hot will it be in Guangzhou today?"
Action: Extract "Guangzhou", use coordinates (23.1291, 113.2644), run script, identify maximum temperature for today
Error Handling
If configuration is missing:
- - Inform the user that credentials need to be configured
- Provide instructions on creating INLINECODE9
- Show the required JSON format
If API request fails:
- - Check if credentials are valid
- Verify network connectivity
- Display error message from the API response
- Suggest checking the configuration file
数智天气技能
本技能支持通过数智天气API查询天气预报,采用HMAC-SHA256认证方式,可获取任意位置的逐小时天气数据。
配置要求
重要提示:使用本技能前,您必须配置API凭证:
请在 ~/.openclaw/skills/shuzhi-weather/config.json 路径下创建配置文件,内容如下:
json
{
appkey: yourappkeyhere,
appsecret: yourappsecrethere
}
将 yourappkeyhere 和 yourappsecrethere 替换为您实际的数智API凭证。
配置优先级
本技能遵循以下配置优先级顺序:
- 1. 用户配置文件 ~/.openclaw/skills/shuzhi-weather/config.json(最高优先级)
- 平台环境变量(如可用)
- 默认值(如存在)
何时使用本技能
在以下情况下激活本技能:
- - 用户询问天气预报或天气信息
- 用户查询特定位置的温度
- 用户提出需要当前或未来数据的天气相关问题
- 用户提供位置名称并期望获取天气详情
技能组件
脚本
scripts/get_weather.py 脚本提供了一种可靠的方式,通过HMAC-SHA256认证从数智天气API获取天气数据。该脚本:
- - 从用户的config.json文件中加载凭证
- 生成双重HMAC-SHA256签名(URL签名 + 请求体签名)
- 向数智API发送经过认证的POST请求
- 返回包含逐小时温度的结构化天气数据
参考文档
references/apiresponseformat.md 包含数智天气API的文档,包括:
- - 请求参数(经度、纬度、逐小时数据类型)
- 响应格式及字段含义
- HMAC-SHA256认证机制
- 错误处理及响应码
工作流程
当本技能被激活时:
- 1. 检查配置 - 确认 ~/.openclaw/skills/shuzhi-weather/config.json 文件存在且包含有效凭证。如不存在,提示用户进行配置。
- 2. 提取位置信息 从用户查询中提取位置信息,可能包括:
- 城市名称(如北京、上海、广州)
- 具体坐标(纬度、经度)
- 描述性位置
- 3. 将位置转换为坐标:
- 如提供城市名称,使用地理编码获取经纬度
- 如直接提供坐标,直接使用
- 常用城市坐标:北京(39.9042, 116.4074)、上海(31.2304, 121.4737)、广州(23.1291, 113.2644)
- 4. 使用坐标执行天气脚本:
- 运行 scripts/get_weather.py,传入经度和纬度参数
- 脚本从config.json加载凭证
- 返回包含逐小时温度的结构化天气数据
- 5. 以自然可读的格式向用户呈现结果:
- 总结关键信息(当前温度、最高/最低温度、预报)
- 包含相关时间信息(未来24小时或用户提及的具体时间)
- 使用符合上下文的单位(默认使用摄氏度)
重要说明
- - 数智天气API需要双重HMAC-SHA256签名认证
- 使用前必须在 ~/.openclaw/skills/shuzhi-weather/config.json 中配置凭证
- 坐标格式:先经度,后纬度
- API端点使用POST方法,请求体为JSON格式
- 响应码200表示成功
- 如凭证缺失或无效,请告知用户检查其config.json文件
交互示例
用户:北京天气怎么样?
操作:检查配置文件是否存在,提取北京,使用坐标(39.9042, 116.4074),运行脚本,呈现天气预报
用户:明天上海会冷吗?
操作:提取上海和明天,使用坐标(31.2304, 121.4737),运行脚本,呈现明天的温度
用户:查询经度116.4074、纬度39.9042的温度
操作:直接使用提供的坐标,运行脚本,呈现逐小时数据
用户:今天广州有多热?
操作:提取广州,使用坐标(23.1291, 113.2644),运行脚本,识别今天的最高温度
错误处理
如配置缺失:
- - 告知用户需要配置凭证
- 提供创建 ~/.openclaw/skills/shuzhi-weather/config.json 的说明
- 显示所需的JSON格式
如API请求失败:
- - 检查凭证是否有效
- 验证网络连接
- 显示API响应中的错误信息
- 建议检查配置文件