URL parameter as custom battery level

Hi all, newbie here.
I defined a custom device:

sensor:
  - platform: template
    sensors:
      mystrom_b1_2p:
        friendly_name: "myStrom b1 2p"
        unit_of_measurement: '%'
        value_template: "{{ states.mystrom_b1_2p.attributes.battery_level }}"
        device_class: battery

The battery level of the device is present in a POST request I got with webhook:

action <MultiDictProxy(‘action’: ‘generic’, ‘mac’: ‘68C63AD0XXYY’, ‘action’: ‘6’, ‘battery’: ‘23’)>

the single attribute should be:

{{ trigger.data.battery }}

How I can assign URL parameter as the battery level of my custom device?
I’m stuck with value_template and data_template, the difference is not clear for me.
Thanks for any hint.
-f