{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreifrdjmy32cipzqmefdlrfogasopzu5hdvsjswgogrew72ja7uoxgu",
    "uri": "at://did:plc:5y2ps7xhcqmc2d63b73ui72s/app.bsky.feed.post/3mihbhzfwkur2"
  },
  "description": "Stop overcharging your laptop and extend battery lifespan with Home Assistant automation. Use a smart plug, webhook triggers, and simple scripts to control charging between safe thresholds and protect your device long-term.",
  "path": "/stop-killing-your-laptop-battery-automate-charging-with-home-assistant/",
  "publishedAt": "2026-04-01T18:00:11.000Z",
  "site": "https://blog.php-systems.com",
  "textContent": "## ⚠️ The Hidden Reason Your Laptop Battery Dies Early\n\nMost people leave their laptop plugged in 24/7.\n\nThat’s the fastest way to **destroy a lithium-ion battery**.\n\nKeeping your battery at 100% constantly:\n\n  * Accelerates chemical wear\n  * Reduces total charge cycles\n  * Shortens lifespan by years\n\n\n\n👉 The ideal range? **20% – 80%**\n\nThe problem: laptops don’t manage this well.\n\nThe solution: **automate it yourself.**\n\n* * *\n\n## 💡 What This Setup Does (And Why It Works)\n\nThis system automatically:\n\n  * Cuts power at **80%**\n  * Restores power at **30%**\n  * Requires zero manual input\n\n\n\nResult:\n\n  * Less battery stress\n  * Longer lifespan\n  * Fewer replacements (save £££)\n\n\n\n* * *\n\n## 🧰 What You Need (Simple Setup)\n\n### 1. Smart Plug (Critical)\n\nThis is what actually controls charging.\n\n**Look for:**\n\n  * Fast response time\n  * Local control (no cloud lag)\n  * Home Assistant compatibility\n\n\n\n💡 Popular choices:\n\n  * TP-Link Tapo (great value, reliable)\n  * TP-Link Kasa (widely supported)\n  * Zigbee plugs (best for local control setups)\n\n\n\n👉 _Tip: Energy monitoring plugs give you extra insight into charging patterns._\n\n* * *\n\n### 2. Home Assistant\n\nIf you’re already running Home Assistant, you’re set.\n\nIf not, this is one of the most useful real-world automations you can build with it.\n\n* * *\n\n### 3. A Simple Script (Runs on Your Laptop)\n\nThis checks battery level and sends signals.\n\n* * *\n\n## ⚙️ Step 1: Home Assistant Automation\n\nAdd these automations:\n\n\n    alias: Laptop Charging Control - OFF\n    trigger:\n      - platform: webhook\n        webhook_id: laptop_charge_off\n    action:\n      - service: switch.turn_off\n        target:\n          entity_id: switch.laptop_plug\n    mode: singlealias: Laptop Charging Control - ON\n    trigger:\n      - platform: webhook\n        webhook_id: laptop_charge_on\n    action:\n      - service: switch.turn_on\n        target:\n          entity_id: switch.laptop_plug\n    mode: single\n\n👉 Replace `switch.laptop_plug` with your actual device.\n\n* * *\n\n## 🌐 Step 2: Webhook Setup (This Is the Key Bit)\n\nHome Assistant automatically creates endpoints:\n\n`http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_off\nhttp://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_on`\n\n### Important Tips:\n\n  * Keep these URLs **private**\n  * Use HTTPS if accessing remotely\n  * Test with:\n\n\n\n`curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_off`\n\n* * *\n\n## 💻 Step 3: Battery Monitoring Scripts\n\n### 🪟 Windows (AutoHotkey)\n\n\n    SetTimer, CheckBattery, 60000\n    return\n\n    CheckBattery:\n    battery := ComObjGet(\"winmgmts:\\\\.\\root\\cimv2\").ExecQuery(\"Select * from Win32_Battery\")\n    for b in battery {\n        level := b.EstimatedChargeRemaining\n\n        if (level >= 80) {\n            Run, curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_off\n        }\n\n        if (level <= 30) {\n            Run, curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_on\n        }\n    }\n    return\n\n* * *\n\n### 🐧 Linux (Bash)\n\n\n    #!/bin/bash\n\n    BATTERY_LEVEL=$(cat /sys/class/power_supply/BAT0/capacity)\n\n    if [ \"$BATTERY_LEVEL\" -ge 80 ]; then\n      curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_off\n    fi\n\n    if [ \"$BATTERY_LEVEL\" -le 30 ]; then\n      curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_on\n    fi\n\nRun every minute via cron:\n\n`* * * * * /path/to/script.sh`\n\n* * *\n\n### 🍎 macOS Alternative\n\n\n    #!/bin/bash\n\n    BATTERY_LEVEL=$(pmset -g batt | grep -Eo \"\\d+%\" | tr -d '%')\n\n    if [ \"$BATTERY_LEVEL\" -ge 80 ]; then\n      curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_off\n    fi\n\n    if [ \"$BATTERY_LEVEL\" -le 30 ]; then\n      curl -X POST http://YOUR_HOME_ASSISTANT:8123/api/webhook/laptop_charge_on\n    fi\n\n* * *\n\n## 🚀 Conversion Tip: Make It “Set and Forget”\n\nTo increase reliability (and avoid annoying toggling):\n\n  * Add a **5% buffer** (e.g. 75–80% OFF, 25–30% ON)\n  * Run scripts every 60–120 seconds\n  * Ensure BIOS allows **auto power-on after AC restore**\n\n\n\n* * *\n\n## 💰 Why This Is Worth Doing\n\nA replacement laptop battery can cost **£50–£150+**.\n\nA smart plug? ~£10–£25.\n\n👉 This setup pays for itself **instantly** if it extends your battery life by even a few months.\n\n* * *\n\n## 🔌 Recommended Setup (Quick Start)\n\nIf you just want something that works:\n\n  * TP-Link Tapo smart plug\n  * Home Assistant automation (above)\n  * Simple script (Windows/Linux/macOS)\n\n\n\n👉 This combo is beginner-friendly and highly reliable.\n\n* * *\n\n## 🏁 Final Thoughts (And Why Most People Don’t Do This)\n\nThis is one of those setups that:\n\n  * Takes **15–20 minutes**\n  * Saves you money long-term\n  * Requires zero maintenance after setup\n\n\n\nMost people won’t bother.\n\nBut once you set it up, your laptop battery will thank you for years.\n\n* * *\n\n## 👉 Next Step\n\nIf you’re already using Home Assistant, this is one of the **highest ROI automations** you can add today.\n\nAnd if you’re not? This might be the one that convinces you.",
  "title": "🔋 Stop Killing Your Laptop Battery: Automate Charging with Home Assistant",
  "updatedAt": "2026-04-01T18:00:15.738Z"
}