node-RED: Setting the volume level based on existing volume level

Hi all!
I am trying to program my HUE Dimmer Switch to control Sonos.
I have successfully manage to turn on my Sonos and adjusting the volume, but I am trying to increase the volume_set steps.
I’m able to fetch the existing volume level and I’d like to add 0.05 to the value but I am getting “Extra keys not allowed”.
Please help me with what is wrong with the following statement entered in the DATA field:

{"volume_level":{{{data.attributes.volume_level}- 0.1}}}

Have a great day everyone!

Change the type of the data field to JSONata Expression and use

{"volume_level": data.attributes.volume_level - 0.1}

Thank you Kermit,
But i still get the same error:

Need to change the type of the data field


This worked!!! Thank you sooooooooo much!!!
(It turned out I was increasing the value too much as well…)
But, what is the difference between JSON and EXPRESSION?

I just found this. I copiesd the code you wrote, changed to “Expression” but get API Error:


78 / 5000

Rezultatele traducerii

How can I make the volume of a speaker take the value of an input number?

{“volume_level”:states.input_number.volume.state }

{"volume_level":  $number($entities("input_number.volume").state) }
1 Like

It works.
Thank you very much!
Have a nice day and weekend!

what is here the right code for volume up?

{"volume_level": $number($entities("input_number.volume").state) +0.1}


my entity id: media_player.denon_partyraum

have it

{ "volume_level":  $number($entities("media_player.denon_partyraum").attributes.volume_level)  -0.05}

I have exact same problem, maybe u figured it out ?