Add Android example (#11686)

* Add Android example

Add Android example configuration

* ✏️ Tweak

* ✏️ Add information

* ✏️ Tweaks

Co-authored-by: Klaas Schoute <klaas_schoute@hotmail.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
PaulParis1 2020-01-12 10:53:15 +01:00 committed by Franck Nijhof
parent bec63cd245
commit badb6c8a17

View File

@ -29,7 +29,32 @@ sensor:
```
{% endraw %}
### Android Devices
On your Android device, once the official [Home Assistant companion app](https://companion.home-assistant.io/) is installed and connected to your Home Assistance instance, you will be able to display the battery level in the frontend by adding a [template sensor](/integrations/template) to your configuration YAML file. You can also use the battery [sensor device class](/integrations/sensor/#device-class) to dynamically change the icon with the battery level.
{% raw %}
```yaml
sensor:
- platform: template
sensors:
battery_phone:
friendly_name: AndroidPhone Battery
unit_of_measurement: '%'
value_template: >-
{%- if state_attr('device_tracker.xxxxx', 'battery_level') %}
{{ state_attr('device_tracker.xxxxx', 'battery_level')|round }}
{% else %}
{{ states('device_tracker.xxxxx') }}
{%- endif %}
device_class: battery
```
{% endraw %}
Replace 'device_tracker.xxxxx' with your phone name as shown under Configuration/Devices Device Info/Entities, for example: 'device_tracker.mi_a1'
#### 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.