Hi,
i have an automation script with multiple OR condition (if it rain or wind speed is over or …) and when one of this apply it do a job and send me a notification.
My question is… Is it possible to notify why the automation apply?
Hi,
i have an automation script with multiple OR condition (if it rain or wind speed is over or …) and when one of this apply it do a job and send me a notification.
My question is… Is it possible to notify why the automation apply?
yes, use a template trigger
I make a test with telegram notification but it doesn’t work due trigger is undefined (the same happen for my automation)
- alias: 'Telegram bot that reply pong to ping'
hide_entity: true
trigger:
platform: event
event_type: telegram_command
event_data:
command: '/ping'
action:
- service: notify.telegram
data:
message: 'pong {{ trigger.event }} '
About
Home Assistant
0.68.1Path to configuration.yaml: /config
Developed by a bunch of awesome people.
Published under the Apache 2.0 license
Source: server — frontend-uiBuilt using Python 3, Polymer 2.6.0, Icons by Google and MaterialDesignIcons.com.
Frontend JavaScript version: latest
Error executing service <ServiceCall notify.telegram: message=<homeassistant.helpers.template.Template object at 0x737b7f50>>
12:40 PM helpers/template.py (ERROR)
Payload is not True, False, or integer (0-100):
12:33 PM components/cover/mqtt.py (WARNING)
Error executing service <ServiceCall notify.telegram: message=<homeassistant.helpers.template.Template object at 0x70389650>>
12:33 PM helpers/template.py (ERROR)
Error executing service <ServiceCall notify.telegram: message=<homeassistant.helpers.template.Template object at 0x6fc71110>>
12:12 PM helpers/template.py (ERROR)
Timer got out of sync. Resetting
12:11 PM core.py (ERROR)
Error executing service <ServiceCall notify.telegram: message=<homeassistant.helpers.template.Template object at 0x6fc48410>>
12:11 PM helpers/template.py (ERROR)
Payload is not True, False, or integer (0-100):
11:31 AM components/cover/mqtt.py (WARNING)
Error fetching description at http://[fe80::526b:8dff:fe36:1c42]:8096/dlna/b693aed2127a4f6596b18327dd88f756/description.xml
11:26 AM ssdp.py (WARNING)
Setup of platform enigma is taking over 10 seconds.
11:25 AM bootstrap.py (WARNING)
Setup of config is taking over 10 seconds.
11:25 AM bootstrap.py (WARNING)
Ended unfinished session (id=134 from 2018-05-03 09:02:13.395247)
11:25 AM components/recorder/init.py (WARNING)Press the button to load the full Home Assistant log.
Log Details (ERROR)Fri May 04 2018 12:40:47 GMT+0200 (W. Europe Daylight Time)
Error executing service <ServiceCall notify.telegram: message=<homeassistant.helpers.template.Template object at 0x737b7f50>>
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/template.py”, line 132, in async_render
return self._compiled.render(kwargs).strip()
File “/usr/lib/python3.6/site-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/usr/lib/python3.6/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/lib/python3.6/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/lib/python3.6/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
File “/usr/lib/python3.6/site-packages/jinja2/sandbox.py”, line 385, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘trigger’ is undefinedDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/core.py”, line 1002, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/lib/python3.6/site-packages/homeassistant/components/notify/init.py”, line 134, in async_notify_message
kwargs[ATTR_MESSAGE] = message.async_render()
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/template.py”, line 134, in async_render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: ‘trigger’ is undefinedService automation/reload called.
Above doesn’t make sense, you mentioned multiple sensors. above doesn’t list any.
can you provide the automation that tracks sensors?
This is the one you need to add the trigger template to.
See extract from mu config:
- alias: Notify iOS app
trigger:
- platform: state
entity_id: alert.basil_battery_too_low
from: 'idle'
to: 'on'
- platform: state
entity_id: alert.basil_humidity_too_low
from: 'idle'
to: 'on'
action:
- service: counter.increment
entity_id: counter.iosbadgecount
- service: notify.ios_lolos_iphone
data_template:
message: '{{ trigger.entity_id | replace("alert.","") | replace("_"," ") |capitalize }}'
- alias: 'Telegram bot that reply pong to ping'
hide_entity: true
trigger:
platform: event
event_type: telegram_command
event_data:
command: '/ping'
action:
- service: notify.telegram
data_template: #<------ NEEDS TO BE A DATA TEMPLATE
message: 'pong {{ trigger.event }}'
Although I don’t think that’s what’s causing the problem.
This is the automation code:
- alias: Awning Close
initial_state: 'on'
trigger:
- platform: sun
event: sunset
offset: -01:30:00
- platform: numeric_state
entity_id: sensor.dark_sky_wind_speed
above: 6
- platform: numeric_state
entity_id: sensor.dark_sky_precip_intensity
above: 3
- platform: numeric_state
entity_id: sensor.weather_yr_cloudiness
above: 60
condition:
condition: state
entity_id: cover.tenda_1
state: open
for:
seconds: 40 ## The screen takes some time to fully roll up or down, I don't want it changing direction half way
action:
- service: cover.close_cover
entity_id: cover.tenda_1
- service: notify.telegram
data:
message: '{{now().strftime("%H:%M %Y-%m-%d")}}: Awning just changed from {{ trigger.from_state.state }} to {{ trigger.to_state.state }} due {{ trigger.event }} '
If i set
message: ‘{{now().strftime(“%H:%M %Y-%m-%d”)}}: Awning Closed’
I received the telegram message
…
action:
- service: cover.close_cover
entity_id: cover.tenda_1
- service: notify.telegram
data_template: #<------ NEEDS TO BE A DATA TEMPLATE
message: '{{now().strftime(“%H:%M %Y-%m-%d”)}}: Awning just changed from {{ trigger.from_state.state }} to {{ trigger.to_state.state }} due {{ trigger.event }} ’
I change the code but now the error is similar:
Fri May 04 2018 14:22:19 GMT+0200 (W. Europe Daylight Time)
Error rendering data template: UndefinedError: ‘trigger’ is undefined
can you share your code?
This is not possible because the trigger platforms are different.
to_state, and from_state won’t appear inside your trigger with event.
to clarify every platform type will only contain what is listed in the docs. So an event trigger will only contain:
a state trigger will only contain
above there is the code,
i change only the action from the 1st version to the latest one
Also, sun doesn’t contain to_state or from_state.
You are mixing too many trigger objects without checking what objects you got. You’re going to get different errors for different triggers…