Now, I twice have had Latops where the battery was bulging and threathen to destroy the Laptops - due to the fact that the ware on full 220V supply constantly.

So - Now I am ensuring that the batteries a disacharged and charged on a regular basis.


Laptop

Script:

sudo systemctl restart upower
sleep 2
upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | sed 's/ //g' | sed 's/percentage://g' | sed 's/%//' | awk -F. '{print $1}' > /var/www/html/battery/battery.txt


root@sparrow:/home/bnp# cat /var/www/html/battery/battery.txt
100 

I pick this up in Home Assistant via a sensor:

- platform: rest
  name: Sparrow Battery
  resource: http://10.0.0.183/battery/battery.txt
  method: GET 
  value_template: '{{ value }}'
  unit_of_measurement: "%"
  scan_interval: 300

And in Node-RED I have a little automation:

At 09:00 every day, I turn off the socket that the MacBook gets power from.

When the battery percentage is below 20% - I turn on the socket again.


Tablet

Pretty much the same:

Here its a little more agressive - as the battery is going between 80%-20% and never are charged to 100%

I use https://www.fully-kiosk.com/ with a licence to get the Tablet battery status and in general read and control the tablets.