Skip to content

Instantly share code, notes, and snippets.

@Geek-MD
Last active July 5, 2025 03:51
Show Gist options
  • Select an option

  • Save Geek-MD/3917910f2538f2a7ba29c0a5c9acc3e9 to your computer and use it in GitHub Desktop.

Select an option

Save Geek-MD/3917910f2538f2a7ba29c0a5c9acc3e9 to your computer and use it in GitHub Desktop.
blueprint:
name: USGS Earthquake Notifier (All Entities)
description: |
Trigger an action when any new earthquake is detected by the USGS Earthquakes Feed integration,
and its magnitude meets or exceeds the defined threshold.
domain: automation
author: Edison Montes @_GeekMD_
homeassistant:
min_version: 2024.6.0
input:
magnitude_threshold:
name: Magnitude Threshold
description: Minimum magnitude required to execute the actions.
default: 4.0
selector:
number:
min: 0.0
max: 10.0
step: 0.1
unit_of_measurement: "M"
actions:
name: Actions
description: |
Define the actions to perform when a qualifying earthquake is detected.
💡 *Example Telegram notification (Markdown)*:
```
service: notify.telegram
data:
message: >
*🌎 Earthquake Alert!*
*Name:* {{ quake_name }}
*Magnitude:* {{ quake_magnitude }}
*Time:* {{ quake_time | as_timestamp | timestamp_custom('%d-%b-%Y %H:%M', true) }} CLT
*Distance:* {{ quake_distance }} km
*Location:* [{{ quake_latitude }}, {{ quake_longitude }}](https://www.google.com/maps/search/?api=1&query={{ quake_latitude }},{{ quake_longitude }})
parse_mode: markdown
```
selector:
action:
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: >
{{
trigger.event.data.entity_id.startswith('geo_location.')
and state_attr(trigger.event.data.entity_id, 'source') == 'usgs_earthquakes_feed'
and state_attr(trigger.event.data.entity_id, 'magnitude') is not none
and state_attr(trigger.event.data.entity_id, 'magnitude') >= (magnitude_threshold | float)
}}
variables:
entity_id: "{{ trigger.event.data.entity_id }}"
magnitude_threshold: !input magnitude_threshold
quake_name: "{{ state_attr(entity_id, 'friendly_name') }}"
quake_magnitude: "{{ state_attr(entity_id, 'magnitude') }}"
quake_time: "{{ state_attr(entity_id, 'time') }}"
quake_distance: "{{ state_attr(entity_id, 'distance') }}"
quake_latitude: "{{ state_attr(entity_id, 'latitude') }}"
quake_longitude: "{{ state_attr(entity_id, 'longitude') }}"
action:
- choose: []
default: !input actions
mode: queued
max: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment