Track Battery Phone Problem

Hi, I’m new with HA. I saw a tutorial about sending your battery level to HA by using tasker.
I can send it, no problem, but however HA recognize my state as unknown…
When I click on my card, it shows a graph with the right values…

What I did was, in tasker I gave this data:
{“state”:"%BATT", “attributes”: {“friendly_name”: “Phone Battery”, “icon”:“mdi:watch”,“unit_of_measurement”:"%"}}

And in my configuration.yaml, I used a template sensor:

  • platform: template
    unit_of_measurement: ‘%’
    value_template: ‘{{ value_json.state }}’

Can someone tell me what I did wrong? I guess thare must be something wrong in value_template in my configuration file, isn’t it?

I have my iPhone 6’s battery tracked by Owntracks and MQTT (not using Tasker so I’m not sure if I can be of any help), but this is what my setup looks like:

This is what my code looks like within the sensors section:

- platform: mqtt state_topic: "owntracks/iphone-jgaspar/iphone-jgaspar" name: "Justin iPhone 6 Battery" unit_of_measurement: "%" value_template: "{{ value_json.batt }}"

Under my groups section, I call out the sensor using:

- sensor.justin_iphone_6_battery

@broesie did you solve your problem?

I’m not using that sensor anymore…

1 Like

well, i basically have to set owntracks as “significant changes mode” otherwise this just drains the battery in a heartbeat…
so looking at the owntracks documentation, it only updates if it sees a position change of over >500m and max. one time in 5min.

So at home when your phone is laying there (no move of 500m) it wont update…

I was using iCloud before…but since there is a bug in that one, i switched over to owntracks.
Hope the iCloud presence detection is fixed soon :slight_smile: