diff --git a/source/_cookbook/track_battery_level.markdown b/source/_cookbook/track_battery_level.markdown index d61575426ad..95a5a831de2 100644 --- a/source/_cookbook/track_battery_level.markdown +++ b/source/_cookbook/track_battery_level.markdown @@ -27,8 +27,12 @@ sensor: {% endraw %} ### Android and iOS Devices +While running the [Owntracks](/components/device_tracker.owntracks/) device tracker you can retrieve the battery level. +How you achieve this depends on how you have configured your Owntracks instance. -While running the [Owntracks](/components/device_tracker.owntracks/) device tracker you can retrieve the battery level with a MQTT sensor. Replace username with your MQTT username (for the embedded MQTT it's simply homeassistant), and deviceid with the set Device ID in Owntracks. +#### MQTT +If you have configured Owntracks to send reports via MQTT you can use the received data via a MQTT sensor. +Replace username with your MQTT username (for the embedded MQTT it's simply homeassistant), and deviceid with the set Device ID in Owntracks. {% raw %} ```yaml @@ -41,3 +45,19 @@ sensor: device_class: battery ``` {% endraw %} + +#### HTTP + +If you have configured Owntracks to send reports to your Home Assistant instance via HTTP you can use a template sensor. +Replace `deviceid` with the set Device ID in Owntracks. + +{% raw %} +```yaml +sensor: +- platform: template + sensors: + your_battery_sensor_name: + value_template: "{{ state_attr('device_tracker.deviceid', 'battery_level') }}" + unit_of_measurement: '%' +``` +{% endraw %}