Smart phone charging to reduce battery degradation

I suspect this has been done before, but last year I put together an automation that would stop my phone charging once it reached a certain battery charge level (say 80%). The aim was to reduce the battery degradation I had seen with my previous phones (typically around 50% degradation after two years). I had read some information suggesting that charging the battery to a high voltage, and/or keeping it at high voltage was detrimental to battery life.

I’ve finally put together a blog post describing what I did.

After around 8 months of using this and other methods to limit my battery charge level, the results seem promising, but it’s probably still a bit early to tell if or how much it’s improving the situation.

2 Likes

This looks really cool, though I will have to ask you what kind of phone you are using. I ask this because iPhones for example already do this with software since iOS 13.

If that is the case your results might deceive you. But I like the idea!

Hi @jimz011 , I have an Android phone which doesn’t have that functionality.

However, I think the new iPhone charging algorithm doesn’t actually prevent charging over a certain level; it just aims to reduce the time the phone spends above 80% charge by attempting to predict when you are going to unplug it, and only fully charging it as that time approaches. This has the benefit of giving you a full charge when you want it (hopefully), but does still mean the battery regularly sees the high voltages that might increase degradation. It’s a good step though, and no doubt something similar will appear in Android which could make my automation obsolete!

1 Like

ive done something similiar, but expect looking at that google template i use the ha app 2.0 integration for iphone (perhaps this works with the android app as well) which also reports battery level & state paired with a energymonitoring plug u can determin if the phone is connected or not :slight_smile:

1 Like

Thanks for sharing @Flipso.

Yes, I had thought about switching to using the Home Assistant app, but it was released after I set this up, and I haven’t bothered to do that yet. I’m also a bit reluctant to have another app doing location tracking, if Google Maps is already doing it.

So how do you detect if the phone is connected? Do you make sure the smart plug is turned on and then assume a phone is connected when the power consumption jumps?

im on the way to try your approach because i really had problems with ha 2.0 to work reliably, the sensors often only updates if u had used the app bevor - probably a problem of my old iphone 6 (low mem, no real multitasking). The energymonitor is included because of that lack of reliability and it therefor checks if the state really matches the situation = if the battery pushes a command (in my case battery > 95%) he looks if something is connected then turns the plug off=)

1 Like

I’ve found the Google Maps reporting to be reasonably reliable on an Android device, although it can be delayed by a number of minutes sometimes. Not sure how well it would work with an iPhone, but hopefully it would be similar.

1 Like

ill try, but except of the lack reliability probably because of my old hardware i would advertise you for the ha 2.0 integration, its really amazing what that app can and how easy it gets integrated in ha and what tons of sensors u get

1 Like

Hi @oscill8ory
Thanks for posting this, you inspired me to make my own twist using the Home Assistant Android App. Here’s what I did:

Made an automation to handle the automated kill switch:

  • Note: the phone charger’s smart plug is called switch.string_lights_switch because I couldn’t be bothered renaming until I found the concept works.
- alias: 'Phone charged to 80%'
  initial_state: 'on'
  trigger: 
  - platform: numeric_state
    entity_id: sensor.cph1921_battery_level
    above: 77
  condition:
  - condition: state 
    entity_id: sensor.cph1921_battery_state
    state: 'charging'
  - condition: template
    value_template: '{{(as_timestamp(states.switch.string_lights_switch.last_changed) - as_timestamp(states.sensor.cph1921_battery_state.last_changed) ) | abs < 900}}'
  # - condition: state
  #   entity_id: input_boolean.bed_occupied
  #   state: 'off'
  action:
  - service: notify.mobile_app_cph1921
    data:
      title: Phone has charged to 80%.
      message: Consider disconnecting charger.
  - service_template: >
      {% if is_state('person.angelo', 'home') and is_state('input_boolean.bed_occupied', 'on') %} script.switch_phone_charger_off
      {% else %} script.do_nothing
      {% endif %}

… But then I noticed that my battery level wasn’t updating quickly enough, and therefore I was waking up to my phone being at 95%+. After reviewing the Android App documentation, I found that each location request also updates the battery level and state.

This automation calls a script:

- alias: 'Update Phone Battery Level for Charging'
  initial_state: 'on'
  trigger: 
  - platform: state
    entity_id: switch.string_lights_switch
    from: 'off'
    to: 'on'
  action:
  - delay:
      minutes: 2
  - service: script.update_angelo_phone_battery_1

This script then creates a 5 minute loop that moves back and forth between another script until the phone’s charger has been turned off.
Script 1

update_angelo_phone_battery_1:
  alias: Update Angelo Phone Battery 1
  sequence:
  - service: notify.mobile_app_cph1921
    data:
      message: "request_location_update"
  - delay: 
      minutes: 5
  - condition: state
    entity_id: sensor.cph1921_battery_state
    state: 'charging'
  - condition: state  
    entity_id: switch.string_lights_switch
    state: 'on'
  - service: script.update_angelo_phone_battery_2

Script 2

update_angelo_phone_battery_2:
  alias: Update Angelo Phone Battery 2
  sequence:
  - service: notify.mobile_app_cph1921
    data:
      message: "request_location_update"
  - delay: 
      minutes: 5
  - condition: state
    entity_id: sensor.cph1921_battery_state
    state: 'charging'
  - condition: state  
    entity_id: switch.string_lights_switch
    state: 'on'
  - service: script.update_angelo_phone_battery_1

This worked a treat last night. My phone was on 79% when I woke up at 6:30 AM. I also set my phone (Oppo Reno 5G) to automatically switch off at 3:00 AM every morning to conserve battery when it should have charged to 80%.


1 Like

Hello Flipso,

Could you share the JSON-file for this flow?

im sorry, I can’t. I have rewritten my node red completely and this got kicked out because as mentioned bevor there was a lack of reliability which only got this working if the app got opened. but if you try to recreate and get to problems you could post them here and ill try to fix that!