mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 08:16:53 +00:00
Update device_tracker.owntracks_http.markdown (#5172)
* Update device_tracker.owntracks_http.markdown Show battery value reported by owntracks * Update device_tracker.owntracks_http.markdown Fix * Fix configuration sample
This commit is contained in:
parent
64df5f785a
commit
8fc39cb9db
@ -34,3 +34,30 @@ Open OwnTracks and go to Connection preferences:
|
|||||||
- Identification: Turn **Authentication** on, username `homeassistant` and password is your API password that you use to login to Home Assistant.
|
- Identification: Turn **Authentication** on, username `homeassistant` and password is your API password that you use to login to Home Assistant.
|
||||||
|
|
||||||
Host example: If I host my Home Assistant at `https://example.duckdns.org`, my name is Paulus and my phone is a Pixel I would set the host to be `https://example.duckdns.org/api/owntracks/paulus/pixel`. This will result in an entity with an ID of `device_tracker.paulus_pixel`. You can pick any name for the user and the device.
|
Host example: If I host my Home Assistant at `https://example.duckdns.org`, my name is Paulus and my phone is a Pixel I would set the host to be `https://example.duckdns.org/api/owntracks/paulus/pixel`. This will result in an entity with an ID of `device_tracker.paulus_pixel`. You can pick any name for the user and the device.
|
||||||
|
|
||||||
|
Since the battery data is available as an attribute of the device tracker entity, it can be tracked with a [`template` sensor](/components/sensor.template/).
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
sensor:
|
||||||
|
- platform: template
|
||||||
|
sensors:
|
||||||
|
pixel_battery:
|
||||||
|
friendly_name: Pixel of Paulus
|
||||||
|
unit_of_measurement: "%"
|
||||||
|
value_template: '{{ states.device_tracker.paulus_pixel.attributes.battery|int }}'
|
||||||
|
icon_template: >-
|
||||||
|
{% set battery_level = states.device_tracker.paulus_pixel.attributes.battery|default(0)|int %}
|
||||||
|
{% set battery_round = (battery_level / 10) |int * 10 %}
|
||||||
|
{% if battery_round >= 100 %}
|
||||||
|
mdi:battery
|
||||||
|
{% elif battery_round > 0 %}
|
||||||
|
mdi:battery-{{ battery_round }}
|
||||||
|
{% else %}
|
||||||
|
mdi:battery-alert
|
||||||
|
{% endif %}
|
||||||
|
entity_id:
|
||||||
|
- device_tracker.paulus_pixel
|
||||||
|
```
|
||||||
|
{% endraw %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user