infra/roles/hass-core/files/packages/weather.yaml

606 lines
21 KiB
YAML

# {{ state_attr("weather.home", "forecast")[0]['precipitation'] }}
# {{ state_attr("weather.forecast_home_hourly", "forecast")[0]['precipitation'] }}
# {{ state_attr("weather.forecast_home_hourly", "forecast")[1]['precipitation'] }}
# {{ state_attr("weather.owm_home", "forecast")[0]['precipitation'] }}
# {{ state_attr("weather.openmeteo_home", "forecast")[0]['precipitation'] }}
# {{ states("weather.openmeteo_home")|default("") == "rainy" }}
# {{ states("weather.home")|default("") == "rainy" }}
# {{ states("weather.forecast_home_hourly")|default("") == "rainy" }}
# {{ states("weather.owm_home")|default("") == "rainy" }}
homeassistant:
customize:
package.node_anchors:
common_attrs: &common_attrs
package: "weather"
common_attrs_templated: &common_attrs_templated
templated: true
<<: *common_attrs
sensor.blitzortung_lightning_distance:
# IDEA: currently using the attribute on 'binary_sensor.weather_lightning', but it
# might actually be easier to use an attribute on a different entity.
#
# This sensor already has state_class, device_class and unit_of_measurement set correctly
distance_threshold: 25.0
<<: *common_attrs
binary_sensor.rain_balcony_bucket:
friendly_name: Balcony tipping bucket rain sensor
templated: false
helper: true
helper_kind: "threshold"
helper_ui: true
comment: "A threshold helper sensor set up i the UI (to get it on the device page...)"
<<: *common_attrs
# binary_sensor.rain_balcony
binary_sensor.rain_balcony:
friendly_name: Rain detected on balcony
templated: false
group: true
comment: >-
Grouping rain detector sensors.
The sensor for the z-wave tipping bucket in the group is a helper set
up in the UI.
Neither the UI "threshold sensor" nor groups can set a 'delay_off', so
the group should be changed into a binary_sensor (template).
binary_sensor.meteoalarm:
friendly_name: "MeteoAlarm (EUMETNET)"
integration: true
<<: *common_attrs_templated
# sensor.weather_precipitation_met_no
sensor.weather_precipitation_met_no:
friendly_name: "Precipitation: met.no"
source_entity_id: "weather.home"
<<: *common_attrs_templated
# sensor.weather_precipitation_owm
sensor.weather_precipitation_owm:
friendly_name: "Precipitation: OWM"
source_entity_id: "weather.owm_home"
<<: *common_attrs_templated
# sensor.weather_precipitation_probability_owm
sensor.weather_precipitation_probability_owm:
friendly_name: "OWM Precipitation probability"
source_entity_id: "weather.owm_home"
<<: *common_attrs_templated
# sensor.chance_of_rain
sensor.chance_of_rain:
friendly_name: "Chance of rain"
source_entity_ids:
- "sensor.weather_precipitation_probability_owm"
- "sensor.pirateweather_precip_probability"
owm: "enabled"
pirateweather: "enabled"
<<: *common_attrs_templated
# sensor.weather_precipitation_owm_rain_snow
sensor.weather_precipitation_owm_rain_snow:
friendly_name: "Precipitation: OWM (rain + snow combined)"
source_rain: "sensor.owm_home_rain"
source_snow: "sensor.owm_home_snow"
<<: *common_attrs_templated
# sensor.weather_precipitation
sensor.weather_precipitation:
friendly_name: "Precipitation (weather APIs)"
source_entity_ids:
- "sensor.weather_precipitation_owm"
- "sensor.weather_precipitation_met_no"
- "sensor.pirateweather_precip_intensity"
owm: "enabled"
pirateweather: "enabled"
met_no: "enabled"
<<: *common_attrs_templated
# binary_sensor.weather_lightning
binary_sensor.weather_lightning:
friendly_name: "Lightning"
distance_threshold: 25.0
source_entity_id_counter: "sensor.blitzortung_lightning_counter"
source_entity_id_distance: "sensor.blitzortung_lightning_distance"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation_tomorrowio
binary_sensor.weather_precipitation_tomorrowio:
friendly_name: "Precipitation: Tomorrow.io"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation_pirateweather
binary_sensor.weather_precipitation_pirateweather:
friendly_name: "Precipitation: PirateWeather"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation_me_no
binary_sensor.weather_precipitation_met_no:
friendly_name: "Precipitation: met.no"
source_entity_id: "weather.home"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation_owm
binary_sensor.weather_precipitation_owm:
friendly_name: "Precipitation: OWM"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation_meteoalarm
binary_sensor.weather_precipitation_meteoalarm:
friendly_name: "Precipitation: MeteoAlarm (EUMETNET)"
<<: *common_attrs_templated
# binary_sensor.weather_precipitation
binary_sensor.weather_precipitation:
friendly_name: "Precipitation"
source_entity_ids:
- "binary_sensor.weather_precipitation_pirateweather"
- "binary_sensor.weather_precipitation_meteoalarm"
- "binary_sensor.weather_precipitation_met_no"
- "binary_sensor.weather_precipitation_owm"
- "binary_sensor.weather_precipitation_tomorrowio"
<<: *common_attrs_templated
# binary_sensor.weather_rain
binary_sensor.weather_rain:
friendly_name: "Rain"
comment: "easier to spell alias for binary_sensor.weather_precipitation"
<<: *common_attrs_templated
# statistics sensor
sensor.lightning_closest_distance:
friendly_name: "Lightning closest distance"
icon: "mdi:flash"
unit_of_measurement: "km"
<<: *common_attrs
automation:
- alias: meteoalarm_warning_notifications
id: meteoalarm_warning_notifications
trigger:
platform: state
entity_id: binary_sensor.meteoalarm
to: 'on'
action:
- service: notify.persistent_notification
data:
title: |
{% from 'formatting.jinja' import meteoalarm_title %}
{{ meteoalarm_title() }}
message: |
{% from 'formatting.jinja' import meteoalarm_message %}
{{ meteoalarm_message() }}
- service: notify.notify
data:
title: |
{% from 'formatting.jinja' import meteoalarm_title %}
{{ meteoalarm_title() }}
message: |
{% from 'formatting.jinja' import meteoalarm_message %}
{{ meteoalarm_message() }}
- alias: nina_warning_notifications
id: nina_warning_notifications
description: ""
mode: queued
trigger:
- platform: state
entity_id:
- binary_sensor.nina_warn_berlin_1
- binary_sensor.nina_warn_berlin_2
- binary_sensor.nina_warn_berlin_3
- binary_sensor.nina_warn_berlin_4
- binary_sensor.nina_warn_berlin_5
to: "on"
condition: []
action:
- service: notify.persistent_notification
data:
message: |
{% from 'formatting.jinja' import nina_message %}
{% set nina = trigger.entity_id %}
{{ nina_message(nina) }}
title: |
{% set nina = trigger.entity_id %}
{% from 'formatting.jinja' import nina_title %}
{{ nina_title(nina) }}
- service: notify.notify
data:
message: |
{% from 'formatting.jinja' import nina_message %}
{% set nina = trigger.entity_id %}
{{ nina_message(nina) }}
title: |
{% set nina = trigger.entity_id %}
{% from 'formatting.jinja' import nina_title %}
{{ nina_title(nina) }}
template:
- trigger:
- platform: time_pattern
minutes: /1
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.home
response_variable: hourly
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.owm_home
response_variable: owm_hourly
sensor:
- name: weather_precipitation_met_no
unit_of_measurement: "mm"
state_class: measurement
icon: "mdi:weather-rainy"
state: |
{{ hourly["weather.home"].forecast[0]["precipitation"] | float | round(1) }}
- name: weather_precipitation_owm
unit_of_measurement: "mm"
state_class: measurement
icon: "mdi:weather-rainy"
state: |
{{ owm_hourly["weather.owm_home"].forecast[0]["precipitation"] | float | round(1) }}
- name: "weather_precipitation_probability_owm"
unit_of_measurement: "%"
state: |
{{ owm_hourly["weather.owm_home"].forecast[0]["precipitation_probability"] | float | round(2) }}
- sensor:
- name: "chance_of_rain"
#unique_id: chance_of_rain
unit_of_measurement: "%"
icon: "mdi:weather-pouring"
device_class: power_factor
state_class: measurement
availability: |
{{
this.attributes.get("source_entity_ids")
| select('has_value')
| list
| length > 0
}}
state: |
{{
this.attributes.get("source_entity_ids")
| select('has_value')
| map('states')
| select('is_number')
| map('float')
| list
| median
| round(0)
}}
- name: weather_precipitation_owm_rain_snow
unit_of_measurement: "mm/h"
state_class: measurement
icon: "mdi:weather-rainy"
availability: |
{{
states("sensor.owm_home_rain") is defined
and states("sensor.owm_home_snow") is defined
and is_number(states("sensor.owm_home_rain"))
and is_number(states("sensor.owm_home_snow"))
}}
state: |
{% set rain = states("sensor.owm_home_rain") %}
{% set snow = states("sensor.owm_home_snow") %}
{% set combined = rain|float + snow|float %}
{{ combined|float | round(1) }}
- name: weather_precipitation
icon: "mdi:weather-rainy"
state_class: measurement
device_class: precipitation_intensity
unit_of_measurement: "mm/h"
availability: |
{{
this.attributes.get("source_entity_ids")
| select('has_value')
| list
| length > 0
}}
state: |
{{
this.attributes.get("source_entity_ids")
| select('has_value')
| map('states')
| select('is_number')
| map('float')
| list
| max
| round(4)
}}
- binary_sensor:
- name: weather_lightning
device_class: problem
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-lightning
{% else %}
mdi:weather-cloudy
{% endif %}
state: |
{% set cnt = states("sensor.blitzortung_lightning_counter")|int(0) -%}
{% set dist = states("sensor.blitzortung_lightning_distance")|float(0.0)|round(1) -%}
{% set dist_threshold = this.attributes.get("distance_threshold") -%}
{{
cnt > 0 and dist <= dist_threshold
and (
is_number(cnt)
and is_number(dist)
and is_number(dist_threshold)
)
}}
- name: weather_precipitation_tomorrowio
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
device_class: problem
attributes:
source_entity_id: "weather.tomorrow_io_s21_nowcast"
state: |
{% from 'weather.jinja' import precip %}
{{ precip("weather.tomorrow_io_s21_nowcast")|bool }}
- name: weather_precipitation_pirateweather
device_class: problem
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
availability: |
{{
is_number(states("sensor.pirateweather_precip_intensity"))
}}
state: |
{% set conditions = [
"exceptional",
"hail",
"lightning",
"lighting-rainy",
"pouring",
"rainy",
"snowy",
"snowy-rainy"
] -%}
{% set intens = states("sensor.pirateweather_precip_intensity") -%}
{{
intens|float > 0.2
or states("weather.pirateweather") in conditions
}}
- name: weather_precipitation_met_no
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
device_class: problem
state: |
{%
set conditions = [
"exceptional",
"hail",
"lightning",
"lighting-rainy",
"pouring",
"rainy",
"snowy",
"snowy-rainy"
]
-%}
{{
states("sensor.weather_precipitation_met_no")|float > 0.0
or states("weather.home") in conditions
}}
- name: weather_precipitation_owm
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
device_class: problem
state: |
{%
set conditions = [
"exceptional",
"hail",
"lightning",
"lighting-rainy",
"pouring",
"rainy",
"snowy",
"snowy-rainy"
]
-%}
{{
states("sensor.weather_precipitation_owm")|float(0.0) > 0.0
or states("weather.owm_home") in conditions
}}
# needs more data/research to see what values are in the event/category attributes
# there is an attrbitute indicating when the alart conditions start
- name: weather_precipitation_meteoalarm
device_class: problem
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
availability: |
{{ has_value("binary_sensor.meteoalarm") }}
state: |
{{
is_state("binary_sensor.meteoalarm", "on")
and is_state_attr("binary_sensor.meteoalarm", "category", "Met")
and (
"rain" in state_attr("binary_sensor.meteoalarm", "event")|lower
or "rain" in state_attr("binary_sensor.meteoalarm", "description")|lower
or "thunderstorm" in state_attr("binary_sensor.meteoalarm", "event")|lower
or "thunderstorm" in state_attr("binary_sensor.meteoalarm", "description")|lower
)
}}
attributes:
source_entity_id: binary_sensor.meteoalarm
- name: weather_precipitation
device_class: problem
icon: |
{% if is_state(this.entity_id, "on") %}
mdi:weather-rainy
{% else %}
mdi:weather-cloudy
{% endif %}
availability: |
{{
this.attributes.get("source_entity_ids")
| select('has_value')
| list
| length > 0
}}
state: |
{{
this.attributes.get("source_entity_ids")
| select("has_value")
| select("is_state", "on")
| list
| length > 0
}}
- name: weather_rain
device_class: problem
icon: |
{{ state_attr("binary_sensor.weather_precipitation", "icon") }}
availability: |
{{ has_value("binary_sensor.weather_precipitation") }}
state: |
{{ states("binary_sensor.weather_precipitation") }}
attributes:
#chance_of_rain_threshold: |
# {{ state_attr("binary_sensor.weather_precipitation", "chance_of_rain_threshold") }}
sources: |
{{ state_attr("binary_sensor.weather_precipitation", "sources") }}
binary_sensor:
- platform: meteoalarm
country: "germany"
province: "Berlin"
# example that should not affect the skylight
# {
# "language":"en",
# "category":"Health",
# "event":"strong heat",
# "responseType":"Prepare",
# "urgency":"Immediate",
# "severity":"Minor",
# "certainty":"Likely",
# "effective":"2023-08-13T09:38:00+02:00",
# "onset":"2023-08-14T11:00:00+02:00",
# "expires":"2023-08-14T19:00:00+02:00",
# "senderName":"Zentrum für Medizin-Meteorologische Forschung",
# "headline":"Official WARNING of STRONG HEAT",
# "description":"The expected weather will bring a situation of strong heat stress. (Level 1 of 3)\nHeight range: < 200 m",
# "instruction":"NOTE: be aware that this is an automatically generated product. The manually created original text warning is only available in German.It is issued by the DWD - Centre for Human Biometeorological Research (ZMMF) in Freiburg.",
# "web":"https://www.wettergefahren.de",
# "contact":"Deutscher Wetterdienst",
# "awareness_level":"2; yellow; Moderate",
# "awareness_type":"5; high-temperature",
# "attribution":"Information provided by MeteoAlarm",
# "device_class":"safety",
# "friendly_name":"MeteoAlarm (EUMETNET)",
# "integration":true,"
# templated":false,
# "package":"weather"
# }
#
# another one:
#
# {
# "language":"en",
# "category":"Health",
# "event":"extreme heat",
# "responseType":"Prepare",
# "urgency":"Immediate",
# "severity":"Severe",
# "certainty":"Likely",
# "effective":"2023-08-14T10:02:00+02:00",
# "onset":"2023-08-15T11:00:00+02:00",
# "expires":"2023-08-15T19:00:00+02:00",
# "senderName":"Zentrum für Medizin-Meteorologische Forschung",
# "headline":"Official SEVERE WARNING of EXTREME HEAT",
# "description":"The expected weather will bring a situation of extreme heat stress. (Level 3 of 3)\nHeight range: < 200 m",
# "instruction":"NOTE: be aware that this is an automatically generated product. The manually created original text warning is only available in German.It is issued by the DWD - Centre for Human Biometeorological Research (ZMMF) in Freiburg.",
# "web":"https://www.wettergefahren.de",
# "contact":"Deutscher Wetterdienst",
# "awareness_level":"4; red; Extreme",
# "awareness_type":"5; high-temperature",
# "attribution":"Information provided by MeteoAlarm",
# "device_class":"safety",
# "friendly_name":"MeteoAlarm (EUMETNET)",
# "package":"weather",
# "templated":true,"integration":true
# }
#
#
# binary_sensor.meteoalarm:
# category: "Health"
# event: "strong heat"
#
# same with dwd_current_warning_level sensors:
#
# {{ states.sensor.dwd_current_warning_level_fhain.attributes.warning_1_name }}
# STARKE HITZE
# {{ states.sensor.dwd_current_warning_level_fhain.attributes.warning_2_name }}
# EXTREME HITZE
# this should: {"language":"en","category":"Met","event":"heavy thunderstorms with gale- or storm-force gusts and heavy rain","responseType":"Prepare","urgency":"Immediate","severity":"Moderate","certainty":"Likely","effective":"2023-08-15T00:55:00+02:00","onset":"2023-08-15T01:00:00+02:00","expires":"2023-08-15T03:00:00+02:00","senderName":"Deutscher Wetterdienst","headline":"Official WARNING of HEAVY THUNDERSTORMS","description":"There is a risk of heavy thunderstorms with gale- or storm-force gusts and heavy rain (level 2 of 4).\nOccurrence: isolated; Approaching from: south-west; Max. gusts: < 70 km/h; Precipitation amounts: 15-25 l/m²/1h","instruction":"NOTE: Be aware of the following possible dangers: There is a risk of local lightning. Lightning strikes pose a danger to life. For instance, trees may sporadically be uprooted and roofs be damaged. Especially watch out for falling branches, tiles and other debris. The downpours can cause temporary traffic disruption.","web":"https://www.wettergefahren.de","contact":"Deutscher Wetterdienst","gusts":"<70 [km/h]","precipitation":"15-25 [l/m² in 1h]","occurrence":"isolated","direction of approach":"south-west","awareness_level":"3; orange; Severe","awareness_type":"3; Thunderstorm","attribution":"Information provided by MeteoAlarm","device_class":"safety","friendly_name":"MeteoAlarm (EUMETNET)","package":"weather","templated":true,"integration":true}
# {{ states.sensor.dwd_current_warning_level_fhain.attributes.warning_1_name }}
# STARKES GEWITTER
- platform: group
name: rain_balcony
device_class: moisture
all: false
entities:
- binary_sensor.rain_balcony_bucket
- binary_sensor.esphome_rainsensor_rain
sensor:
- name: lightning_closest_distance
platform: statistics
entity_id: sensor.blitzortung_lightning_distance
state_characteristic: value_min
max_age:
hours: 6