Hey everyone! I’ve been working on integrating earthquake data into my Lovelace setup and wanted to share my findings and some tips that might help others looking to do something similar. ![]()
![]()
I came across the emscrss integration, which pulls earthquake data from the European-Mediterranean Seismological Centre. It’s pretty cool, but I was a bit stuck on how to display the data in a user-friendly way on Lovelace. The sensor returns a list of earthquakes with details like magnitude, time, and location, but I wanted each earthquake to have its own UI element instead of just a text dump.
After some research, I found that using Lovelace cards with custom templates was the way to go. Here’s what I did:
- Create a Custom Lovelace Card: I used the
templatecard type to loop through the earthquake data. Here’s a sample template I used:
yaml
earthquakes:
- title: ‘ML 2.6 DODECANESE ISLANDS, GREECE’
magnitude: 2.6
time: ‘2021-02-10T08:37:59+02:00’
distance: 290
link: ‘https://www.emsc-csem.org/Earthquake/earthquake.php?id=947538’
… more earthquakes …
friendly_name: Earthquakes
icon: ‘mdi:alert’
- Use a For Loop in the Template: I set up a template that iterates over each earthquake in the list and displays the details in a clean format. Here’s an example of how the template looks:
yaml
Earthquakes:
{% for quake in state_attr(‘sensor.earthquakes’,‘earthquakes’) %}
- {{ quake.time }} - {{ quake.title }} - Magnitude: {{ quake.magnitude }} - Distance: {{ quake.distance }}
{% endfor %}
-
Customize the Display: I added some CSS styling to make the cards look neat. You can customize the colors, fonts, and layout to match your Lovelace theme.
-
Consider Using an HTML Card: If you want more control over the layout, you can use the
iframecard to embed an HTML page. This is especially useful if you want to include maps or more detailed information. -
Set Up Automation: I also set up an automation to notify me whenever an earthquake above a certain magnitude occurs. This way, I get real-time updates without having to check the Lovelace card manually.
Here are a few tips to make your earthquake data display even better:
- Filter by Magnitude: Only show earthquakes above a certain magnitude to reduce noise.
- Add a Map Integration: Use a map integration to show the epicenter of each earthquake.
- Custom Icons: Use different icons based on the earthquake’s magnitude for quick visual reference.
I’d love to hear how others are displaying dynamic data like this on Lovelace! Have you found any cool integrations or tips that I might have missed? Let’s share and learn together! ![]()