Binary Sensor - Life360 phone battery charging state

Im having an issue with getting a binary sensor for an attribute from life360 to work.

This is what I currently have:

  - platform: template
    sensors:
      brodie_iphone_charge_state:
        friendly_name: Brodie's iPhone Charge State
        value_template: >
          {{ is_state('device_tracker.life360_brodie.attributes', 'battery_charging', 'true')}}

Have also tried:

  - platform: template
    sensors:
      brodie_iphone_charge_state:
        friendly_name: Brodie's iPhone Charge State
        value_template: >
          {{ is_state_attr('device_tracker.life360_brodie', 'battery_charging', 'true')}}

Any help would be greatly appreciated

Try:

        value_template: >
          {{ state_attr('device_tracker.life360_brodie', 'battery_charging') }}
3 Likes

That did it.

Thanks so much!

2 Likes

Just an FYI. Your first attempts didn’t work because that attribute is a boolean, not a string. At the very least you would need to have done this:

        value_template: >
          {{ is_state_attr('device_tracker.life360_brodie', 'battery_charging', true) }}

But since it’s already a boolean, there’s no need to check if true is true. :wink:

2 Likes