The TP Link Kasa smart switches log energy consumption data over time, however the app is very limited and won't let you get out data, graph it or see historical usage. This script extracts and saves to a CSV file.
The python-kasa
library is used to communicate with the Kasa switch.
- Python must be installed
- You must be on the same wifi network as the Kasa switch
- The Kasa switch must be set up
- Run
pip install python-kasa python-dateutil
to install dependencies - Download the
TpLinkKasa-GetEnergyConsumptionAsCsv.py
to a folder on your computer - Edit the file and set the date range you want to get energy consumption data for
- Run
python TpLinkKasa-GetEnergyConsumptionAsCsv.py
in the folder with the python script downloaded - A file called
output.csv
will be created. You can import this file into Excel or Google Sheets