Errors while using trigger variables with trigger-based template entities.
kulmegil opened this issue · comments
The problem
Template integration does not provide separate section for variables that would be useful in some scenarios. However it's possible to attach them to individual triggers as described in automation docs.
While trigger and entity works as expected, it spams log with errors
.
What version of Home Assistant Core has the issue?
2022.5.5
What was the last working version of Home Assistant Core?
2022.5.5
What type of installation are you running?
Home Assistant Core
Integration causing the issue
template
Link to integration documentation on our website
https://www.home-assistant.io/integrations/template/
Diagnostics information
No response
Example YAML snippet
template:
- trigger:
- platform: state
entity_id: sensor.impk_12716
variables:
line104: |
{{- state_attr("sensor.impk_12716", "list") | default([]) | selectattr("line", "==", "104") | list -}}
# more lines
stop_name: DZIELNA
sensor:
- unique_id: impk_stop_12716_line_104
device_class: timestamp
icon: 'hass:bus'
availability: '{{ line104|length >= 1 }}'
name: '{{ line104[0].line + " → " + line104[0].direction if line104|length >= 1 else "104 ("+stop_name+")" }}'
state: '{{ line104[0].departure if line104|length >= 1 else "" }}'
attributes:
line: '104'
direction: '{{ line104[0].direction if line104|length >= 1 else "" }}'
delay: '{{ line104[0].delay if line104|length >= 1 else 0 }}'
stop_id: 12716
next_departure: '{{ line104[1].departure if line104|length >= 2 else "" }}'
next_direction: '{{ line104[1].direction if line104|length >= 2 else "" }}'
third_departure: '{{ line104[2].departure if line104|length >= 3 else "" }}'
third_direction: '{{ line104[2].direction if line104|length >= 3 else "" }}'
# more similar sensors
Anything in the logs that might be useful for us?
Logger: homeassistant
Source: helpers/trigger.py:73
First occurred: 15:44:18 (24 occurrences)
Last logged: 15:53:18
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/trigger.py", line 73, in with_vars
await action(run_variables, context)
TypeError: object NoneType can't be used in 'await' expression
Additional information
Used it in another scenario and it creates the same error.
Hey there @PhracturedBlue, @tetienne, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (template
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
template documentation
template source
(message by IssueLinks)
The same error but in automation with trigger variables. Error appears not every time trigger fires. Can't find the pattern of its occurrence.
Core 2022.5.5
HA OS 8.1
Seeing same issue in 2022.8.6. In this case the trigger causing it is:
- platform: event
event_type: event_template_reloaded
variables:
version: >
{% set version = [state_attr('sensor.tessie_vehicle_state_data_sensor', 'car_version'),states('sensor.tessie_software_teslascope'),states('sensor.tessie_software_current_version')] | reject('in',[None,'unknown','unavailable']) | list | first|default('unknown') %}
{{ version.split(' ')[0] }}
If I remove that event and reload I get no error. Mind, issue clearly is not specific to this kind of trigger; just that this trigger is triggered on reloading the templates.