I have created this repo for the scripts that I use to monitor the power consumption at my home 🏡.
It is a personal project, but please reach out if there is anything to improve, or something that you find interesting.
conda create --name tuya python=3.9
conda activate tuya
python3 -m pip install python-crypto
python3 -m pip install pycryptodome # or pycrypto, pyaes, Crypto
python3 -m pip install tinytuya # or pytuya
python3 -m pip install tuyapower # Pull this tuyapower module from PyPi
python3 -m pip install demjson3 # Read json files
python3 -m pip install matplotlib # do some plotting
Follow the instructions for Tuya Device preparation from TuyaPower and read the Notes. They are pertinent for using these scripts after the first time.
As a result, you should now have in the root folder the following files:
devices.json
: most important one - contains the keys.tinytuya.json
: configuration data with the credentials that you used to scan.tuya-raw.json
: General information about the devices, contains the mappings.snapshot.json
: Only created if you answeredY
to Poll local devices? (Y/n). It has the current reading values of the device.
This contains examples scripts for using tuyapower
.
Check the main Example.py from TuyaPower.
I created this script to monitor the power consumption during a wash. This script:
- Gathers the device info and establishes the communication with it.
- Has a loop in time to retrieve the information from the smart plug.
- Saves the reading to a txt file with name the time stamp.
- (Optionally) plots the power consumption.