Earthquake notification in OH2?

Yes, i live in a very active zone regarding earthquakes… Every time we have a little shake i try to go online, find some website to learn the center and magnitude of the earthquake, call son, wife and friends-relatives in order, which takes some nervous time actually…

So what i thought, OH2 can periodically check the earthquake database and inform me if the epicenter is within a given radius and higher than a given magnitude. So, first step i get the last 24 hrs information from a web site and convert it to json with a script:

curl -s "" > deprem.csv
awk -F',' -v OFS=',' 'NF=15' deprem.csv > deprem2.csv
csvjson -i 4 -e WINDOWS-1254 deprem2.csv > deprem.json 
rm deprem.csv
rm deprem2.csv

Now i have this deprem.json file having all earthquakes within the last 24 hrs. And… Yeah i don’t know what next :slight_smile: Should i deal with a javascript or python or whatever. I simply guess it is not ready for JSON transformation to OH2 since i did not made the filtering yet for the magnitude and location. I think that after filtering out to a maximum of 2 events, i can get it from a rss with feed binding, or directly from JSON transformation to a String variable or Pushsafer binding.

Is there anyone who can direct me into the right path?

I decided it is too early to output the file into JSON. I am parsing the file in Python now and will only output JSON for most important ones.

1 Like

Have a look here:

Earthquake detection is also available with Z-Wave Fibaro Motion sensor

That’s an nice solution!
When you get it going, please share your findings.

The website is excellent. It captures events also in neighbor areas so I will also use it :slight_smile:

@Dim Hi Angelos, that’s the exact point flood of earthquakes in the map we are facing for the last couple of shaky days :slight_smile: Seems like we are feeling the same earthquakes on two sides of aegean…

I wrote a python script that downloads the csv file, correct encodings, select earthquakes within a given radius and select earthquakes larger than a given magnitude, and write these selections to a json file. What i am after is to display the highest magnitude in the last 24 hrs as magnitude and location as a text item in the sitemap and all the others in the sub page of the text item.

Will finish it in a couple of days and i will share the codes here…

1 Like

@cgeo Thanks for the information, i did’nt knew Fibaro had seismograph mode. I will definitely check it out, if it it’s not affected by the bypassing trucks and playing kids, that’s exactly the product i am after :wink:

So, sorry for the code, probably not everything is efficient since this is my first python attempt. The code exports 3 files;

earthquake.json: A list of all close and high magnitude events.
earthquakemax.json: Highest magnitude event to be used for String item with http binding for use with JSONPATH.
earthquake.html: A table view of earthquake.json to be used with webview.

For those who will attempt, probably you should change some code in order to make script work with your local Earthquake information provider. Since mine only exports in CSV file, i had to do this with a script.

Also, you should define a cron rule to execute the script every minute or so…

import csv
import json
import urllib.request
from json2html import *
from haversine import haversine
from datetime import datetime
from dateutil import tz

from_zone = tz.gettz('UTC')
to_zone = tz.gettz('Asia/Beijing')
# My Home Coordinates

# Check Earthquakes Within radius in km.
radius = 100

# Check Magnitude; discard magnitudes under minMagnitude, get magnitudes over maxMagnitude (Location free)
maxMagnitude = 5
minMagnitude = 3.5

# Get CSV file from web page 
response = urllib.request.urlopen("")
# Correct the encoding of the CSV
gpsTrack ='WINDOWS-1254')
# Prepare JSON file for write
jsonfile = open('deprem.json', 'wb')

# Set up CSV reader and process the header line
csvReader = csv.DictReader(gpsTrack.splitlines())
header = next(csvReader)

# Make an empty list
coordList = []
# Loop through the lines in the string
for row in csvReader:
    lat = row["Enlem"] #Lat
    lon = row["Boylam"] #Lon
    mag = row["Büyüklük"] #Magnitude
    # UTC time conversion
    utc = datetime.strptime(row["Tarih"],'%Y-%m-%d %H:%M:%SZ')
    utc = utc.replace(tzinfo=from_zone)
    central = utc.astimezone(to_zone)
    central = central.replace(tzinfo=None)
    row["Tarih"] = str(central)
    if haversine (myHome,[float(lat),float(lon)]) < radius: #Check radius and magnitude
        if float(mag) > minMagnitude:          
    elif float(mag) > maxMagnitude:
    # Append Distance to My Home in km.
    aa = haversine (myHome,[float(lat),float(lon)])

# Write HMTL table from the JSON for the filtered earthquakes
with open('earthquake.html', 'w') as html_file:
    print(json2html.convert(json = json.dumps(coordList, ensure_ascii=False, indent=4)), file=html_file)

# Write max magnitude event in a seperate json file
with open('earthquakemax.json', 'w') as f:
    json.dump(max(coordList, key=lambda ev: ev['Büyüklük']), f, ensure_ascii=False, indent=4) 

# Write JSON file for the selected filters        
with open('earthquake.json', 'w') as f:
    json.dump(coordList, f, ensure_ascii=False, indent=4) 

1 Like

Hi @febz11 !

did you catch the latest one ? I think that it is within your radius = 100


Hi @Dim,

Yes it did since the magnitude is greater than 5.

But unfortunately it has been feed to the system (By the government web page) only 15 mins. after the earthquake, or probably because of web site availability issues. I think the best way is to install a Fibaro Motion Sensor as Christos suggested, so that i will be notified instantly during the earthquake.

I also made some research for additional sensors or small size seismographs, but reached nowhere.

In the meantime, i found an application called Zismos eQuake, both for ios and android. What it does is to use smartphones as earthquake sensors, only if it is in charging state and not moving, stable mode. So that it can send a notification during or even just before the earthquake. Brilliant idea if you ask me, unfortunately it doesnot have an API to use for 3rd party integration.

So i hope our friends in Kos island are all OK and nobody hurt. Since we are a traumatised generation because of 1999 Earthquake in Turkey, everybody in Bodrum are really scared and returning back to their homes from their holiday in Bodrum.


I checked also but I couldn’t find some small “smart/connectable” seismograph… :frowning:

I don’t know how well these sensor products will work.
They have an embedded tamper sensor (accelerometer) that triggers upon vibration.

I have both the Fibaro FGMS-001 and the Aeon Labs MultiSensor 6.
The related settings for the FGMS-001 are:

FGMS manual:

For the Aeotec Multi 6: I still haven’t found how to adjust the tamper sensor settings…

I hope everybody is ok on both sides of the Aegean