
当前天气、空气质量、生活指数建议
灾害天气预警
小时级天气预报、七日天气预报

天气预警、天气预报总览

近7天天气预报

24小时天气预报

生活指数、空气质量信息
前言
我使用的插件最早引用自瀚思彼岸论坛Golden_Soap大佬的插件(https://bbs.hassbian.com/thread-3971-1-1.html),但该插件一直没有更新过配置,导致我的环境一直无法运行,自己肝的原因主要是懒得改之前的参数配置,换插件全得改一遍,有的数据还没了,又正好借着这个机会再学习一边插件,所以就有了这个插件,废话不说上地址
https://github.com/c1pher-cn/heweather
1.使用和风官方apiv7版本
2.需要使用开发者账号里的免费api,普通用户请务必升级到开发者账号(免费,但要提交身份证审核,api权限会比普通用户高一些)https://console.qweather.com/#/console
3.appkey申请需要先[创建应用](https://console.qweather.com/#/apps),后选添加数据key,选wabapi即可
4.配置里的Location_ID 如何获取?详见https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
0.下载相关文件
先按github上的文件目录格式把对应文件拷贝到HomeAssistant的custom_components目录,
想用hacs商店的同学需要晚一点(HACS商店的配置预计会在12月底左右上线,9月就提交了,审批进度贼慢,在hacs商店里搜索haweather后安装后进行yaml配置编写)
正确下载文件后的文件目录格式:
custom_components/
--heweather
--manifest.json
--sensor.py
--weather.py
注意,无论使用哪种安装方式,本插件都必须进行下面的yaml配置后才能看到具体信息!!!
1.weather下的heweather(七日天气预报)
weather:
- platform: heweather
location: 101210106 # 填写你所在区域代码Location_ID,https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
key: ABCDE # api平台申请的key
2.sensor下的heweather(天气情况、空气质量、自然灾害预警)
sensor:
- platform: heweather
location: 101210106 # 填写你所在区域代码Location_ID,https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
key: ABCDE # api平台申请的key
disasterlevel: 3
disastermsg: allmsg disasterlevel的数字表示关注的自然灾害等级,配置3表示关注 >=3级的灾害
1 Standard
2 Minor
3 Moderate
4 Major
5 Severe
6 Extreme disastermsg表示灾害预警是否显示灾害的明细信息
title 只显示标题
allmsg 显示标题+明细信息
3.相关传感器名称:
已有中文翻译配出来就能看到,文档里我就不对应写了,另外如果配置多个heweather或者修改过key和location信息的话,找不到新实体时可以注意一下,新实体id后面会新增一个_2 _3
天气预报,7天,24小时级别都在这里面
weather.he_feng_tian_qi
生活指数
sensor.shu_gua_du_zhi_shu
sensor.kong_qi_wu_ran_kuo_san_tiao_jian_zhi_shu
sensor.lu_xing_zhi_shu
sensor.chuan_yi_zhi_shu
sensor.fang_shai_zhi_shu
sensor.jiao_tong_zhi_shu
sensor.guo_min_zhi_shu
sensor.gan_mou_zhi_shu
sensor.xi_che_zhi_shu
sensor.zi_wai_xian_zhi_shu
sensor.tai_yang_jing_zhi_shu
空气信息
sensor.heweather_level
sensor.heweather_category
sensor.heweather_qlty
sensor.heweather_primary
sensor.heweather_pm25
sensor.heweather_pm10
sensor.heweather_no2
sensor.heweather_so2
sensor.heweather_o3
sensor.heweather_dew
sensor.heweather_cloud
sensor.heweather_precip
sensor.heweather_pressure
sensor.heweather_vis
4.关于两个预警信息
灾害预警有具体有配置实体:sensor.heweather_disaster_warn,为了方便做相关自动化,传感器状态为on时,表示有相关灾害,灾害信息存在States里

近一小时天气预警:
需要自己在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 %}

每日起床第一次出卧室的天气tts播报,或类似的日常播报需求
根据自然灾害预警的信息发信息通知
根据小时天气预警的内容进行信息通告
>>>>>和风天气自动化分享

既然看到这里了,配置成功后记得给个三联关注哦