Owntracks and Battery attribute


I use the battery attribute from owntracks to display in HA. Since moving to 0.94, it changed name and but still reported and worked once I changed the sensor… Now after a couple of days the attribute has vanished…

Does anyone know what has happened to it please?

  - platform: template
        friendly_name: 'Mark battery'
        value_template: '{{ states.device_tracker.mark_mark.attributes.battery_level|float }}'
        unit_of_measurement: "%"
         - device_tracker.mark_mark


I have a similar issue… when I reboot HA… the battery attribute from my OwnTracks tracker works fine. Then… about 12 hours later, it stops registering the battery attribute from my android phone, even though it updates the GPS location without issue.

I then get an error that says:

Log Details (ERROR)

Sun Jun 16 2019 19:06:24 GMT-0400 (Eastern Daylight Time)

Could not render template Android Battery: UndefinedError: ‘mappingproxy object’ has no attribute ‘battery_level’

I’m not sure why it’s failing all the sudden.

Im having the same problem. Upgraded to 0.94.3 from 0.93.2 and now I dont get battery to my devices.

  - platform: template
        friendly_name: "Saras Batteri"
        unit_of_measurement: "%"
        value_template: "{{ state_attr('device_tracker.sara_android_owntracks', 'battery') }}"
        device_class: battery

Whats wrong with my setup?

I think yours may be simple… try changing ‘battery’ to ‘battery_level’ in the value template.

1 Like

That helped! Now its working again! :grinning:

Cool! Glad it was that easy!

yes this is happening to me as well.

To reproduce it-- change from not_home back to home.

I’m on 0.95.4 and the battery level pops in and out.
Also when I am away if you look at HA it shows me as away for about 5 seconds and then home for 5 seconds and this repeats in a loop.
Not sure when it started, but something is wrong.
Any thoughts?

I don’t have the issue with home/not home but my battery is sometimes there other times not… no idea why

I solved this by switching from http to mqtt in owntracks.

Always shows battery now, never cuts out anymore.

strange as mine has always been mqtt and still does this


Mark I did notice IF you have regions set in owntracks it can cause in an issue when it stops calculating the proximity. Mainly with Home. Use HA zone.home to solve it.

where do you mean Jim? I do have 3 regions, but in HA I use zone. ?

Mine is getting worse… Particularly when I am not home


And I don’t use any regions within OwnTracks… all my zones are in HA…

I’ve removed all my regions and it still says unknown… I am outside of my home zone at work