mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 08:16:53 +00:00
Add a way to retrieve battery level via HTTP (#10437)
* Add a way to retrieve battery level via HTTP The MQTT way of receiving data only seems to work if you have configured a MQTT backend. Added a template sensor to get the battery level with a HTTP Owntracks backend. This way is tested on my Hometracks system. * Apply direct suggestions from code review Added the easy changes where @frenck gets attributed Co-Authored-By: Franck Nijhof <frenck@frenck.nl> * Applied suggestion to value_template Changed the way the value_template gets the battery_level as suggested by @frenck . Tested on my system to make sure it works. Co-Authored-By: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
9569b2968e
commit
e881649c1a
@ -27,8 +27,12 @@ sensor:
|
||||
{% endraw %}
|
||||
|
||||
### Android and iOS Devices
|
||||
While running the [Owntracks](/components/device_tracker.owntracks/) device tracker you can retrieve the battery level.
|
||||
How you achieve this depends on how you have configured your Owntracks instance.
|
||||
|
||||
While running the [Owntracks](/components/device_tracker.owntracks/) device tracker you can retrieve the battery level with 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.
|
||||
#### 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.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
@ -41,3 +45,19 @@ sensor:
|
||||
device_class: battery
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
#### HTTP
|
||||
|
||||
If you have configured Owntracks to send reports to your Home Assistant instance via HTTP you can use a template sensor.
|
||||
Replace `deviceid` with the set Device ID in Owntracks.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
your_battery_sensor_name:
|
||||
value_template: "{{ state_attr('device_tracker.deviceid', 'battery_level') }}"
|
||||
unit_of_measurement: '%'
|
||||
```
|
||||
{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user