0%

HomeAssistant 集成和风天气

HomeAssistant 接入和风天气。

HA Version: 0.94.4

首先用京东帐号申请一个和风API,请注意,是京东万象平台,不是从风天气官网申请的 API 。

1. hf_weather 组件实现

1.1. 预览

001

002

1.2 下载组件

下载组件 ,放入 HA 对应目录。

1.3. 配置 configurations.yaml

配置 configuration.yaml

1
2
3
4
5
weather:
- platform: hf_weather
name: hefengweather
city: shanghai
appkey: YOUR_API_KEY

启用 sun 组件

1
sun:

lovelace 启用天气卡片(首页右上角“配置 UI - 原始配置编辑器”)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 引入自定义卡片hf_weather-card
resources:
- type: module
url: /local/custom-lovelace/hf_weather-card/hf_weather-card.js
- type: module
url: /local/custom-lovelace/hf_weather-card/hf_weather-more-info.js
# 在view里面的cards节点,增加天气卡片类型
views:
path: default_view
title: Home
cards:
... ...
- type: 'custom:hf_weather-card' # card类型
entity: weather.hefengweather # entityid
mode: daily # hourly按小时天气预报、daily按天天气预报,不设置则同时显示
title: 和风天气 # 标题,不设置则使用entity的friendly_name
icons: /local/custom-lovelace/hf_weather-card/icons/animated/ # 图标路径,不设置则采用cdn,结尾要有"/"

如果不从原始编辑器中添加,也可添加 ENTITY,在 entity 的编辑器中编辑如下:

1
2
3
4
5
entity: weather.hefengweather
icons: /local/custom-lovelace/hf_weather-card/icons/animated/
title: 和风天气
type: 'custom:hf_weather-card'
mode: hourly

2. HeWeather组件实现

HeWeather

2.1 下载组件

下载组件 ,放入 HA 对应目录。

2.2 配置

编辑 heweather.yaml ,填充对应 appkey ,

1
2
3
4
5
sensor:
- platform: heweather
city: shanghai
appkey: 905195***************3627c7f781d
... ...

配置 configurations.yaml ,添加 packages:

1
2
3
4
homeassistant:
... ...
customize: !include customize.yaml
packages: !include_dir_named packages # 添加此行

2.3 HA 中添加 entity

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
- cards:
- entity: weather.localweather
name: 上海天气
type: weather-forecast
- entities:
- entity: sensor.remind
- entity: sensor.hourly_forcast_3
- entity: sensor.hourly_forcast_6
- entity: sensor.hourly_forcast_9
show_header_toggle: false
title: 小时天气预报
type: entities
- entities:
- entity: sensor.suggestion_air
- entity: sensor.suggestion_comf
- entity: sensor.suggestion_cw
- entity: sensor.suggestion_drsg
- entity: sensor.suggestion_flu
- entity: sensor.suggestion_sport
- entity: sensor.suggestion_trav
- entity: sensor.suggestion_uv
show_header_toggle: false
title: 品质生活
type: entities
- entities:
- entity: sensor.heweather_qlty
- entity: sensor.heweather_no2
- entity: sensor.heweather_pm25
- entity: sensor.heweather_co
- entity: sensor.heweather_so2
- entity: sensor.heweather_o3
show_header_toggle: false
title: 本地空气质量
type: entities
Donate comment here.