Interaction through Python

I've made a project where using it sends the battery details ( 'remaining battery', 'time for the battery to empty' and 'whether is the computer is charging' ) through python as post request to the web. On the other side, we get the values and show them in the app :iphone:

I've uploaded the Python script as well as the Google script to GitHub, you can fork or download it.

In the repository, open the and upload it to the Google scripts.
Then you've to copy the script's ID and change it in the file. The current script ID won't work. It's just for testing. Scroll below to understand the

You could also change the interval or pause between post requests. The current value is set to 700 milliseconds.

The below is the Google script's code. Both the post and get request code is in the same script. Make sure to change the spreadsheet's ID here.

The three values will be stored in a single cell in the spreadsheet as in the form of JSON. We'll get the values, decode the JSON and show it.

The three JSON keys here for the values are ('remainingBattery', 'pluggedIn' and 'timeLeft'). We use dictionary blocks to parse them.

Say me if anything is wrong, I'll correct it.

Thanks! :smiley:


Where does one put the file ?

The code is written in Python 3. So you'll have to install Python 3 and the packages and run it using Python's terminal or open the folder in the code editor. I'll also upload Java equivalent code in a few minutes :slightly_smiling_face:

On the device then....? This part is not clear.

No, Tim, you'll have to install Python on you're computer to run it. I'm too new to Python, so it's difficult for me.

I am very interested @Kumaraswamy :star_struck:

1 Like
Running it through terminal

Post: You will have to copy all files in venv\Lib\site-packages and post them in the folder where the exists. Then you'll have to run python in cmd/terminal once you've installed Python.

Means it will store laptop's battery details in spreadsheet using Python (windows) which you can get using App (Android).


Yes you're right. That's how it works as said in the first post :slightly_smiling_face: