Notify if the phone is fully charged

Hi, i have installed the HA companion app to my android phone and i saw there a sensor.battery_level entity which can display the battery level and the flag whether the phone is charging under the attributes. I would like to use my Google Home to inform me when my phone is fully charged with an automation.

I’m planning to use the battery level (higher than 99%) as the trigger condition and also is_charging attribute from the sensor.battery_level as the condition to fire the tts to my Google Home.

May i know how do i extract is_charging attribute and use in the automation?

Thanks in advance.

1 Like

Hello… You can use an attribute in an automation by using the “platform: template”…

Example (I do not know the value of the attribute “IS_CHARGING” so I compared in the example to value equal “YES”:

- alias: example
  initial_state: true
  trigger:
    - platform: template
      value_template: '{{ "Yes" == (states.sensor.battery_level.attributes.is_charging) }}'
  condition:
      - <YOUR CONDITIONS>
  action:
     - <YOUR ACTIONS> 

Thanks for the reply. The value of the attribute is true/false so i have to replace the “Yes” to “true”? Is my understanding correct?

As the value is already true/false, the automation will trigger when the value is becoming true… If this is not what you are looking for, you effectively need to test if your attribute is equal to false to trigger…

I didn’t even know that those sensors existed (along with the sensor.wifi_connection).

Who decided to make those sensor names so generic? You would think they would at least have the base name of the device tracker entity in them somewhere.

This was actually something that impacted both iOS and Android but it will be fixed in 0.106 for new entities that get created.

Thanks. I will try it out with your recommendation.