『瀚思彼岸』» 智能家居技术论坛

标题: HomeAssistant插件【和风天气v7】【20250420更新】 [打印本页]

作者: c1pher_小愚    时间: 2022-7-28 15:25
标题: HomeAssistant插件【和风天气v7】【20250420更新】
本帖最后由 25989406 于 2025-4-29 10:35 编辑

前言

我使用的插件最早引用论坛 Golden_Soap大佬的插件,但该插件很久没有更新过配置,导致我的环境一直无法运行,自己肝的原因主要是懒得改之前的参数配置,换插件全得改一遍,有的数据还没了,又正好借着这个机会能再学习下插件的逻辑,哈哈哈。
如果觉得对你有帮助,就来b站支持一波吧:
https://www.bilibili.com/video/BV16t4y1g7Ey

------202306最新修改------
202306版本升级了底层python环境,从python10升到11,升级变化较大,插件修正更新 支持新版

------0316最新修改------
修正部分请求接口超时带来的错误提示,适配修复2023.3.4版本的weather实体的属性信息(应该是01月份版本引入的)

------0923最新修改------数据整合,去掉多余的sensor,只需要配置weather和sensor两个配置即可
原来在sensor里的24小时天气,转移到weather中内置。
sensor中的传感器说明全部修正成中文。

------20231218------上架HACS商店!!!

-----20250420----更新:


支持WebUI 添加集成


支持开发者修改API Host(针对和风天气公告的调整:https://blog.qweather.com/post/console-v4/

github地址:

[hide]
https://github.com/c1pher-cn/heweather
使用要求ha版本为 202309(包含)以及后续版本
A.手动安装方法:
新版本只需要下载/custom_components/heweather/ 文件夹里的sensor.py weather.py manifest.json三个文件到你HA主配置文件的 /custom_components/heweather/ 目录
然后按说明里的方法在yaml里配置weather和sensor

B.HACS安装:
商店搜索 heweather 单击进入后

                               
登录/注册后可看大图

点击右下角下载

                               
登录/注册后可看大图

然后按说明里的方法在yaml里配置weather和sensor





[/hide]






效果:

[attach]51739[/attach][attach]51741[/attach][attach]51742[/attach][attach]51743[/attach][attach]51740[/attach]
[attach]39766[/attach]

主要配置说明:
1.使用和风官方apiv7版本
2.必须申请开发者账号里的免费api,请务必升级到开发者账号(免费,但要提交身份证审核,api权限会比普通用户高一些)[color=var(--fgColor-accent, var(--color-accent-fg))]https://console.qweather.com/#/console
3.appkey申请需要先[color=var(--fgColor-accent, var(--color-accent-fg))]创建应用,后选添加数据key,选wabapi即可
[backcolor=var(--bgColor-muted, var(--color-canvas-subtle))]国内的城市区域location关系:https://github.com/qwd/LocationL ... ity-List-latest.csv
4.在和风控制台的设置页面查看自己分配的API host:https://console.qweather.com/setting?lang=zh

                               
登录/注册后可看大图

5.新版本整合优化了sensor以及相关中文名字,图标。将原有的24小时天天气预报从sensor中转移到weather里

配置方法
1.heweather(七日天气预报),放在weather里
  1. weather:
  2.   - platform: heweather
  3.     location: 101210106        # 填写你所在区域代码Location_ID,https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
  4.     host: devapi.qweather.com  # 开发者信息中的API Host
  5.     key: ABCDE                 # api平台申请的key
复制代码

2.heweather(天气情况、空气质量、自然灾害预警),放在sensor里
  1. sensor:
  2.   - platform: heweather
  3.     location: 101210106        # 填写你所在区域代码Location_ID,https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv
  4.     host: devapi.qweather.com  # 开发者信息中的API Host
  5.     key: ABCDE                 # api平台申请的key
  6.     disasterlevel: 3
  7.     disastermsg: allmsg
复制代码

sensor里的其他两个参数:
  disasterlevel:表示关注的自然灾害等级,1-6为从轻微到严重
  配置3表示关注 >=3级的灾害

  Standard           1 最轻微
  Minor               2
  Moderate          3
  Major               4  
  Severe              5
  Extreme            6  最严重  

disastermsg:表示灾害预警是否显示灾害的明细信息
  title 只显示标题
  allmsg 显示标题+明细信息
















作者: Roger    时间: 2022-7-28 16:06
收藏了,谢谢!
作者: zhanfu86    时间: 2022-7-28 16:28
专门登录来顶你
作者: 88802270    时间: 2022-7-28 16:48
收藏了,谢谢!
作者: yuyuye    时间: 2022-7-28 16:59
蛮好,又一个和风插件,帮顶。虽然我个人已重回彩云怀抱。
作者: lhlxx2010    时间: 2022-7-28 17:05
收藏了,谢谢!
作者: Ari    时间: 2022-7-28 17:05
哎呀,没抢上沙发!顶
作者: 26501782    时间: 2022-7-28 17:16
adasdasdasda
作者: wbdownn    时间: 2022-7-28 17:21
我第一个用的就是和风,后来换了彩云,感觉更准
作者: chesley    时间: 2022-7-28 21:20
顶大神,学习一下
作者: zhuguoqing    时间: 2022-7-28 22:21
顶大神,用财运的路过
作者: w64180974    时间: 2022-7-28 22:22
很厉害,谢谢
作者: jck773656345    时间: 2022-7-28 22:56
6666支持
作者: usrusr22    时间: 2022-7-28 23:23
专门登录来顶你
作者: ss454534    时间: 2022-7-28 23:58
HomeAssistant插件【和风天气v7】【
作者: wmhack    时间: 2022-7-28 23:58
看着不错额额的呃
作者: wmhack    时间: 2022-7-29 00:14
可以把配置文件configuration.yaml,直接贴出来一下吗?小白有点不知道怎么放
作者: c1pher_小愚    时间: 2022-7-29 00:34
wmhack 发表于 2022-7-29 00:14
可以把配置文件configuration.yaml,直接贴出来一下吗?小白有点不知道怎么放

更新了,sensor要跟已有的配置合并,剩下的直接放在你的configuration.yaml就好了
作者: rabbit8686    时间: 2022-7-29 05:30
学习了,谢谢
作者: xyz1943    时间: 2022-7-29 08:26
謝謝大大的分享
作者: fang53    时间: 2022-7-29 09:33
收藏了,謝謝大大的分享.
作者: dx27    时间: 2022-7-29 11:11
顶大神,学习一下

作者: rivoldo    时间: 2022-7-29 11:11
比彩云的漂亮,多谢了
作者: dinson    时间: 2022-7-29 11:28

收藏了,谢谢!
作者: wmhack    时间: 2022-7-29 22:08
25989406 发表于 2022-7-29 00:34
更新了,sensor要跟已有的配置合并,剩下的直接放在你的configuration.yaml就好了 ...

谢谢大佬,现在非常清晰了
作者: wmhack    时间: 2022-7-29 22:33
我按照大佬的配置,加好了,但是没有展示出来,是怎么回事呢?重启了几次也是一样不显示
作者: Bighippo    时间: 2022-7-29 23:09
学习学习
作者: wmhack    时间: 2022-7-29 23:17
大佬,希望能够完整把组件和配置文件,打包发一下额,现在总是不成功,看了一下以前的和风插件,还有很多文件和配置的
作者: EK17    时间: 2022-7-29 23:29
謝謝分享

作者: c1pher_小愚    时间: 2022-7-30 04:42
wmhack 发表于 2022-7-29 23:17
大佬,希望能够完整把组件和配置文件,打包发一下额,现在总是不成功,看了一下以前的和风插件,还有很多文 ...

需要的文件都在github里,按目录格式下载就行了,我不会再额外打包。 运行不成功不贴日志的话没人能帮到你
作者: dragonfly    时间: 2022-7-30 10:29
是否真的有效,查查看
作者: hxkjc    时间: 2022-7-30 10:46

收藏了,谢谢!
作者: wmhack    时间: 2022-7-30 11:15
25989406 发表于 2022-7-30 04:42
需要的文件都在github里,按目录格式下载就行了,我不会再额外打包。 运行不成功不贴日志的话没人能帮到 ...

好像是缺了 group:  配置额
作者: c1pher_小愚    时间: 2022-7-30 12:06
wmhack 发表于 2022-7-30 11:15
好像是缺了 group:  配置额

Group怎么展示是你自己的事情啊,前台自己配置,跟插件本身没关系
作者: wmhack    时间: 2022-7-30 12:49
本帖最后由 wmhack 于 2022-7-30 12:52 编辑
25989406 发表于 2022-7-30 12:06
Group怎么展示是你自己的事情啊,前台自己配置,跟插件本身没关系

Logger: homeassistant.components.weather
Source: custom_components/heweather_forecast/weather.py:81
Integration: Weather (documentation, issues)
First occurred: 12:42:32 (1 occurrences)
Last logged: 12:42:32

Error while setting up heweather_forecast platform for weather
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/heweather_forecast/weather.py", line 69, in async_setup_platform
    async_add_devices([LocalWeather(data)], True)
  File "/config/custom_components/heweather_forecast/weather.py", line 81, in __init__
    self._temperature_unit = None






[backcolor=var(--mdc-theme-surface, #fff)][color=var(--mdc-dialog-content-ink-color, rgba(0, 0, 0, 0.6))]Logger: custom_components.heweather_forecast.weather
Source: custom_components/heweather_forecast/weather.py:298
Integration: heweather_forecast ([color=var(--primary-color)]documentation
)
First occurred: 12:42:32 (1 occurrences)
Last logged: 12:42:32
Error while accessing: https://devapi.qweather.com/v7/w ... 7acaxxxxxxxxxxxx






作者: eddies    时间: 2022-7-30 15:27
回复一下顶一下看看
作者: c1pher_小愚    时间: 2022-7-30 17:13
wmhack 发表于 2022-7-30 12:49
Logger: homeassistant.components.weather
Source: custom_components/heweather_forecast/weather.py:81 ...

我晚上回家看看
作者: dante210402    时间: 2022-7-30 17:37
感谢分享~~
作者: c1pher_小愚    时间: 2022-7-30 21:20
wmhack 发表于 2022-7-30 12:49
Logger: homeassistant.components.weather
Source: custom_components/heweather_forecast/weather.py:81 ...

你的key和权限应该都没问题,感觉是没拿到数据或者超时,重启试试看
正常拿到数据后的主要实体:
小时天气预报
sensor.hourly_forcast_*
天气、空气情况
sensor.heweather_**
生活指数
sensor.suggestion_**

7天天气预报(ha主界面添加天气卡片即可)
weather.localweather
极端天气预警
sensor.heweather_disaster_warn
一小时天气预警
sensor.remind
作者: wmhack    时间: 2022-7-31 16:40
25989406 发表于 2022-7-30 21:20
你的key和权限应该都没问题,感觉是没拿到数据或者超时,重启试试看
正常拿到数据后的主要实体:
小时天 ...

我重启过很多次了,都是不能不行额,而且上面那个保存,感觉代码有问题额
作者: 狗屎一刀斩    时间: 2022-7-31 17:57
来了来了
作者: c1pher_小愚    时间: 2022-7-31 18:30
wmhack 发表于 2022-7-31 16:40
我重启过很多次了,都是不能不行额,而且上面那个保存,感觉代码有问题额 ...

那也不至于四个代码全有问题吧
作者: wmhack    时间: 2022-7-31 20:31
25989406 发表于 2022-7-31 18:30
那也不至于四个代码全有问题吧

也是的,另外,我装了彩云天气,不知道有没有冲突额
作者: youniss    时间: 2022-7-31 22:48

作者: 河边的泡泡    时间: 2022-8-1 08:38
看看

论坛助手,iPhone
作者: c1pher_小愚    时间: 2022-8-1 10:14
wmhack 发表于 2022-7-31 20:31
也是的,另外,我装了彩云天气,不知道有没有冲突额

不会冲突,没关系
作者: wmhack    时间: 2022-8-1 23:02
25989406 发表于 2022-8-1 10:14
不会冲突,没关系

我是用的最新版本的HA,有影响吗
作者: tc0077    时间: 2022-8-2 11:04
谢谢分享~~! 支持@@NB!!
作者: c1pher_小愚    时间: 2022-8-2 11:35
wmhack 发表于 2022-8-1 23:02
我是用的最新版本的HA,有影响吗

我用的6月份版本,虽然不是最新,但应该没问题
作者: tangyali    时间: 2022-8-2 12:35
谢谢楼主分享
作者: 13990973177    时间: 2022-8-2 12:43

收藏了,谢谢!
作者: jooney3123    时间: 2022-8-2 14:53
赞一个。收藏先  感谢!
作者: schymatter    时间: 2022-8-2 15:45
顶一下!!!!!!!!1
作者: ZSW    时间: 2022-8-2 16:16
好东西,正是我需要的
作者: cotontru    时间: 2022-8-2 16:35
牛蛙牛蛙
作者: rongws    时间: 2022-8-3 09:28
学习一下,谢谢
作者: arthurfsy    时间: 2022-8-3 10:11
信息很多,先了解一下
作者: flow    时间: 2022-8-3 10:24
学习一下看看怎么配置
作者: zfrf52    时间: 2022-8-3 10:50
谢谢 看看正好有需求

作者: greathaoqi    时间: 2022-8-3 11:22
学习下大佬!!
作者: hyhrobot    时间: 2022-8-3 12:21
感谢分享
作者: Kingfeng    时间: 2022-8-3 14:15
感谢分享 我试试
作者: 27635155    时间: 2022-8-3 20:00
支持一波,学习了。。。。
作者: y17920    时间: 2022-8-4 16:23
感谢大佬
作者: menlsux    时间: 2022-8-4 22:48
感谢分享
作者: zw459123678    时间: 2022-8-5 00:35
新手前来观摩
作者: 520key    时间: 2022-8-5 09:02
感谢楼主分享!
作者: hitomr    时间: 2022-8-5 15:16
谢谢分享
作者: zhfan    时间: 2022-8-6 06:41
支持楼主
作者: dedihao    时间: 2022-8-6 13:55
感谢分享教程
作者: fxzz365    时间: 2022-8-6 15:18
厉害,谢谢
作者: yaoy    时间: 2022-8-7 08:15
楼主威武~
作者: yaoy    时间: 2022-8-7 09:13
楼主求助~~~
我把文件 拷贝到了 /root/config/custom_components  ,然后重新配置了 configuration.yaml ,然后重启了 (没有看到加载错误)
在概览中  没有新的设备(没有变化)
作者: yaoy    时间: 2022-8-7 10:48
楼主~ 这个有对应的卡片么?
作者: tonytcf    时间: 2022-8-7 20:08
我是来学习的
作者: c1pher_小愚    时间: 2022-8-7 21:16
yaoy 发表于 2022-8-7 10:48
楼主~ 这个有对应的卡片么?

天气卡片可以直接用,其他的都是sensor类型的实体,没特殊卡片
作者: c1pher_小愚    时间: 2022-8-7 21:18
yaoy 发表于 2022-8-7 09:13
楼主求助~~~
我把文件 拷贝到了 /root/config/custom_components  ,然后重新配置了 configuration.yaml  ...

看日志,有问题会报错的
作者: shadowba    时间: 2022-8-8 09:17
哦?你这通知推送咋实现的?企业微信?
作者: c1pher_小愚    时间: 2022-8-8 09:56
shadowba 发表于 2022-8-8 09:17
哦?你这通知推送咋实现的?企业微信?

这是app自带的推送,设置了个自动化,发现异常天气告警推送+本地tts
作者: 56268888    时间: 2022-8-8 12:19
学习一下,正好遇到这个问题了哈哈哈。谢谢!
作者: sepeighth    时间: 2022-8-8 13:54
感谢分享
作者: coolhotsz    时间: 2022-8-16 10:28
学习一下
作者: hxkjc    时间: 2022-8-16 11:10

收藏了,谢谢!
作者: fang316    时间: 2022-8-16 12:38
感谢分享
作者: s6471165    时间: 2022-8-16 14:48
谢谢谢谢谢
作者: zheng1112    时间: 2022-8-16 15:18
多谢分享,学习学习。
作者: whity233    时间: 2022-8-16 15:24
支持一下

作者: jiabccc    时间: 2022-8-17 09:40
学习一下学习一下
作者: ashlikesnow    时间: 2022-8-19 14:08
让我康康
作者: maomao000    时间: 2022-8-19 14:58

收藏了,谢谢!
作者: coolxin    时间: 2022-8-19 16:34
大佬大佬111111111111
作者: shiweizhen12@gm    时间: 2022-8-19 17:20
不知道为啥我的天气没用了
作者: Kakemeta    时间: 2022-8-20 17:12
下载了我也去试一下
作者: cjy199387    时间: 2022-8-20 17:32
牛逼啊啊啊啊啊啊啊啊啊
作者: avatasia    时间: 2022-8-20 18:45
感谢楼主, 辛苦啦。



作者: chenyang931101    时间: 2022-8-20 18:55
回复支持
作者: avatasia    时间: 2022-8-20 19:31
weather:
  - platform: heweather_forecast

请问下这个配置该如何生效。
另外灾害预警 已经 reminder这个, 现在好像没有啦。
作者: heapcn    时间: 2022-8-20 21:41
看看,支持楼主
作者: sefeng    时间: 2022-8-22 11:41
感谢楼主分享!
作者: sefeng    时间: 2022-8-22 13:02
最新版配置文件报错,无法生效




欢迎光临 『瀚思彼岸』» 智能家居技术论坛 (https://bbs.hassbian.com/) Powered by Discuz! X3.5