About 查询天气
A Home Assistant integration that brings QWeather (和风天气) forecasts and disaster warnings into Home Assistant. It suits Home Assistant users who want local weather data and can build hourly rain alerts with template sensors.
Key features
- 01Uses the official QWeather API with JWT credentials
- 02Weather lookup by city or coordinates
- 03Selectable disaster warning severity levels
- 04Warning output as title only or full details
Use cases
- 01Showing local weather in Home Assistant
- 02Setting up an hourly rain alert with a template sensor
- 03Writing automations based on weather data
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
12Saved tool list · updated 3w ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| location | string | Yes | Longitude and latitude |
Details
From the project README
和风天气 homeassistant插件
如果觉得对你有帮助,就来b站支持一波吧:小愚
配置说明:
1.使用和风官方最新api版本
2.必须申请开发者账号里的免费api,请务必升级到开发者账号(免费,api权限会比普通用户高一些)https://console.qweather.com/#/console
3.appkey申请需要先创建项目,后选创建凭据,建议选择 JSON Web Token (JWT) ,公钥见第5步
4.在HACS商店中搜索heweather,找到本插件并下载
5.设置->设备与服务->添加集成->搜索heweather->选择本插件,同时建议使用JWT凭证,(API模式将在2027年废弃)。
项目id点击已创建的项目后可见。
凭据id在创建凭据后可见,创建JWT凭据时粘贴ha页面显示的公钥即可。
HOST地址见设置页面
国内的城市区域location、经纬度关系:
https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
-
关注的自然灾害等级,1-6为从轻微到严重, 代表在灾害预警里你关注的灾害等级。
"Standard": "标准的",
"Minor": "次要的",
"Moderate": "中等的",
"Major": "主要",
"Severe": "严重",
"Extreme": "极端"
只显示标题即只在灾害预警text中透出灾害标题,显示标题+明细信息则会在text中透出全部信息(会比较长)
一小时天气预警
需要自己在template里配置一个sensor模板,可以参考我的配置(读取小时级天气预报,然后判断是否有雨雪天气,有的话sensor的状态会被置为on,同时sensor的states的值即为具体的天气信息和降水概率)
template:
- trigger:
- platform: time_pattern
hours: "*"
action:
- service: weather.get_forecasts
target:
entity_id: weather.he_feng_tian_qi
data:
type: hourly
response_variable: forecast
sensor:
- name: heweather_rain_warn
unique_id: heweather_rain_warn
state: >
{% if forecast['weather.he_feng_tian_qi'].forecast[0].condition in ('sunny','cloudy','partlycloudy','windy') %}
off
{% else %}
on
{% endif %}
attributes:
states: >
{% if forecast['weather.he_feng_tian_qi'].forecast[0].condition in ('sunny','cloudy','partlycloudy','windy') %}
未来一小时,天气{{ forecast['weather.he_feng_tian_qi'].forecast[0].text }},没有降雨
{% else %}
接下来一小时会有{{ forecast['weather.he_feng_tian_qi'].forecast[0].text }},降水概率为 {{ forecast['weather.he_feng_tian_qi'].forecast[0].precipitation_probability}}%
{% endif %}
自动化配置实例
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.