Skip to content

Instantly share code, notes, and snippets.

View markxroberts's full-sized avatar

Mark Roberts markxroberts

View GitHub Profile
@markxroberts
markxroberts / imap_sensor_setup.yaml
Last active October 5, 2025 06:36
IMAP sensor setup for Home Assistant MetOffice Severe Weather alerts
{% set start = text | regex_findall_index("on ... ([0-9]+.....[0-9]*)",0) +" "+ text | regex_findall_index("Between ([0-9]+:[0-9]+)",0) if sender == "metoffice@service.govdelivery.com" else "no date or time" %}
{% set end = text | regex_findall_index("on ... ([0-9]+.....[0-9]*)",1) +" "+ text | regex_findall_index("and ([0-9]+:[0-9]+)",0) if sender == "metoffice@service.govdelivery.com" else "no date or time" %}
{% set details = text | regex_findall_index("Headline\s*(.*)\s*What to expect",0) if sender == "metoffice@service.govdelivery.com" else "no details" %}
{% set local = true if "LOCATION" in text else false %}
{% set cancel = true if "Cancelled" in text else false %}
{% set tz = "+01:00" if "UTC+1" in text else "Z" %}
{% if 'wind' in subject %}
{{ {"start": start, "end": end, "type": "wind", "local": local, "cancel": cancel, "details": details, "tz": tz} }}
{% elif 'rain' in subject %}
{{ {"start": start, "end": end, "type": "rain", "local": local, "cancel": cancel, "details": details, "tz": tz} }}
@markxroberts
markxroberts / template.yaml
Last active October 5, 2025 06:37
Metoffice Home Assistant setup from severe weather warning email alerts
- trigger:
- platform: event
event_type: "imap_content"
event_data:
sender: "metoffice@service.govdelivery.com"
custom:
type: 'wind'
id: received
- platform: time
at: sensor.weather_warning_wind_end