Hey guys.
I have an automation which runs a script on volume change of my AVR and sends an notification to my Android TV (Nvidia shield).
Sadly, sometimes it throws an conversation exception.
Script:
alias: VolumeOSD
sequence:
- condition: device
device_id: 32fb178b6d500a6c3d8485db757b214f
domain: media_player
entity_id: media_player.fernseher
type: is_on
- service: notify.android_tv_wohnzimmer
data:
title: Lautstärke
message: >-
{{ ((state_attr('media_player.lautsprecher', 'volume_level') *
100)|round(1)) }}
data:
duration: 1
position: top-right
fontsize: large
transparency: 0%
color: indigo
interrupt: 0
icon:
url: http://192.168.0.8:8123/local/speaker.png
mode: single
icon: mdi:amplifier
Exception:
2022-03-13 22:39:02 ERROR (MainThread) [homeassistant.components.script.volumeosd] VolumeOSD: Error executing script. Error for call_service at pos 2: Error rendering data template: TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
2022-03-13 22:39:02 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 407, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1814, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
I think it’s an problem when the media_player (denon AVR) is switched on or off.
Can you please help me to do some error try & catch on volume_level?
thx
pOpY