I hate to bump this but I have been looking at it for days and either I am doing something stupid or there is something very wrong with HA (obviously I suspect the former).
Also, tagging @petro, @anon43302295, @Mariusthvdb may not be appreciated but this feels like just the kind of thing you generally solve. But I do apologise and feel free to ignore this if you want to.
(And of course any general improvements or recommendations are appreciated too.)
I have three automations that have identical triggers.
- one creates a persistant notification,
- one sets an
input_text
, - the other sets an
input_datetime
,
All achieve this by extracting from and reformatting trigger.event.data.description
.
My first issue is that one of these automations doesn’t actually fire when the trigger occurs. Any suggestions as to why this might be?
all them trigger like this:
trigger:
- platform: event
event_type: feedreader
The second issue is that even one of the automations that does fire doesn’t work even though in the template test tool, both work perfectly.
This is the persistant notification automation which always fires and always works.
automation:
- alias: 'Alert From Weather RSS Feed'
initial_state: on
trigger:
- platform: event
event_type: feedreader
action:
- service: script.notify
data_template:
show: True
message: "{{ trigger.event.data.description }}"
title: "{{ trigger.event.data.title }}"
This is the automation that never fires and in the next post is the automation that fires but doesn’t work (except in the template tool - it is long so had to be a second post).
In case anyone wants to try these here is an example of trigger.event.data.description
“Yellow Warning of Snow And Ice affecting England (London & South East England) : Buckinghamshire, Milton Keynes, Oxfordshire valid from 0900 Sat 15 Dec to 0900 Sun 16 Dec”
#====================
#=== Set expiry time
#====================
- alias: Met Office Severe Weather Warning Expiry
initial_state: on
trigger:
- platform: event
event_type: feedreader
action:
- service: input_datetime.set_datetime
data_template:
entity_id: input_datetime.met_office_severe_weather_warning_expiry
data:
time: >
{% set warning = trigger.event.data.description %}
{% set valid_to = warning.split('from ')[1].split(' to')[0] %}
{% set valid_to_hour = valid_to.split(' ')[0][0:2] %}
{% set valid_to_minutes = valid_to.split(' ')[0][2:4] %}
{{ valid_to_hour }}:{{ valid_to_minutes }}
date: >
{% set warning = trigger.event.data.description %}
{% set months_map = {
'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06',
'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12' } %}
{% set valid_to = warning.split('from ')[1].split(' to')[0] %}
{% set valid_to_date = valid_to.split(' ')[-2] %}
{% set valid_to_month = months_map[valid_to.split(' ')[-1]] %}
{{ now().year }}-{{ valid_to_month }}-{{ valid_to_date }}