home-assistant-configuration/config/packages/weather.yaml

355 lines
14 KiB
YAML
Raw Normal View History

###############################################################################
# @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
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
2020-08-22 03:28:38 +00:00
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_lighting_strikes:
source: sensor.acurite_6045m_3078_strcnt
cycle: quarter-hourly
### You first need to find either your NWS Zone ID or County ID. Im 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
#Ive 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: mqtt
# name: "Back Porch"
# state_topic: "house/acurite2mqtt/Acurite-6045M_3078"
# unit_of_measurement: '°F'
# value_template: "{{ value_json.temperature_F }}"
# json_attributes_topic: "house/acurite2mqtt/Acurite-6045M_3078"
# device_class: temperature
# - platform: mqtt
# name: "Crawlspace"
# state_topic: "house/acurite2mqtt/Acurite-609TXC_73"
# unit_of_measurement: '°F'
# value_template: "{{ value_json.temperature_F }}"
# json_attributes_topic: "house/acurite2mqtt/Acurite-609TXC_73"
# device_class: temperature
# - platform: mqtt
# name: "Garage"
# state_topic: "house/acurite2mqtt/Acurite-Tower_10968"
# unit_of_measurement: '°F'
# value_template: "{{ value_json.temperature_F }}"
# json_attributes_topic: "house/acurite2mqtt/Acurite-Tower_10968"
# device_class: temperature
- platform: mqtt
name: "Lightning total count"
state_topic: "house/lightning/total_count"
- platform: mqtt
name: "Yesterday Rain Total"
state_topic: "house/rain/yesterday_total"
- platform: mqtt
name: "Rain Guage Total"
state_topic: "house/rain/cumlative_total"
- platform: mqtt
name: "Previous Rain Guage Total"
state_topic: "house/rain/previous_cumlative_total"
- platform: statistics
name: Inside Humidity Stats
entity_id: sensor.current_inside_humidity
sampling_size: 500
- platform: template
sensors:
backporch_weather:
friendly_name: Back Porch Weather
value_template: "{{ states.sensor.acurite_6045m_3078_t.state | round}} °F / {{ states.sensor.acurite_6045m_3078_h.state }} %"
garage_weather:
friendly_name: Garage Weather
value_template: "{{ states.sensor.acurite_tower_10968_t.state | round}} °F / {{ states.sensor.acurite_tower_10968_h.state }} %"
crawlspace_weather:
friendly_name: Crawlspace Weather
value_template: "{{ states.sensor.acurite_609txc_73_t.state | round}} °F / {{ states.sensor.acurite_609txc_73_h.state }} %"
guestbath_weather:
friendly_name: Guest Bath Weather
value_template: "{{ states.sensor.acurite_tower_guest_bath_t.state | round}} °F / {{ states.sensor.acurite_tower_guest_bath_h.state }} %"
masterbath_weather:
friendly_name: Master Bath Weather
value_template: "{{ states.sensor.acurite_tower_master_bath_t.state | round}} °F / {{ states.sensor.acurite_tower_master_bath_h.state }} %"
rain_guage_in:
friendly_name: Rain Guage (Inches)
value_template: "{{ (states('sensor.acurite_rain899_2743_rt') | float / 25.4) | round(2) }}"
todays_rainfall:
friendly_name: Daily Rain (Inches)
value_template: "{{ (((states('sensor.acurite_rain899_2743_rt') | float / 25.4) | round(2) ) - ((states('sensor.previous_rain_guage_total') | float ))) | round(2) }}"
clothing_forecast:
friendly_name: "Clothing Forecast"
unit_of_measurement: ''
value_template: >-
{%- if states('sensor.nws_daytime_temperature')|int > 63 %}
{%- if states('sensor.nws_daytime_temperature')|int < 80 %}
Nice
{% elif states('sensor.nws_daytime_temperature')|int > 95 %}
Hot
{% else %}
Toasty
{%- endif %}
{% elif states('sensor.nws_daytime_temperature')|int < 64 %}
{%- if states('sensor.nws_daytime_temperature')|int < 32 %}
Freezing
{% elif states('sensor.nws_daytime_temperature')|int > 50 %}
Chilly
{% else %}
Cold
{%- endif %}
{% else %}
Unknown
{%- endif %}
nws_current_forecast:
friendly_name: 'Current Forecast'
value_template: "{{ states.weather.klzu_daynight.attributes.forecast[0].detailed_description | truncate(250, False) }}"
nws_current_rain_forecast:
friendly_name: 'Current Rain Chance'
value_template: "{{ states.weather.klzu_daynight.attributes.forecast[0].precipitation_probability }}"
unit_of_measurement: '%'
nws_current_temperature:
friendly_name: 'Current Temperature'
value_template: "{{ states.weather.klzu_daynight.attributes.temperature }}"
device_class: temperature
nws_daytime_temperature:
friendly_name: 'Daytime Temperature'
value_template: >-
{% if states.weather.klzu_daynight.attributes.forecast[0].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[0].temperature }}
{% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[1].temperature }}
{% endif %}
device_class: temperature
nws_current_condition:
friendly_name: 'Current Condition'
value_template: "{{ states.weather.klzu_daynight.state }}"
nws_current_humidity:
friendly_name: 'Current Humidity'
value_template: "{{ states.weather.klzu_daynight.attributes.humidity }}"
nws_current_visibility:
friendly_name: "Current Visability"
value_template: "{{ states.weather.klzu_daynight.attributes.visibility }}"
nws_current_windspeed:
friendly_name: "Current Windspeed"
value_template: "{{ states.weather.klzu_daynight.attributes.wind_speed }}"
nws_overnight_low:
friendly_name: "Overnight Low"
unit_of_measurement: ''
value_template: >-
{% if states.weather.klzu_daynight.attributes.forecast[0].daytime == False %}
{{ states.weather.klzu_daynight.attributes.forecast[0].temperature }}
{% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == False %}
{{ states.weather.klzu_daynight.attributes.forecast[1].temperature }}
{% endif %}
nws_overnight_forecast:
friendly_name: "Overnight Forecast"
unit_of_measurement: ''
value_template: >-
{% if states.weather.klzu_daynight.attributes.forecast[0].daytime == False %}
{{ states.weather.klzu_daynight.attributes.forecast[0].detailed_description | truncate(250, False) }}
{% elif states.weather.klzu_daynight.attributes.forecast[1].daytime == False %}
{{ states.weather.klzu_daynight.attributes.forecast[1].detailed_description | truncate(250, False) }}
{% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == False %}
{{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }}
{% endif %}
nws_forecast_tomorrow:
friendly_name: "Forecast Tomorrow"
unit_of_measurement: ''
value_template: >-
{%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[1].detailed_description | truncate(250, False) }}
{% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }}
{%- endif %}
nws_forecast_rain_tomorrow:
friendly_name: "Rain Chance Tomorrow"
unit_of_measurement: '%'
value_template: >-
{%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[1].precipitation_probability }}
{% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[2].precipitation_probability }}
{%- endif %}
nws_forecast_tomorrow_night:
friendly_name: "Forecast Tomorrow Night"
unit_of_measurement: ''
value_template: >-
{%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[2].detailed_description | truncate(250, False) }}
{% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[3].detailed_description | truncate(250, False) }}
{%- endif %}
nws_forecast_rain_tomorrow_night:
friendly_name: "Rain Chance Tomorrow Night"
unit_of_measurement: '%'
value_template: >-
{%- if states.weather.klzu_daynight.attributes.forecast[1].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[2].precipitation_probability }}
{% elif states.weather.klzu_daynight.attributes.forecast[2].daytime == True %}
{{ states.weather.klzu_daynight.attributes.forecast[3].precipitation_probability }}
{%- endif %}
current_inside_humidity:
friendly_name: "Current Inside Humidity"
unit_of_measurement: '%'
value_template: "{{ states.climate.home.attributes.current_humidity }}"
lighting_stike_count:
friendly_name: "Lightning Strike Count"
value_template: "{{ states.sensor.back_porch_strike_count.state }}"
previous_rainfall:
friendly_name: "Previous Rainfall"
value_template: "{{ states.sensor.daily_rainfall_in.attributes.last_period }}"
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:
2020-11-07 16:20:26 +00:00
store_rain_total:
sequence:
- service: mqtt.publish
data_template:
topic: 'house/rain/cumlative_total'
retain: true
payload: "{{ ((states('sensor.acurite_rain899_2743_rt') | float / 25.4) | round(2) )}}"
- service: mqtt.publish
data_template:
topic: 'house/rain/previous_cumlative_total'
retain: true
payload: "{{ ((states('sensor.acurite_rain899_2743_rt') | float / 25.4) | round(2) )}}"
2020-11-07 16:20:26 +00:00
store_lightning_count:
sequence:
- service: mqtt.publish
data:
topic: house/lightning/total_count
payload_template: "{{ states.sensor.acurite_6045m_3078_strcnt.state | int }}"
2020-11-07 16:20:26 +00:00
retain: true
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
2020-08-22 03:28:38 +00:00
entity_id: sensor.flood_watch