vault backup: 2025-02-17 20:48:44
This commit is contained in:
parent
6d0b16ddb5
commit
a82c23a7d0
@ -3,3 +3,60 @@
|
|||||||
- HomeAssistant 和风天气插件的自动化分享 https://www.bilibili.com/read/cv18078640/
|
- HomeAssistant 和风天气插件的自动化分享 https://www.bilibili.com/read/cv18078640/
|
||||||
# 和风天气 Token
|
# 和风天气 Token
|
||||||
afdc8b37975043888ad47943ff25b980
|
afdc8b37975043888ad47943ff25b980
|
||||||
|
|
||||||
|
|
||||||
|
# HA
|
||||||
|
在configuration.yaml中添加:
|
||||||
|
```YAML
|
||||||
|
template:
|
||||||
|
- trigger:
|
||||||
|
- platform: time_pattern
|
||||||
|
hours: "*"
|
||||||
|
action:
|
||||||
|
- service: weather.get_forecasts
|
||||||
|
data:
|
||||||
|
type: hourly
|
||||||
|
target:
|
||||||
|
entity_id: weather.he_feng_tian_qi
|
||||||
|
response_variable: hourly
|
||||||
|
sensor:
|
||||||
|
- name: "小时天气预警"
|
||||||
|
unique_id: weather_forecast_hourly
|
||||||
|
state: >
|
||||||
|
{% if hourly['weather.he_feng_tian_qi'].forecast[0].condition in ('sunny','cloudy','partlycloudy','windy') %}
|
||||||
|
off
|
||||||
|
{% else %}
|
||||||
|
on
|
||||||
|
{% endif %}
|
||||||
|
attributes:
|
||||||
|
states: >
|
||||||
|
{% if hourly['weather.he_feng_tian_qi'].forecast[0].condition in ('sunny','cloudy','partlycloudy','windy') %}
|
||||||
|
未来一小时,天气{{ hourly['weather.he_feng_tian_qi'].forecast[0].text }},没有降雨
|
||||||
|
{% else %}
|
||||||
|
接下来一小时会有{{ hourly['weather.he_feng_tian_qi'].forecast[0].text }},降水概率为 {{ hourly['weather.he_feng_tian_qi'].forecast[0].precipitation_probability }}%
|
||||||
|
{% endif %}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 自动化
|
||||||
|
对应的自动化:
|
||||||
|
```yaml
|
||||||
|
alias: 一小时天气预警
|
||||||
|
description: ""
|
||||||
|
triggers:
|
||||||
|
- entity_id:
|
||||||
|
- sensor.xiao_shi_tian_qi_yu_jing
|
||||||
|
trigger: state
|
||||||
|
actions:
|
||||||
|
- device_id: 384bea520a0ee825ecb63fb71d19b2a1
|
||||||
|
domain: mobile_app
|
||||||
|
type: notify
|
||||||
|
message: "注意注意! 接下来的天气为{{state_attr('sensor.xiao_shi_tian_qi_yu_jing','states')}} "
|
||||||
|
title: 天气预警
|
||||||
|
- action: notify.send_message
|
||||||
|
metadata: {}
|
||||||
|
data:
|
||||||
|
message: "[\"注意注意! {{state_attr('sensor.xiao_shi_tian_qi_yu_jing','states')}}\"]"
|
||||||
|
target:
|
||||||
|
entity_id: notify.xiaomi_cn_799945688_l06a_play_text_a_5_1
|
||||||
|
initial_state: true
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user