Has anyone used the HTTP binding to retrieve Seismic information via WFS services using QuakeML, GML or GeoJSON (or similar)?
I was thinking of having a play with this, to bring local seismic information into OpenHAB, and would be good to know if someone else has already had a play/success with this, and how they did it & used it.
For me, this would be via the GeoNet service in NZ, but it appears that there are other public equivalents in other parts of the world, including Europe….
Why integrate Seismic information into OpenHab, I hear some of you ask? Our region is a bit seismically active at present, and I have a few use cases I am thinking of:
One of my planned projects for this coming winter, will be integrating a Well Submersible Pump Control system into OpenHab, to provide supervisory control (it’s still autonomous, but the primary intent of the integration is to move pump operation to off-peak rates). I was thinking of using the Seismic information for control input as well, as when we have significant quakes, we get a bit of discolouration/silt, which can take a few days to settle, and holding off filling the tank for a few days could help avoid building up silt in the tank/reticulation
I’m slowly building OpenHab to be my information portal – Current weather, forecast weather, solar system/house status etc. Having details of when/where and how big/deep the last (reasonable) quake was, would be another useful addition
One other future possibility, is also for notifications of power interruption, to correlate a possible cause information into the notification (e.g. if there was a quake notification within (say) 15 seconds of the detected power outage). Useful if I am away, but I think I would know if I was at home …. I probably won’t spend too much time on this idea, as we have only had one quake induced multi-day power outage, the rest only caused minor ‘blips’ in power supply
Haven’t figured my plan for testing yet, but may involve setting the OpenHAB server to a date of a quake meeting the selection criteria (size, geographic boundaries)… Certainly my preference over creating an actual test quake !!
Any existing integration’s out there, or are others interested if I manage to get something running.
Interesting idea Glen - sounds like you are based in Christchurch as well? Hadn’t thought of that but would be interesting to see what you come up with. I am sure if there is a suitable HTTP feed then parsing the data into openHAB should be relatively easy. Keep us posted!
As for test data, only need to go back as far as Sunday for that!
Hi Ben - Yup – Based in Christchurch, and yes I think Sunday’s event would meet all test criteria!!
GeoNet do provide a Web Service Interface (details can be found here: http://info.geonet.org.nz/display/appdata/Advanced+Queries ), and I don’t think there will be too much issue with retrieving/extracting the information I need (there are JSON, XML options which should be able to be parsed nicely in OpenHAB). As part of the request, I can set geographic boundaries (or distance from geographic point), and minimum values for magnitude, since date etc., so won’t really need to do filtering on OH end.
More of interest, is how I am going to manipulate and use this data once it’s in OpenHAB, as it’s (perhaps?) a little more abstract/changeable than usual OH items. My thoughts were towards using some items along the lines of:
LastQuakeDateTime
LastQuakeMagnitude
LastQuakeDepth
LastQuakeEventID (Could be used if I want a link to the GeoNet website for more info on the specific quake, and a Map – Don’t think I want to make more work for myself than necessary, by adding maps etc.)
I was then thinking about use of comparisons as I would for Astro items such as Sunset/Sunrise to create rules based on when the last quake occurred (or could just display the items in the SiteMap).
One of the challenges I am aware of, is that the location, or magnitude of a quake changes, as more data is collected and processed by GeoNet (say up to 10-15 mins following the quake). Which means a quake event could disappear from ‘view’ in OPenHAB (e.g. if I am looking for >mag 5, and it eventually downgrades to a mag 4.9, or the epicentre moves outside the selected boundary, the ‘LastQuakeDateTime’ value could end up blank/invalid.). Perhaps having a scheduled rule writing the previous value into another Item on a regular basis, and then copying back if ‘LastQuakeDateTime’ (and other items) become blank.
Given it’s only a recently hatched idea (think Sunday afternoon !!), I haven’t fully thought this crazy scheme through yet, and have some more refinement yet to come, once I get the time to get my teeth into it……
Hi @ben_jones12 - If you are still interested, I have finally got around to having a play with this ‘Quake Integration’ using the HTTP binding. (Been a warm winter, so have spent too much time enjoying the outdoors, not behind the computer, hence big delay).
I haven’t set up any rules yet, but created some initial items which seem to work ok, so far anyway… These identify the Magnitude, and Date of the last quake in the Canterbury Region, of a quake >=Magnitude 5, and <=50KM Deep.
For those outside Canterbury Region, just modify the Lat/Lon polygon Boundaries…
SiteMap:
Text item=quake_magnitude
Text item=quake_date
Haven’t extensively tested it yet, but from what I can see, the concern I identified in the previous post is a non-issue. If the subsequent processing/refinement by GeoNet pushes it (the last quake) back outside the filters applied for Magnitude/Depth or Location, the previous quake details fitting those criteria will be updated back into these items…
Will need to try sort some rules next, but still need to actually integrate the Well Submersible Pump Controller into OpenHAB first, which is one of the primary applications for this information…
Got a slight tweak which you might be interested in. If you use the HTTP caching function you can save yourself making the same API call just to extract different info in different items;
Great - Thanks for that Ben - That is a much tidier way of doing it. Was my first real play with the HTTP binding, so took a while to figure all the ‘escaping’ required to get the GeoNet query working from within the Binding…didn’t read the rest of the binding wiki page obviously !! Cheers
As part of my move to OH3, I am currently working through all my old integrations/configs and bringing them into the OH3 UI etc. I have updated the Quake “Integration” to now work via the UI config. Just thought I would share the config here, if anyone trips up over this old post, and wants to try it in OH3.
This achieves exactly the same outcome as the previous posts describe, or to summarise, it brings in the magnitude & date/time for the last significant shake from GeoNet, with the parameters currently set to:
Greater than magnitude 5
Within the Canterbury Region (approx)
Depth less than 50KM
Only brings back one event (“feature”)
Again, this should work with any other global providers who provide GeoJSON, or for those in NZ, just edit the boundaries for the Polygon to suit your region (And set the other parameters to suit).
FYI, the ‘from’ date is just set to an arbitrary date with precedes the commencement of the Christchurch quakes, but prevents GeoNet trying to do a query from the dawn of time !!
Next step for me is to create the rules under the new JSS rules engine. I will also post them on here, once I get them sorted.
UID: http:url:geonetquake
label: Geonet Last Significant Quake Data
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://wfs.geonet.org.nz/geonet/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonet:quake_search_v1&outputFormat=json&maxFeatures=1&cql_filter=magnitude>5+AND+origintime>='2010-01-01T00:00:00.000Z'+AND+WITHIN(origin_geom,POLYGON((172.951+-41.767,+172.001+-42.832,+169.564+-44.341,+172.312+-45.412,+175.748+-42.908,+172.951+-41.767)))
delay: 0
stateMethod: GET
refresh: 60
commandMethod: GET
timeout: 3000
bufferSize: 2048
channels:
- id: geonetlastmajorquakemagnitude
channelTypeUID: http:string
label: Geonet Last Major Quake Magnitude
description: ""
configuration:
mode: READONLY
stateTransformation: JSONPATH:$.features[0].properties.magnitude
- id: geonetlastmajorquakedatetime
channelTypeUID: http:string
label: Geonet Last Major Quake Date Time
description: ""
configuration:
mode: READONLY
stateTransformation: JSONPATH:$.features[0].properties.origintime