Owntracks Android battery monitoring in combination with device tracking

Hello,

I can’t get Owntracks device tracking and Android battery monitoring work at the same time. Device tracking uses HTTP connection (at least whites recommended) and Android battery monitoring uses MQTT. I can get both to work individually but not at the same time. Is there a way to use MQTT for device tracking with Owntracks or Android battery monitoring with HTTP?

Regards,
Mikael

Have you looked at the attributes that come with the device tracker? Add the device tracking, then look at the entity in the developer tools/states page. You should see all the attributes. Battery state should be one of them.

You are correct!

But how do I extract that attribute as a sensor value?

With MQTT I used :

- platform: mqtt
    state_topic: "owntracks/Micke/s10"
    name: "Phone Battery"
    unit_of_measurement: "%"
    value_template: '{{ value_json.batt }}'
    device_class: battery

Use the device tracker entity

  - platform: template
    sensors:
      phone_battery:
        friendly_name: "Battery level"
        unit_of_measurement: '%'
        device_class: battery
        value_template: "{{ state_attr('device_tracker.MY_PHONE', 'battery_level') }}"
1 Like

Perfect, thanks!