I’m trying to get Alexa to set the volume on my Denon receiver. Problem is that the receiver is showing negative dB values as display value and the component works with a positive value. Also it is scaled. I found out how to convert it, but after conversion I’m having a negative float, which should just be converted to a positive float.
So I tried it with abs() and multiplying with -1, but both return not the expected result. Was hoping someone here sees my mistake.
action:
service: media_player.volume_set
data_template:
entity_id: media_player.denon_livingroom
volume_level: '{{ Volume |float / 100 + -0.8 | round(2) }}'
speech:
type: plaintext
text: Ok
Volume is the var coming in through Alexa, confirmed working. Say in this example the outcome is -0.50, and it needs to be 0.50. Shouldn’t be a problem;
{{ Volume |float / 100 + -0.8 | round(2) | abs }}
And instead of the expected 0.50 it returns 1.1.
If I multiply with -1, it also returns 1.1
I think it has something to do with order, but using parentheses isn’t possible in Jinja2, right?