mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Add cookbook entry for battery levels
This commit is contained in:
parent
58a9a98a66
commit
e24bcbf058
38
source/_cookbook/track_battery_level.markdown
Normal file
38
source/_cookbook/track_battery_level.markdown
Normal file
@ -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 %}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user