Member-only story

Build a Laptop Battery Status Logger with the Notion API and Python — Notion Public API Guide

Seb Hulse
9 min readJul 9, 2021

Example of the finished product — the laptop battery status Notion database © Seb Hulse

Hi! So you’ve heard the big news? That’s right — Notion has finally released its long awaited public API into the wild in beta! That means we can build, automate and integrate all kinds of cool stuff to further boost the functionality that notion offers — namely, leveraging the potential of Notion databases.

This post walks through one example of just how easy it can be to automate the logging of data into a notion database and hints at ideas for what we could do with that data later on. We first dive into the code, then discuss processing the output to be a bit more visually appealing within the database and finish with setup/implementation details. Feel free to skip ahead to the Setup if you just want to get up and running!

Contents

  • Code
  • Notion Database Visual Processing
  • Setup

Specifically, for this example, we’ll write a Python3 script to gather current battery status data (percentage, estimated time remaining, plugged-in status and timestamp), and push it to our Notion database using the requests python package. Then, we set up a cronjob to automate running this script every 2 minutes to start building a database that looks something like the above image.

But why? I hear you ask… Good question — for me, the main reason to log laptop battery status is to access it in realtime from anywhere with an internet connection. This is useful because I’m currently charging my laptop with a small solar setup at the back of the garden (I’ll be doing a write-up soon but here’s a taste…), and I want to know whether it’s sufficiently charged yet without having to go outside! Lazy, I know… More generally, you could use the logs to calculate total charge power usage estimations or even build a swanky Machine Learning regression model to predict how much longer it will take to charge your battery from its current state. You could also make cool wavy graphs out of it…

Alternately, forget about the battery status logger and maybe think more towards IoT logging time-series data to a Notion database, for example!

Let’s get into it!

Code

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Seb Hulse
Seb Hulse

Written by Seb Hulse

I write about what I’m learning — usually with a technical focus. Let’s enlighten one another! sebhulse.com

No responses yet

Write a response