Ciquattro
(Ciquattro)
December 26, 2018, 5:08pm
1
Hi,
I need some help to configure this notifications for this plaftorm, any suggestions?
I have setup the platform usgs_earthquakes_feed
############### Earth Quake ######################
geo_location:
- platform: usgs_earthquakes_feed
feed_type: 'past_day_all_earthquakes'
#feed_type: 'past_month_all_earthquakes'
radius: 500
minimum_magnitude: 0.0
latitude: !secret latitude
longitude: !secret longitude
I have setup a passive zone for the alert
- name: Earth Quake Alert Zone
latitude: !secret latitude
longitude: !secret longitude
radius: 15000
passive: true
and then create an automation for noitfy on earthquake alert that don’t work.
Any suggestion on how to make it work?
- alias: 'Earth Quake Alert'
initial_state: 'on'
trigger:
platform: geo_location
source: usgs_earthquakes_feed
zone: zone.earth_quake_alert_zone
event: enter
action:
- service: persistent_notification.create
data_template:
message: "{{ trigger.to_state.name }} - {{ trigger.to_state.attributes.status }}"
title: "Earth Quake Alert"
- service: notify.hassnico_bot
data_template:
message: >
"{{ trigger.to_state.attributes.friendly_name }} Earth Quake Alert Test"
tom_l
January 26, 2019, 4:04am
2
Did you get this to work?
Ciquattro
(Ciquattro)
January 30, 2019, 11:22am
3
partially… I get work with the component on the map but the notification still not work…
cazbrat
(Juan RodrĂguez)
September 1, 2019, 12:27am
4
I have the same problem.
Have you found a solution?
Ciquattro
(Ciquattro)
September 5, 2019, 11:47am
5
hmm no… because I forgot about this component … I’ll take a look today and I’ll post a solution… if I’ll found one
Ciquattro
(Ciquattro)
September 5, 2019, 1:23pm
6
I was not able to understand how to trigger new event created from the usgs platform… so I have done this automation but I have to test it
- alias: 'Earth Quake Alert'
initial_state: 'on'
trigger:
event: enter
platform: geo_location
source: usgs_earthquakes_feed
zone: zone.home
action:
- service: persistent_notification.create
data_template:
message: Earthquake detected nearby.
title: "Earth Quake Alert"
- service: notify.hassnico_bot
data_template:
message: Earthquake detected nearby.
Ciquattro
(Ciquattro)
September 5, 2019, 2:29pm
7
Maybe better something like this:
- alias: 'Earth Quake Alert'
trigger:
platform: geo_location
source: usgs_earthquakes_feed
zone: zone.earth_quake_alert_zone
event: enter
condition:
condition: template
value_template: "{{ trigger.event.data.entity_id.startswith('geo_location.m') and
distance('device_tracker.nico_nico')|int <= 50 }}"
action:
- service: notify.notify
data_template:
message: >
message: "ALARM! Earth Quake Detected {{ states('sensor.date_time') }}"
Ciquattro
(Ciquattro)
September 6, 2019, 1:14pm
8
So my final solution is this:
- alias: 'Earth Quake Alert'
trigger:
platform: geo_location
source: usgs_earthquakes_feed
zone: zone.earth_quake_alert_zone
event: enter
condition:
condition: template
value_template: "{{ trigger.to_state.attributes.type == 'earthquake' }}"
action:
- service: persistent_notification.create
data_template:
message: "{{ trigger.to_state.name }} - {{ trigger.to_state.attributes.status }}"
title: "Earth Quake Alert"
- service: notify.hassnico_bot
data_template:
message: "ALARM! Earth Quake Detected {{ states('sensor.date_time') }}"
- service: hassio.addon_stdin
data_template:
addon: 89275b70_dss_voip
input: {"call_sip_uri":"sip:[email protected] ","message_tts":"Allerta, E' stato registrato un Terremoto"}
3 Likes
tom_l
September 6, 2019, 1:16pm
9
Thanks @Ciquattro I’m going to give this a go for alerts about my friends who live on a bit of the Pacific Ring of Fire.
1 Like
Ciquattro
(Ciquattro)
September 6, 2019, 1:21pm
10
in the configuration.yaml I have this settings:
geo_location:
- platform: usgs_earthquakes_feed
feed_type: 'past_day_all_earthquakes'
radius: 100
minimum_magnitude: 4.0
latitude: !secret latitude
longitude: !secret longitude
1 Like
tom_l
September 6, 2019, 1:23pm
11
Yeah I had no problem with that bit (maybe the feed type was wrong?). It was generating notifications I could not get tot work.
Can you get the magnitude and distance from zone centre as attributes?
EDIT: what format is the lat and lon? Edit2: never mind, scrolling to the bottom of the docs gives an example.
Edit3: one last thing, should I see a zone on the map?
cazbrat
(Juan RodrĂguez)
September 8, 2019, 11:23pm
12
Thanks @Ciquattro . I will do the tests too.
sdesalve
(Sdesalve)
September 23, 2019, 11:02pm
13
Bravo!
Nice job! I love your solution for getting an automated voice call notification for an earthquake!
1 Like
Thanks for lining this out!
I used the passive zone and the automation seems to work, with “enter” and the reference to the USGS feed.
Cheers
2 Likes
lordwizzard
(Lordwizzard)
November 16, 2023, 10:01pm
16
Seems that the feed has gone down, but the web site works for the USGS. Anyone else seeing this issue today?
FoxxMD
August 29, 2024, 2:28pm
18
Nothing ground breaking but I wanted to share my automation using what I’ve parsed from this thread and a few other places to make this easier to test and configure for those that stumbled across this in the future.
This automation:
triggers when a new quake entity enters zone.se_earthquake
(change to yours)
* only when quake is automatic
* this prevents “updated/revised” (reviewed
status) quake alerts from spamming your automation. You’ll only get the first alert.
Some additional variables are provided to actions:
time
is a human friendly timestamp of when the quake happened formatted to your timezone like 2024-08-28 11:51
miles
the geolocation provides state
(distance from lat/long) in kilometers so this is it converted to miles
The action sends a notification to all devices that can be notified
Change notify
to a specific device and/or copy/paste action for multiple devices
For android devices it displays an actionable link that points to the USGS details page for this alert
Example of notification content (message
):
M2.03 -- 8 km S of Sparta, North Carolina (7mi away) at 2024-08-28 11:51
alias: Earthquake
description: ""
trigger:
- platform: geo_location
source: usgs_earthquakes_feed
zone: zone.se_earthquake
event: enter
condition:
- condition: template
value_template: >-
{{ trigger.to_state.attributes.type == 'earthquake'}}
enabled: true
action:
- variables:
time: >-
{{ as_timestamp( trigger.to_state.attributes.time ) |
timestamp_custom('%Y-%m-%d %-H:%M') }}
miles: "{{ int(float(trigger.to_state.state) * 0.621) }}"
- action: notify
metadata: {}
data:
message: >-
M{{ trigger.to_state.attributes.magnitude }} -- {{
trigger.to_state.attributes.place }} ({{ miles }}mi away) at {{ time }}
title: Earthquake
data:
actions:
- action: URI
title: Details
uri: >-
https://earthquake.usgs.gov/earthquakes/eventpage/{{
trigger.to_state.attributes.external_id }}
mode: single
For debugging, here is code you can copy/paste into Developer Tools → Template to test the formatting for the message content (or whatever you want)
{% set trigger = {
"from_state": null,
"to_state": {
"state": "12.3",
"attributes": {
"type": "earthquake",
"status": "automatic",
"time": "2024-08-28T15:51:38.530000+00:00",
"place": "8 km S of Sparta, North Carolina",
"magnitude": 2.03,
"external_id": "se60502383",
"longitude": -81.10483,
"latitude": 36.428
}
}
}
%}
{% set time = as_timestamp( trigger.to_state.attributes.time ) |
timestamp_custom('%Y-%m-%d %-H:%M') %}
{% set miles = int(float(trigger.to_state.state) * 0.621) %}
M{{ trigger.to_state.attributes.magnitude }} -- {{
trigger.to_state.attributes.place }} ({{
miles }}mi away) at {{ time }}
And here is an example of the payload of a triggered automation for use with the above template testing:
trigger:
id: '0'
idx: '0'
alias: null
platform: geo_location
source: usgs_earthquakes_feed
entity_id: geo_location.m_2_0_8_km_s_of_sparta_north_carolina
from_state: null
to_state:
entity_id: geo_location.m_2_0_8_km_s_of_sparta_north_carolina
state: '415.8'
attributes:
source: usgs_earthquakes_feed
latitude: 36.428
longitude: -81.10483
external_id: se60502383
place: 8 km S of Sparta, North Carolina
magnitude: 2.03
time: '2024-08-28T15:51:38.530000+00:00'
updated: '2024-08-28T21:45:15.248000+00:00'
status: reviewed
type: earthquake
unit_of_measurement: km
attribution: USGS All Earthquakes, Past Day
icon: mdi:pulse
friendly_name: M 2.0 - 8 km S of Sparta, North Carolina
last_changed: '2024-08-29T10:19:27.436541+00:00'
last_reported: '2024-08-29T10:19:27.436541+00:00'
last_updated: '2024-08-29T10:19:27.436541+00:00'
context:
id: 01J6ETBCACCKHXRGFXWJ95KVXA
parent_id: null
user_id: null
zone:
entity_id: zone.se_earthquake
state: '0'
attributes:
latitude: 34.283277
longitude: -84.318702
radius: 600000
passive: true
persons: []
editable: true
icon: mdi:map-marker
friendly_name: SE Earthquake
last_changed: '2024-08-28T20:24:06.132353+00:00'
last_reported: '2024-08-28T20:24:06.132353+00:00'
last_updated: '2024-08-28T20:24:06.132353+00:00'
context:
id: 01J6DAHSQMACH6Q03KPH7XDP68
parent_id: null
user_id: null
event: enter
description: geo_location - usgs_earthquakes_feed
1 Like