mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-09 18:36:51 +00:00
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:
parent
bec63cd245
commit
badb6c8a17
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user