Help needed setting up battery template sensot

I have an Aqara motion luminance sensor connected to zigbee2mqtt running on the same Pi 3 as Hassbian. I am trying to set up a template bettery sensor with the following configuration. It shows as a sensor on my frontend but with no value.

The motion and luminance sensor entity is sensor.presence_illuminance and report attribute as battery: 100.00

  - platform: template
    sensors: 
      presence_illuminance_batt:
        friendly_name: "Presence_battery"
        unit_of_measurement: '%'
        value_template: "{{ sensor.presence_illuminance.attributes.battery }}"

Am I doing anything wrong? Thanks

Try

value_template: "{{ states.sensor.presence_illuminance.attributes.battery }}"

Although my Xiaomi devices seem to have the attribute battery_level rather than battery.

Thanks! states.sensor.presence_illuminance.attributes.battery works for me

I think zigbee2mqtt reports attribute battery instead of battery_level