Skip to content

Commit

Permalink
Merge branch 'master' into zone_with_gps
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Mar 21, 2023
2 parents 597ad81 + 78e6d6a commit d9909d7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion custom_components/nws_alerts/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "nws_alerts",
"name": "NWS Alerts",
"version": "2.5",
"version": "2.8",
"documentation": "https://github.com/finity69x2/nws_alerts/",
"issue_tracker": "https://github.com/finity69x2/nws_alerts/issues",
"dependencies": [],
Expand Down
17 changes: 17 additions & 0 deletions lookup_options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# NWS Alert Lookup Options
The National Weather Service (NWS) provides different methods to query weather alerts and warnings: county/zone-based alert lookup and GPS point-based alert lookup. In the NWS Alert Intergration, County and Zone configurations are grouped. Overall, County, Zone, and Coordinate location alert lookup each has strengths and limitations. The choice between the methods depends on the user's location, the complexity of the local weather patterns, and the level of detail and precision required for the specific situation.

## Coordinate (most precise)
The point-based alert lookup uses the user's precise location (based on submitted coordinates) to query weather alerts for your specific location. This method provides more accurate and targeted information, particularly useful for users who live or work in areas with microclimates or complex topography. However, this method may delay awareness of severe weather developing in the user's region.

**NOTE: The NWS Alerts integration will use both of the following methods (both County and Zone) if you select the "Zone ID" lookup method in the integration configuration.

## County (least precise)
The county-based alert lookup relies on geographic boundaries defined by county lines. The NWS issues weather alerts based on the weather conditions within each county. While counties are well-defined and familiar to most, they may not be precise enough for areas with complex topography or microclimates. In such places, weather conditions can vary significantly from one location to another, even within the same county. For example, a county may be mostly flat but have a mountainous region that experiences different weather conditions. Therefore, relying on county-based alerts alone may not provide enough detail for some users.

## Zone (recommended method)
The zone-based alert lookup, relies on geographic boundaries defined by the NWS based on weather patterns and conditions. Zones can vary in size and shape and are often used in areas with complex topography or microclimates where weather conditions can differ significantly over short distances. By defining zones based on weather patterns, the NWS can issue more targeted and precise alerts that consider each zone's unique conditions. <b>Zone-based queries are the recommended method for most users.</b>

## Source:
- https://www.weather.gov/media/documentation/docs/NWS_Geolocation.pdf
- https://www.weather.gov/gis/PublicZones
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
#################################################################################
#
# This is the package for NWS ALERTS USING THE CUSTOM INTEGRATION
# This is the package for NWS ALERTS USING THE CUSTOM COMPONENT
#
#################################################################################

## For testing the API

# https://api.weather.gov/alerts/active/count

# https://api.weather.gov/alerts/active?zone=INZ009,INC033
# https://api.weather.gov/alerts/active?zone=<some_zone>


######################## SENSOR ###############################################

## the NWS Sensor can now be installed using HACS. If you aren't using HACS you can uncomment the nws_alerts sensor here and configure it manually.
sensor:

# sensor:
# - platform: nws_alerts
# zone_id: 'INZ009,INC033'
# name: nws alerts yaml

######################## BINARY SENSOR #########################################

binary_sensor:
- platform: template
sensors:
nws_alerts_are_active:
friendly_name: NWS Alerts Are Active
#entity_id: sensor.nws_alerts
value_template: >
{{ states('sensor.nws_alerts') | int(0) > 0 }}
icon_template: >-
Expand All @@ -35,18 +30,28 @@ binary_sensor:
{% else %}
mdi:weather-sunny
{% endif %}
######################## INPUT BOOLEAN #########################################

input_boolean:
nws_multi_alert:
name: NWS Multiple Alerts At Once


############################## VARIABLE #####################################

## this uses the hass_variable custom component.
## you can install thru HACS or manually from https://github.com/Wibias/hass-variables

variable:
nws_alerts_event_ids:
value: 'none'
restore: true

######################## AUTOMATION ###########################################

automation:
- alias: 'NWS Check for Multi Alerts'
initial_state: true
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.nws_alerts
Expand All @@ -71,7 +76,7 @@ automation:
entity_id: input_boolean.nws_multi_alert

- alias: 'NWS Weather Alert Pop Up Control'
initial_state: true
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.nws_alerts
Expand Down Expand Up @@ -137,7 +142,7 @@ automation:
"{{ state_attr('sensor.nws_alerts', 'display_desc').split('\n\n-\n\n')[0] }}"
- alias: NWS Notification Weather Alert
initial_state: true
initial_state: 'on'
trigger:
platform: state
entity_id: sensor.nws_alerts
Expand All @@ -146,13 +151,13 @@ automation:
- '{{ trigger.to_state.state|int > trigger.from_state.state|int }}'
- "{{ (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] not in states.variable.nws_alerts_event_ids.attributes.values()|list) and (state_attr('sensor.nws_alerts', 'event_id').split('-')[0] != states('variable.nws_alerts_event_ids')) }}"
action:
- service: notify.pushbullet_notify
- service: notify.pushbullet
data:
message: >
"NWS: {{ state_attr('sensor.nws_alerts', 'title').split(' - ')[0] }}"
- alias: NWS Announce Weather Alert
initial_state: true
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.nws_alerts
Expand Down Expand Up @@ -195,7 +200,7 @@ automation:
- delay: '00:00:15'
- service: notify.alexa_media
data:
message: "<audio src='https://h7a3u8r0lt405rwrar1rcgi8ep9a1gez.ui.nabu.casa/local/mp3/nws_alert_tone.mp3' />"
message: "<audio src='https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/local/mp3/nws_alert_tone.mp3' />"
target:
- media_player.computer_room_dot
- media_player.kitchen_dot
Expand Down Expand Up @@ -226,7 +231,7 @@ automation:
{% endif %}
- alias: NWS Announce Weather Alert for MBR
initial_state: true
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.nws_alerts
Expand Down Expand Up @@ -259,7 +264,7 @@ automation:
- delay: '00:00:15'
- service: notify.alexa_media
data:
message: "<audio src='https://h7a3u8r0lt405rwrar1rcgi8ep9a1gez.ui.nabu.casa/local/mp3/nws_alert_tone.mp3' />"
message: "<audio src='https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.ui.nabu.casa/local/mp3/nws_alert_tone.mp3' />"
target:
- media_player.bedroom_2_dot
- media_player.master_bedroom_dot
Expand All @@ -276,9 +281,9 @@ automation:
data:
type: tts
message: "Attention!,,,Attention!,,,The National Weather Service Has issued a Tornado Warning for our area."

- alias: NWS Update Event ID Variable
initial_state: true
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.nws_alerts
Expand All @@ -302,7 +307,7 @@ automation:
variable: nws_alerts_event_ids
value: "{{ (trigger.to_state.attributes.event_id).split('-')[0] }}"

############################ SCRIPT ###################################
############################### SCRIPT ###################################

script:
nws_popup_on_wx_alert:
Expand All @@ -316,14 +321,4 @@ script:
notification_id: "nwswxalert"
message: "{{ message }}"
title: '{{ title }}'
############################## VARIABLE #####################################


## this uses the hass_variable custom component.
## you can install thru HACS or manually from https://github.com/Wibias/hass-variables

variable:
nws_alerts_event_ids:
value: 'none'
restore: true

0 comments on commit d9909d7

Please sign in to comment.