This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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} }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |