MQTT Ephemeral events on map

Hello!

So my goal is to display temporary events (area 911/emergency alerts) on the home assistant map so I can setup alerts of nearby events

I’ve found info on using device trackers but I was wondering if there was a better idea for that. Ideally events would be able to be deleted and not clutter the entity registry. Not really sure if that can be done?

Thanks!

Not sure if this helps you or gives you any ideas. I use the lovelace map card to display latest events in areas from the PulsePoint service. It works okay, I believe they have improved some of the map and geojson abilities in Home Assistant since I last touched this so there may be cleaner display option in HA now. My data for the map comes from a MQTT sensor that I create for each PulsePoint area of interest, the sensor value and attributes are just the latest event from Pulsepoint, so other than the sensor history there is no detritus. You can disable history in HA History for these sensors if you do not want to keep it. However, I found this history interesting when I did a little data analysis on 911 event locations, types and COVID spikes. My alerting function is done by a automation that calculates in the event is within a given radius of ‘key’ locations and then sends out a Pushover notification, shown below. I do most of the geo location work in the python docker app.

Good hunting!


# lovelace
      - type: map
        entities:
          - entity: sensor.pulsepoint_sbco
          - entity: sensor.pulsepoint_sbci
          - entity: sensor.pulsepoint_mont
          - entity: sensor.pulsepoint_carp
          - entity: sensor.pulsepoint_vent
          - entity: sensor.pulsepoint_sber
          - entity: sensor.pulsepoint_sopa
          - entity: sensor.pulsepoint_pasa

          - entity: sensor.pulsepoint_redl
          - entity: sensor.pulsepoint_esco

# mqtt sensor
# mqtt sensors
sensor:
  - name: 'PulsePoint SOPA'
    unique_id: "pulsepoint-19195"
    expire_after: 43200
    state_topic: "pulsepoint/19195"
    value_template: "{{ value_json.desc_short }}"
    json_attributes_topic: "pulsepoint/19195"

# mqtt message from pulsepoint scrapper docker python application
{
  "timestamp": "1721828894",
  "time_local": "2024-07-24 06:48",
  "id": "1907489404",
  "agency_abbr": "SOPA",
  "desc_short": "Medical Emergency",
  "address": "MONTEREY RD, SOUTH PASADENA, CA",
  "street_number": "unknown",
  "common_place_name": "",
  "latitude": "34.1118020000",
  "longitude": "-118.1666070000",
  "close_to_key_location": false,
  "key_location": "{}",
  "key_location_distances": "{\"SP01\": \"0.60\", \"SP02\": \"1.35\"}",
  "equipment": "",
  "agency_code": "19195",
  "incident_code": "ME",
  "desc_long": "All incidents of a medical nature."
}

# automation for 'close' events

- alias: PulsePoint Close Event South Pasadena Fire Department
  trigger:
    platform: template
    value_template: "{{  \n  is_state_attr('sensor.pulsepoint_sopa', 'close_to_key_location',
      true) }}\n"
  action:
    service: notify.pushover
    data:
      message: 'Close to : {{ state_attr(''sensor.pulsepoint_sopa'', ''key_location'')
        }} {{ state_attr(''sensor.pulsepoint_sopa'', ''desc_short'') }} {{ state_attr(''sensor.pulsepoint_sopa'',
        ''address'') }}

        '
      data:
        url: comgooglemaps://?center={{ state_attr('sensor.pulsepoint_sopa', 'latitude')
          }},{{ state_attr('sensor.pulsepoint_sopa', 'longitude') }}&zoom=18
        priority: 0
        sound: none
  id: 60e986d5ac36418fb5fb2b397d7ad415
- alias: PulsePoint Close Event San Bernardino County Fire Department
  trigger:
    platform: template
    value_template: "{{  \n  is_state_attr('sensor.pulsepoint_sber', 'close_to_key_location',
      true) }}\n"
  action:
    service: notify.pushover
    data:
      message: 'Close to : {{ state_attr(''sensor.pulsepoint_sber'', ''key_location'')
        }} {{ state_attr(''sensor.pulsepoint_sber'', ''desc_short'') }} {{ state_attr(''sensor.pulsepoint_sber'',
        ''address'') }}

        '
      data:
        url: comgooglemaps://?center={{ state_attr('sensor.pulsepoint_sber', 'latitude')
          }},{{ state_attr('sensor.pulsepoint_sber', 'longitude') }}&zoom=18
        priority: 0
        sound: vibrate

That actually might be quite helpful!

I think my approach would be to poll the API every 5min or so, and set an expire_after value. Then I’ll just map to an array of sensors based on ordering in the JSON output and I’ll cap it up a reasonable number 20ish maybe? And I could pre-filter out some of the really far away incidents.

Thanks!