[Custom Component] Lastquake - Near Realtime Earthquake Notification

EMSC has a smartphone app called Last Quake to notify users of earthquakes happening around and it is pretty quick to notify. They also have a websocket connection server SeismicPortal which is also very quick (and near realtime, according to their own claim) to notify.

This custom component connects to EMSC servers and the servers push earthquake messages to your HA whenever an earthquake happens and updates your sensor if that earthquake is within your provided parameters.

The parameters are as follows:

  • name : Name of the sensor

  • center_latitude: Latitude of your base location, default is zone.home latitude

  • center_logitude: Longitude of your base location, default is zone.home longitude

  • radius_km: Distance of all earthquakes to be informed of, within a radius from your base location (in km)

  • min_mag: Minimum magnitude of earthquakes to be informed of, within the radius defined earlier.

  • total_max_mag: Independent from earlier parameters, show all earthquakes larger than this magnitude from all over the world.

The custom component is written by GPT-4 and i am very surprised that it handled this with such precision. I used a dummy HA container to test this component; so i do not guarantee a very stable outcome for now. I corrected and added some properties manually later.

Also, any disconnections from the websocket are not handled yet since i did not had any disconnection for the time i was testing.

So if any one of you wants to test this and give me feedback i would be grateful.

I am currently testing your integration and noticed whenever ha reboots, the last state becomes unknown. Any way to keep it’s last magnitude state?

On a side note, I am using similar notification which I have created several template sensors basis of of this url. The list is mostly in Japan area though I have seen list not of Japan.

https://www.jma.go.jp/bosai/quake/data/list.json