Collecting attributes data from entity

Code used:

### iPad Pro 12.9
- platform: template
  sensors:
    battery_percentage_ipad_pro_129:
      friendly_name: 'iPad Pro 12.9 Battery Percentage'
      unit_of_measurement: '%'
      value_template: >-
          {%- if states.device_tracker.ipadpro129.attributes.battery %}
              {{ states.device_tracker.ipadpro129.attributes.battery|round }}
          {% else %}
              {{ states.sensor.battery_percentage_ipad_pro_129.state }}
          {%- endif %}
      device_class: battery
- platform: template
  sensors:
    battery_charging_status_ipad_pro_129:
      friendly_name: 'iPad Pro 12.9 Charging Status'
      value_template: >-
        {% if states.device_tracker.ipadpro129.attributes.battery_status == 'Charging' %}
            Charging 
        {% elif states.device_tracker.ipadpro129.attributes.battery_status == 'NotCharging' %}
            Not Charging
        {% else %}
            Unknown
        {% endif %}
      icon_template: >-
        {% if states.device_tracker.ipadpro129.attributes.battery_status == 'Charging' %}
            mdi:power-plug
        {% elif states.device_tracker.ipadpro129.attributes.battery_status == 'NotCharging' %}
            mdi:power-plug-off
        {% else %}
            mdi:battery-unknown
        {% endif %}

Of cource change xxx.ipadpro129.xxx in what you have for your device tracker.

Note: the Unknown status of the iPad Pro 12.9 is correct. Issues with the iCloud tracker…