Sonos dynamic volume_set - templating

Hello,

I’m using a Homematic Remote to control SONOS speaker. I want to use the remote to control the volume of sonos speaker in addiction to the actual volume, because the “volume_up” / “volume_down” service is incresing the volume by 0.05. I’m using a separate sensor, which stores the volume level of the speaker. If the volume is below 0.09 the automation should trigger and should change the volume by step 0.01.

- alias: 'hmkey2s_low'
  hide_entity: True
  trigger:
    platform: event
    event_type: homematic.keypress
    event_data:
      name: Remote
      channel: 2
      param: PRESS_SHORT
  condition:
    condition: numeric_state
    entity_id: sensor.sonos_wz_volume
    below: 0.09
  action:
    service: media_player.volume_set
    entity_id: media_player.wohnzimmer
    data:
      volume_level: '{{ states.media_player.wohnzimmer.attributes.volume_level + 0.01}}'

The automation is triggered, but the volume of the sonos speaker does not change.

Any help is appreciated.

data_template: might help

Thanks

data_template:
      volume_level: '{{ states.media_player.wohnzimmer.attributes.volume_level + 0.01}}'

solves the problem.