From e24bcbf0584f05d7f6df55947633447202f2a4a8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 29 Jan 2016 10:54:39 +0100 Subject: [PATCH] Add cookbook entry for battery levels --- source/_cookbook/track_battery_level.markdown | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 source/_cookbook/track_battery_level.markdown diff --git a/source/_cookbook/track_battery_level.markdown b/source/_cookbook/track_battery_level.markdown new file mode 100644 index 00000000000..54ff4279368 --- /dev/null +++ b/source/_cookbook/track_battery_level.markdown @@ -0,0 +1,38 @@ +--- +layout: page +title: "Track your battery level" +description: "Basic example how to track the battery level of your mobile devices." +date: 2016-01-29 09:00 +sidebar: false +comments: false +sharing: true +footer: true +--- + +### {% linkable_title Battery level %} + +The [iCloud](/components/device_tracker.icloud/) is gathering various details about your device including the battery level. To display it in the Frontend use a [template sensor](/components/sensor.template/). + +```yaml + - platform: template + sensors: + battery_iphone: + unit_of_measurement: '%' + value_template: >- + {% raw %}{%- if states.device_tracker.iphone.attributes.battery %} + {{ states.device_tracker.iphone.attributes.battery }} + {% else %} + {{ states.sensor.battery_iphone.state }} + {%- endif %}{% endraw %} +``` + +While running the [Owntracks](/components/device_tracker.owntracks/) device tracker you can retrieve the battery level with a MQTT sensor. + +```yaml + - platform: mqtt + state_topic: "owntracks/tablet/tablet" + name: "Battery Tablet" + unit_of_measurement: "%" + value_template: {% raw %}'{{ value_json.batt }}'{% endraw %} +``` +