iPhone battery level not showing

Hello all,

I included the whole iPhone-battery state issue into my config:

1st. The sensor (as shown here):

 sensors:    
  - platform: template
      sensors:
        battery_iphone:
          unit_of_measurement: '%'
          value_template: >-
              {%- if states.device_tracker.iphone.attributes.battery %}
                  {{ states.device_tracker.iphone.attributes.battery|round }}
              {% else %}
                  {{ states.sensor.battery_iphone.state }}
              {%- endif %}

And in one of my views I added the group and entity:

  iphone:
    name: Stephans iPhone
    entities:
      - sensor.battery_iphone

I see the group in the webpanel BUT without any percentage. It says “unknown %”.
Looking into my logs it looks like it is communicating with the Find my iPhone-Server (and sending the right battery level among much much more information):

17-04-07 19:07:46 DEBUG (Thread-8) [pyicloud.services.findmyiphone.http] batteryLevel': 0.4199999868869781

Does anybody know why the battery_sensor isn’t extracting the battery_level?
iCloud is configured in the config and 2-factor-authentication is disabled as well (as recommended here)

Cheers

is your phone listed as “device_tracker.iphone” in the states table? If not you need to customize the name to match your setup.

It was listet as “device_tracker.myiphone”, thank you. So I changed the sensor as well as the group-entry:

 sensors:    
  - platform: template
      sensors:
        battery_myiphone:
          unit_of_measurement: '%'
          value_template: >-
              {%- if states.device_tracker.myiphone.attributes.battery %}
                  {{ states.device_tracker.myiphone.attributes.battery|round }}
              {% else %}
                  {{ states.sensor.battery_iphone.state }}
              {%- endif %}

Still no success.

Weird thing: If I comment all groups out my phone appears in the default_view:

low power mode
true
battery status
Charging
battery
37.00000047683716
device status
offline
account name
my_iphone
longitude

interval
1
gps accuracy
10
source type
gps
latitude

Any ideas?

Cheers

I have the same issue, did you find a solution to your

sensor.battery_iphone unknown

Right now I would just be happy to get rid of it…