本帖最后由 misLia 于 2025-2-17 14:10 编辑
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 %}
- action:
- service: weather.get_forecasts
target:
entity_id: weather.he_feng_tian_qi
data:
type: daily
response_variable: forecast
sensor:
- name: max_temperature
unique_id: max_temperature
unit_of_measurement: "°C"
state: >-
{{forecast['weather.he_feng_tian_qi'].forecast[0].temperature}}
大佬能帮我看看嘛?上面那段action是根据你文档里加的小时降雨预报。最下面那个action是我照着上面这个小时降雨预报加的一段。但是折腾半天了,都是“不可用”。
|