Not sure it’s a concern but I have an automation for my Denon receiver volume and although visually in the system it seems to work I get a lot of errors in the logs. The whole automation block is:
- alias: "Denon Set Volume"
initial_state: 'on'
trigger:
platform: state
entity_id: input_number.denon_volume
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.denon_x2200w
volume_level: >
{{states('input_number.denon_volume') | int / 100}}
- alias: "Denon Update Volume Slider"
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.denon_volume
- platform: homeassistant
event: start
condition:
condition: state
entity_id: media_player.denon_x2200w # receiver must be on to set the volume, without this would throw error on startup
state: 'on'
action:
- delay:
seconds: 3
- service: input_number.set_value
data_template:
entity_id: input_number.denon_volume
value: '{{ trigger.to_state.state }}'
The errors I’m seeing are and not sure if it’s caused from the way HA loads things or delays in loading:
2020-11-23 12:47:34 ERROR (MainThread) [homeassistant.components.automation.denon_update_volume_slider] Denon Update Volume Slider: Error executing script. Unexpected error for call_service at pos 2: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 351, in async_render
render_result = compiled.render(kwargs)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'to_state'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 144, in async_prepare_call_from_config
service_data.update(template.render_complex(config[conf], variables))
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 91, in render_complex
return {
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 92, in <dictcomp>
render_complex(key, variables): render_complex(item, variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 96, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'dict object' has no attribute 'to_state'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 253, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 432, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 146, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'
2020-11-23 12:47:34 ERROR (MainThread) [homeassistant.components.automation.denon_update_volume_slider] While executing automation automation.denon_update_volume_slider
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 351, in async_render
render_result = compiled.render(kwargs)
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'to_state'