Track Your Battery Level


iOS Devices

If you have a device running iOS (iPhone, iPad, etc), The iCloud is gathering various details about your device including the battery level. To display it in the Frontend use a template sensor.

sensor:
  - platform: template
    sensors:
      battery_iphone:
        unit_of_measurement: '%'
        value_template: >-
            {%- if states.device_tracker.iphone.attributes.battery %}
                {{ states.device_tracker.iphone.attributes.battery }}
            {% else %}
                {{ states.sensor.battery_iphone.state }}
            {%- endif %}

The else part is used to have the sensor keep it’s last state if the newest iCloud update doesn’t have any battery state in it (which happens sometimes). Otherwise the sensor will be blank.

Android and iOS Devices

While running the Owntracks device tracker you can retrieve the battery level with a MQTT sensor.

sensor:
  - platform: mqtt
    state_topic: "owntracks/tablet/tablet"
    name: "Battery Tablet"
    unit_of_measurement: "%"
    value_template: '{{ value_json.batt }}'