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
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
script.gs and upload it to the Google scripts.
Then you’ve to copy the script’s ID and change it in the
main.py 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 blocks are the same for Kodular.
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.