367 lines
14 KiB
YAML
Executable File
367 lines
14 KiB
YAML
Executable File
###############################################################################
|
||
# @author : Jeffrey Stone
|
||
# @date : 02/19/2019
|
||
# @package : Weather
|
||
# @description : Weather and NWS Alerts
|
||
# @original : https://github.com/Vasiley/Home-Assistant-Main/blob/master/packages/weather_alerts_nws.yaml
|
||
###############################################################################
|
||
|
||
homeassistant:
|
||
customize:
|
||
package.node_anchors:
|
||
customize: &customize
|
||
package: 'weather_alerts'
|
||
sensor.nws_alert_count:
|
||
friendly_name: Alerts
|
||
icon: mdi:alert-outline
|
||
|
||
# weather:
|
||
# # REMOVING darksky integration since API is EOL in 18 months. Migrated to NWS
|
||
# # - platform: darksky
|
||
# # api_key: !secret darksky_api
|
||
# - platform: nws
|
||
# api_key: !secret nws_api_key
|
||
# station: klzu
|
||
|
||
weather:
|
||
- platform: pirateweather
|
||
api_key: !secret pirate_weather_api
|
||
# Additional optional values:
|
||
#latitude: Location latitude
|
||
#longitude: Location longitude
|
||
mode: "daily"
|
||
name: Anchorage House
|
||
|
||
|
||
group:
|
||
alerts_card:
|
||
name: Alerts
|
||
entities:
|
||
- sensor.nws_alerts
|
||
|
||
input_boolean:
|
||
freeze_warning:
|
||
name: Freeze Warning
|
||
icon: mdi:snowflake-alert
|
||
weather_alert_texts:
|
||
name: Weather Alert Texts
|
||
icon: mdi:telegram
|
||
lightning_warning:
|
||
name: Lightning Warning
|
||
icon: mdi:flash-alert
|
||
tornado_alarm:
|
||
name: Tornado Alarm
|
||
icon: mdi:speaker-wireless
|
||
tstorm_alarm:
|
||
name: T-Storm Alarm
|
||
icon: mdi:speaker-wireless
|
||
raining:
|
||
name: Raining
|
||
|
||
utility_meter:
|
||
daily_rainfall_in:
|
||
source: sensor.acurite_rain899_2743_rt
|
||
cycle: daily
|
||
weekly_rainfall_in:
|
||
source: sensor.acurite_rain899_2743_rt
|
||
cycle: weekly
|
||
recent_lightning_strikes:
|
||
source: sensor.acurite_6045m_3078_strcnt
|
||
cycle: quarter-hourly
|
||
|
||
### You first need to find either your NWS Zone ID or County ID. I’m not sure which is better but I used my Zone ID here.
|
||
### You can find your Zone ID by going to https://alerts.weather.gov/ 7, scroll down to your state and click on the “zone list” then look for the entry for your county.
|
||
### I recommond useing both
|
||
|
||
#I’ve taken much of the underlying work here and created a custom component for nws alerts sensor.
|
||
#The sensor can be created by adding the nws_alerts.py file to <config_directory>/custom_components/sensor/ and adding the following to your sensor definitions:
|
||
|
||
sensor:
|
||
# - platform: nws_alerts
|
||
# zone_id: 'GAZ034,GAC135'
|
||
- platform: weatheralerts
|
||
state: GA
|
||
zone: 34
|
||
county: 135
|
||
- platform: pirateweather
|
||
api_key: !secret pirate_weather_api
|
||
scan_interval: '00:15:00'
|
||
monitored_conditions:
|
||
- temperature
|
||
- precip_probability
|
||
- precip_type
|
||
- humidity
|
||
- cloud_cover
|
||
- nearest_storm_distance
|
||
- precip_intensity
|
||
- wind_speed
|
||
- platform: statistics
|
||
name: Inside Humidity Stats
|
||
entity_id: sensor.current_inside_humidity
|
||
state_characteristic: mean
|
||
sampling_size: 500
|
||
|
||
- platform: template
|
||
sensors:
|
||
current_forecast:
|
||
friendly_name: Current Forecast
|
||
unit_of_measurement: ''
|
||
icon_template: mdi:weather-sunny
|
||
value_template: >-
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.condition }}
|
||
attribute_templates:
|
||
high_temp: >-
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.temperature }}
|
||
wind_bearing: >-
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.wind_bearing }}
|
||
wind_speed: >-
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.wind_speed }}
|
||
precipitation_probability: >-
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.precipitation_probability }}
|
||
description: >
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{{ forecast.detailed_description | truncate(250, False) }}
|
||
overnight_forecast:
|
||
friendly_name: Overnight Forecast
|
||
unit_of_measurement: ''
|
||
icon_template: mdi:weather-sunny
|
||
value_template: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.condition }}
|
||
attribute_templates:
|
||
low_temp: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.temperature }}
|
||
wind_bearing: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.wind_bearing }}
|
||
wind_speed: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.wind_speed }}
|
||
precipitation_probability: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.precipitation_probability }}
|
||
description: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[0] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% endif %}
|
||
{{ forecast.detailed_description | truncate(250, False) }}
|
||
tomorrow_forecast:
|
||
friendly_name: Tomorrows Forecast
|
||
unit_of_measurement: ''
|
||
icon_template: mdi:weather-sunny
|
||
value_template: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.condition }}
|
||
attribute_templates:
|
||
high_temp: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.temperature }}
|
||
wind_bearing: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.wind_bearing }}
|
||
wind_speed: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.wind_speed }}
|
||
precipitation_probability: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.precipitation_probability }}
|
||
description: >-
|
||
{% if is_state('binary_sensor.overnight', 'on') %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[1] %}
|
||
{% else %}
|
||
{% set forecast = state_attr('weather.klzu_daynight','forecast')[2] %}
|
||
{% endif %}
|
||
{{ forecast.detailed_description | truncate(250, False) }}
|
||
outside_pressure:
|
||
friendly_name: 'outisde pressure'
|
||
value_template: '{{ state_attr(''weather.home'',''pressure'') }}'
|
||
unit_of_measurement: ''
|
||
clothing_forecast:
|
||
friendly_name: "Clothing Forecast"
|
||
unit_of_measurement: ''
|
||
value_template: >-
|
||
{%- if state_attr('sensor.current_forecast', 'high_temp')|int > 63 %}
|
||
{%- if state_attr('sensor.current_forecast', 'high_temp')|int < 80 %}
|
||
Nice
|
||
{% elif state_attr('sensor.current_forecast', 'high_temp')|int > 95 %}
|
||
Hot
|
||
{% else %}
|
||
Toasty
|
||
{%- endif %}
|
||
{% elif state_attr('sensor.current_forecast', 'high_temp')|int < 64 %}
|
||
{%- if state_attr('sensor.current_forecast', 'high_temp')|int < 32 %}
|
||
Freezing
|
||
{% elif state_attr('sensor.current_forecast', 'high_temp')|int > 50 %}
|
||
Chilly
|
||
{% else %}
|
||
Cold
|
||
{%- endif %}
|
||
{% else %}
|
||
Unknown
|
||
{%- endif %}
|
||
nws_current_forecast:
|
||
friendly_name: 'Current Detailed Forecast'
|
||
value_template: "{{ state_attr('sensor.current_forecast', 'description')}}"
|
||
nws_current_rain_forecast:
|
||
friendly_name: 'Current Rain Chance'
|
||
value_template: "{{ state_attr('sensor.current_forecast', 'precipitation_probability')}}"
|
||
unit_of_measurement: '%'
|
||
nws_current_temperature:
|
||
friendly_name: 'Current Temperature'
|
||
value_template: "{{ state_attr('weather.klzu_daynight','temperature') }}"
|
||
device_class: temperature
|
||
nws_current_condition:
|
||
friendly_name: 'Current Condition'
|
||
value_template: "{{ states('weather.klzu_daynight') }}"
|
||
nws_current_humidity:
|
||
friendly_name: 'Current Humidity'
|
||
value_template: "{{ state_attr('weather.klzu_daynight','humidity') }}"
|
||
nws_current_visibility:
|
||
friendly_name: "Current Visability"
|
||
value_template: "{{ state_attr('weather.klzu_daynight','visibility') }}"
|
||
nws_current_windspeed:
|
||
friendly_name: "Current Windspeed"
|
||
value_template: "{{ state_attr('weather.klzu_daynight','wind_speed') }}"
|
||
nws_overnight_low:
|
||
friendly_name: "Overnight Low"
|
||
unit_of_measurement: ''
|
||
value_template: >-
|
||
{{ state_attr('sensor.overnight_forecast', 'low_temp')}}
|
||
|
||
|
||
current_inside_humidity:
|
||
friendly_name: "Current Inside Humidity"
|
||
unit_of_measurement: '%'
|
||
value_template: "{{ state_attr('climate.home','current_humidity') }}"
|
||
lighting_stike_count:
|
||
friendly_name: "Lightning Strike Count"
|
||
value_template: "{{ states('sensor.acurite_6045m_3078_strcnt') }}"
|
||
yesterday_rainfall_in:
|
||
friendly_name: "Yesterday Rainfall"
|
||
value_template: "{{ state_attr('sensor.daily_rainfall_in', 'last_period') }}"
|
||
previous_rainfall:
|
||
friendly_name: "Past 48h Rainfall"
|
||
value_template: "{{ states('sensor.daily_rainfall_in') | float + state_attr('sensor.daily_rainfall_in', 'last_period') | float }}"
|
||
lightning_warning:
|
||
friendly_name: "Lightning Warning"
|
||
value_template: >-
|
||
{%- if states('sensor.recent_lightning_strikes') | int > 0 %}
|
||
Unsafe
|
||
{% else %}
|
||
Safe
|
||
{%- endif %}
|
||
|
||
|
||
automation:
|
||
|
||
|
||
- alias: 'record previous day rainfall'
|
||
trigger:
|
||
- platform: time
|
||
at: '23:58:00'
|
||
action:
|
||
service: mqtt.publish
|
||
data_template:
|
||
topic: 'house/rain/yesterday_total'
|
||
retain: true
|
||
payload: "{{ states('sensor.todays_rainfall') }}"
|
||
|
||
- alias: Forecast Low Near Freezing
|
||
trigger:
|
||
- platform: numeric_state
|
||
entity_id: sensor.nws_overnight_low
|
||
below: 35
|
||
- platform: numeric_state
|
||
entity_id: sensor.nws_current_temperature
|
||
below: 35
|
||
condition:
|
||
- condition: state
|
||
entity_id: input_boolean.freeze_warning
|
||
state: 'off'
|
||
action:
|
||
- service: input_boolean.turn_on
|
||
entity_id: input_boolean.freeze_warning
|
||
|
||
- alias: Forecast Low Above Freezing
|
||
trigger:
|
||
- platform: numeric_state
|
||
entity_id: sensor.nws_overnight_low
|
||
above: 33
|
||
condition:
|
||
- condition: state
|
||
entity_id: input_boolean.freeze_warning
|
||
state: 'on'
|
||
- condition: numeric_state
|
||
entity_id: sensor.nws_overnight_low
|
||
above: 35
|
||
action:
|
||
- service: input_boolean.turn_off
|
||
entity_id: input_boolean.freeze_warning
|
||
|
||
|
||
script:
|
||
|
||
refresh_weather_alert_sensors:
|
||
sequence:
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.tornado_warning
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.tornado_watch
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.tstorm_warning
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.tstorm_watch
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.flood_warning
|
||
- service: homeassistant.update_entity
|
||
entity_id: sensor.flood_watch
|
||
|
||
|