using this:
- alias: 'Forward notifications to filed_notifications'
id: 'Forward notifications to filed_notifications'
# initial_state: 'off'
trigger:
platform: event
event_type: call_service
event_data:
domain: notify
service: notify
condition: []
action:
service: notify.filed_notifications
data_template:
message: >
{% set message = trigger.event.data.service_data.message %}
{{ as_timestamp(now()) | timestamp_custom('%d %b: %X') }}: {{ message }}
I am sending all notify.notify messages to a filed_notifications.txt.
Id like to expand this to all services in the notify domain, of course excluding the notify.filed_notifications itself.
Could I do that leaving out the service: notify
from the trigger?
secondly, Id like to add the service to the notification in the file.
right now the notifications look like:
11 Mar: 22:22:04: Netwerk Dorm switched off
Iād like to expand that too, with the relevant service, but am not sure what trigger data to use. would that be trigger.event.data.service_data.service
?
@pnbruckner since you helped me create this automation some time ago, allow me to ask for your assistance once more?
it wasnāt trigger.event.data.service_data.service
but should be trigger.event.data.service
would this be correct:
- alias: 'Forward notifications to filed_notifications'
id: 'Forward notifications to filed_notifications'
# initial_state: 'off'
trigger:
platform: event
event_type: call_service
event_data:
domain: notify
# service: notify
condition:
condition: template
value_template: >
{{trigger.event.data.service != filed_notifications}}
action:
service: notify.filed_notifications
data_template:
message: >
{% set message = trigger.event.data.service_data.message %}
{% set service = trigger.event.data.service_data.service %}
{{ as_timestamp(now()) | timestamp_custom('%d %b: %X') }} - {{service}}: {{ message }}
of course I have tried this:
1- it triggers on all notifications services, which is what I hoped for.
2- BUT: {{trigger.event.data.service != filed_notifications}} doesnāt prevent the automation from triggering on the filed_notifications, and renders an infinite loop of nested notificationsā¦
3- I do get this as filed notification:
11 Mar: 23:27:36 - notify: 23:27:36: Sun is below_horizon and Frontend is set to 'darkblue'
which means the service notify is displayed correctly, so trigger.event.data.service
is the correct way to get that.
4- Why then wonāt it filter out the filed_notifications in the condition?