Weather Skill
Installation
npm
CODEBLOCK0
pnpm
CODEBLOCK1
Parameters
- -
-V, --version: output the version number - INLINECODE1 : Location to get the weather for
- INLINECODE2 : Specify the number of days to get the weather forecast for.
- INLINECODE3 : Specify the number of hours to get the weather forecast for.
- INLINECODE4 : Path to the config file
- INLINECODE5 : Latitude and longitude to get the weather for (format: lon,lat)
- INLINECODE6 : display help for command
Parameter constraints:
- -
--location and --coordinates cannot be used together. You must provide at least one of them. - INLINECODE9 and
--hours cannot be used together. If neither is provided, real-time weather will be returned.
Environment variables:
- -
SKILLS_WEATHER_CONFIG_FILE_PATH: Optional environment variable to specify the path to the configuration file. If not provided, the skill will look for a default config file in the current directory.
Examples
Get real-time weather:
- - Get real-time weather for New York: INLINECODE12
- Get real-time weather for specific coordinates: INLINECODE13
- Get real-time weather for London (with a specified config file): INLINECODE14
Get daily weather forecasts:
- - Get today's weather forecast for Futian District, Shenzhen: INLINECODE15
- Get Beijing's weather forecast for the next 3 days: INLINECODE16
- Get a one-month weather forecast for specific coordinates: INLINECODE17
- Get Shanghai's weather forecast for the next 2 days (with a specified config file): INLINECODE18
Get hourly weather forecasts:
- - Get Guangzhou's weather forecast for the next 12 hours: INLINECODE19
- Get a 6-hour weather forecast for specific coordinates: INLINECODE20
- Get Shenzhen's weather forecast for the next 24 hours (with a specified config file): INLINECODE21
Supported Weather Data Providers
Configuration File
Default config file path: ~/.skills-weather-config.json
Example:
CODEBLOCK2
Field Descriptions
- -
privateKey: A private key provided by QWeather for authentication. - INLINECODE24 : The application ID provided by QWeather to identify the app.
- INLINECODE25 : A credential ID provided by QWeather for authentication.
- INLINECODE26 : The host address of the QWeather API.
天气技能
安装
npm
bash
npm install -g skills-weather
pnpm
bash
pnpm add -g skills-weather
参数
- - -V, --version:输出版本号
- -l, --location :获取天气的位置
- -d, --days :指定获取天气预报的天数
- -h, --hours :指定获取天气预报的小时数
- -f, --config :配置文件的路径
- -c, --coordinates :获取天气的经纬度(格式:经度,纬度)
- --help:显示命令帮助
参数约束:
- - --location 和 --coordinates 不能同时使用。必须至少提供其中一个。
- --days 和 --hours 不能同时使用。如果两者都未提供,将返回实时天气。
环境变量:
- - SKILLSWEATHERCONFIGFILEPATH:可选环境变量,用于指定配置文件的路径。如果未提供,技能将在当前目录中查找默认配置文件。
示例
获取实时天气:
- - 获取纽约的实时天气:skills-weather -l New York
- 获取指定坐标的实时天气:skills-weather -c -74.0060,40.7128
- 获取伦敦的实时天气(使用指定配置文件):skills-weather -l London -f /path/to/config.json
获取每日天气预报:
- - 获取深圳福田区今天的天气预报:skills-weather -l futian -d 1
- 获取北京未来3天的天气预报:skills-weather -l 北京 -d 3
- 获取指定坐标未来一个月的天气预报:skills-weather -c 116.4074,39.9042 -d 30
- 获取上海未来2天的天气预报(使用指定配置文件):skills-weather -l 上海 -d 2 -f /path/to/config.json
获取逐小时天气预报:
- - 获取广州未来12小时的天气预报:skills-weather -l 广州 -h 12
- 获取指定坐标未来6小时的天气预报:skills-weather -c 121.4737,31.2304 -h 6
- 获取深圳未来24小时的天气预报(使用指定配置文件):skills-weather -l 深圳 -h 24 -f /path/to/config.json
支持的天气数据提供商
配置文件
默认配置文件路径:~/.skills-weather-config.json
示例:
json
{
privateKey: G7refSYx9TWAPADGuOdyGycWVNr0POaebYddeNtDjxSSN01b0165TITV9fA=,
appId: BB9A36BAB1,
credentialId: 3207A9092A,
apiHost: 0dfe03a7c3.re.qweatherapi.com
}
字段说明
- - privateKey:和风天气提供的用于身份验证的私钥。
- appId:和风天气提供的用于标识应用的应用程序ID。
- credentialId:和风天气提供的用于身份验证的凭证ID。
- apiHost:和风天气API的主机地址。