mjg59 / python-broadlink

Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs
MIT License
1.35k stars 477 forks source link

Feature: Add API to get historical data for Smart Plug mini from broadlink server (or mention my tool) #746

Open ZuinigeRijder opened 1 year ago

ZuinigeRijder commented 1 year ago

I am using 2 Smart plug SP3S-EU since 2018. The e-control App was limited in functionality/views. One of the strange things is e.g. the fact that you cannot see the month December of the year before the current year. So I was looking around if someone already had a better solution. I found the library python-broadlink, but this was only for local access to your broadlink smart plug devices (get direct power measurements). So I decided to try to sniff the e-Control app, see here.

In short, it appeared way easier to get the historical data of my smart plug mini than expected. You do not even have to login, you only need the server name and MAC address of the smart plug mini. Oops, so simple ;-)

So I started making a simple standalone python script smart_plug_mini.py which appends the history data per hour in a csv file for each device and made some parts configurable. Also the tool writes the Day, Weeks, Months and Years summaries to separate .csv files per device.

Maybe this is interesting for others or for python-broadlink to add to their features.

If this does not fit in the architecture of python-broadlink, maybe you want to add my tool python-broadlink-smart-plug-mini to the README of python-broadlink?

ZuinigeRijder commented 1 year ago

FYI for the ones who would like more information of my tool python-broadlink-smart-plug-mini.

Added tool to read the smart_plug_mini.py generated csv files and write a summary for each device to a separate Google spreadsheet

Note: you need to install the package gspread and configure gspread

Usage:

python csv_to_google_sheet.py

INPUTFILES:

Standard output:

OUTPUT SPREADSHEET:

So the smart_plug_mini.py tool runs on my Raspberry Pi server, but I want to look at the results, without having to login to my server. So another tool has been made, which copies a summary to a google spreadsheet for each device: csv_to_google_sheet.py

The Google spreadsheet contains kWh usage, including nice diagrams, when you import the example Badkamer.SP.xlsx spreadsheet in Google Spreadsheet:

A short video of how it can look on an Android phone, can be found here. Of course you can also view the Google Spreadsheet on your computer or tablet, e.g. Windows or Mac.

Broadlink Smart Plug Mini showing csv results in Google Spreadsheet