Best method of knowing when our phones are plugged in?


My partner and I both have android phones and want to be able to reliably report to our HA when our phones are plugged in/unplugged.

So far I’ve tried:

  • Two separate MQTT plugins for Tasker. Both work intermittently, sometimes taking up to 60 seconds to fire, if at all. Both stop working after a couple of days regardless. No good.
  • Using Tasker to fire a HTTP POST to my HA. This is basically instant, however if I have no connection/intermittent connection at the time of the trigger, the web request gets lost and I have no way of repeating/confirming.
  • Using IFTTT’s Charging/Not Charging triggers to fire a HTTP POST to HTTP2MQTT running on a Pi. Seems the most reliable, but seems to take several minutes to reach the HA… however again, I find this works about 70% of the time.

Does anyone have a reliable & quick method of informing your HA when your phone is plugged in?

I currently use the Google Maps Location sharing component:

It has a battery_charging attribute that shifts to “true” when your phone is plugged in. I have an automation that tells me when my phone is charging and reports the battery percentage:

- alias: Alert  when my Phone is Charging
    platform: template
    value_template: '{{ states.device_tracker.google_maps_10997766544904342137605.attributes.battery_charging }}'
    - service: notify.sms
        message: '{{now().strftime("%H:%M:%S")}} CDT Pixel is being charged and is at {{states.device_tracker.google_maps_10997766544904342137605.attributes.battery_level}}%)'

I also have a Zigbee power outlet that I report when the wattage goes to a specific number. You can also do this with a Zwave power outlet:

- alias: Set  Phone Charging to On if power is more than 5 watts
    - platform: numeric_state
      entity_id: sensor.centralite_3210l_0b2d5889_1_2820
      above: '5'
    service: homeassistant.turn_on
    entity_id: input_boolean.myphonecharging

Ariela android client has a build in battery MQTT sensors that can send informations to HA like: battery level, health, temperature, charging state, even if the phone is charging wireless or by cable.

Please tell me how to set this up in HA. I have my Android device, but only see for battery lever (between percentages…) how do you get state (charging/not)?

Install the companion app and you will get lots of sensors.

If you click on that sensor you will be able to see lots of other values like charging status, battery temp etc