Archive Tuya and Smart Life telemetry locally in SQLite, JSONL, or CSV.
Project description
Tuya Telemetry Archive
Keep more than seven days of Tuya temperature and humidity history locally.
Tuya Telemetry Archive copies recent Tuya and Smart Life sensor logs into a local archive. Repeated collections are deduplicated. If Tuya changes a previously reported reading, the local record is updated.
The collector currently recognizes devices in category wsdcg with either
temp_current / humidity_value or va_temperature / va_humidity data points. It
accepts Tuya's integer and ASCII integer-string encodings for those values. It requires
Python 3.11 or newer.
Why this exists
Tuya's free Device Log service retains seven days of history. Run the collector regularly to copy readings before they expire from Tuya's service.
Install
Install from PyPI in a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install tuya-telemetry-archive
tuya-archive --help
Set up and collect
Follow the Tuya Cloud setup guide to create a Smart Home cloud project, link a Tuya Smart or Smart Life account, authorize log access, and choose the correct regional endpoint.
Then run:
tuya-archive setup
tuya-archive doctor
tuya-archive collect
tuya-archive status
A successful collection looks like this:
success: 1/1 devices, 48 fetched, 48 inserted, 0 corrected.
Run tuya-archive collect at least once every seven days. Daily collection leaves
enough overlap to tolerate a missed run.
Archive storage
SQLite is the default archive backend. JSONL and CSV are available when a text-readable archive is more useful.
Set the backend during setup or with TUYA_STORAGE_BACKEND in the protected environment
file:
TUYA_STORAGE_BACKEND=sqlite
Choose sqlite, jsonl, or csv. SQLite remains the default.
| Backend | Use it for | Trade-off |
|---|---|---|
| SQLite | Normal long-running archives | Requires SQLite-aware tools for direct inspection |
| JSONL | Small archives that should remain text-readable | Rewrites the file when changes are committed |
| CSV | Portable archives for spreadsheets and data tools | Uses several related files and rewrites changed yearly partitions |
The CSV backend is a directory named archive-csv. Device and collection-run records
have their own CSV files. Observations are partitioned by UTC calendar year as
observations-YYYY.csv, so corrections only rewrite the affected yearly partition.
The files work together as one archive and should be backed up or moved as a directory.
Hourly CSV reports
Run this after collecting data:
tuya-archive export
By default, the command writes one hourly CSV per UTC calendar year in the private data directory:
csv/hourly-2026.csv
csv/hourly-2027.csv
Choose another directory for the annual files:
tuya-archive export --output-dir ./annual-csv
Or write one combined file:
tuya-archive export --output ./tuya-hourly.csv
Each row includes the device label and pseudonym, data-point code, unit, sample count, and hourly minimum, mean, maximum, first, and last values. UTC and local timestamps are both included. The local timestamp includes its UTC offset so repeated daylight-saving hours remain distinct.
Optional macOS scheduler
Scheduling is optional. You can run tuya-archive collect from cron, another scheduler,
or your own automation.
On macOS, the project can install a daily user LaunchAgent:
tuya-archive schedule install
tuya-archive schedule status
Remove it with:
tuya-archive schedule uninstall
The default interval is 86,400 seconds. To choose another interval:
tuya-archive schedule install --interval-seconds 43200
The LaunchAgent uses the Python interpreter that installed it. Reinstall the schedule after moving or rebuilding that virtual environment. See the macOS scheduling guide for details.
Local files and privacy
On macOS, files are stored under:
~/Library/Application Support/tuya-telemetry-archive/
├── config/config.env
└── data/
├── identity.key
├── archive.sqlite3 (or archive.jsonl or archive-csv/)
└── csv/
Other platforms follow XDG conventions. Override the defaults with
TUYA_ARCHIVE_CONFIG_DIR and TUYA_ARCHIVE_DATA_DIR.
Raw Tuya device IDs are not written to the archive. They are replaced with stable HMAC
pseudonyms using the local identity.key. The archive still contains device labels,
timestamps, and sensor readings, so it should be treated as private household data.
Back up identity.key with the archive. If the key is lost, future readings from the
same device will receive a different pseudonym. See SECURITY.md for
reporting and handling guidance.
Archives from collectors that used a different SQLite schema or device-identity scheme cannot be copied directly into this archive. Keep the existing collector running while you validate a separate archive. See the legacy SQLite import design for the planned identity mapping, validation, backup, and cutover process.
Tested devices and current limitations
Collection has been tested with the
SENCKIT 4-Pack WiFi Temperature Humidity Sensor
(Amazon ASIN B0B5DQZTG9). Tuya temperature/humidity sensors in category wsdcg have
been observed with both temp_current / humidity_value and va_temperature /
va_humidity; the test suite covers both families with synthetic fixtures.
Tuya also publishes a general temperature and humidity sensor solution. That page describes the Tuya platform category, not this exact SENCKIT retail listing.
Other devices that expose one of the supported data-point pairs may work, but they have not been verified against this project yet. Tuya Cloud setup, API authorization, endpoint behavior, and service availability can also change independently of this repository.
Hourly CSV reports are the only built-in reporting workflow. Arbitrary queries, charts, and an MCP server are not implemented yet. The built-in scheduler currently supports macOS only.
Development
Use synthetic fixtures only. Never add real credentials, device IDs, identity keys, household labels, telemetry, archives, or exports.
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[dev]'
.venv/bin/python -m pytest -v
.venv/bin/ruff check .
.venv/bin/python -m build
See CONTRIBUTING.md for the safety requirements and development workflow.
Maintenance and contributions
This project will be actively maintained. Contributors are welcome to add more device integrations, reporting workflows, scheduling platforms, and other improvements.
See the Tuya Cloud setup guide, security policy, contribution guide, release guide, and MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tuya_telemetry_archive-0.1.1.tar.gz.
File metadata
- Download URL: tuya_telemetry_archive-0.1.1.tar.gz
- Upload date:
- Size: 64.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeaf5641493301a23e1778e95c73d3e565cdc80bc3fec0e4fb1a44d493d7beba
|
|
| MD5 |
0ace6f2b5d693243870194b405d86131
|
|
| BLAKE2b-256 |
08a966b97dc09af183ec9a1f7ab7464250819460621fdb7ae5588c7fd7e2a9db
|
Provenance
The following attestation bundles were made for tuya_telemetry_archive-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on ankushagrawal94/tuya-telemetry-archive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tuya_telemetry_archive-0.1.1.tar.gz -
Subject digest:
aeaf5641493301a23e1778e95c73d3e565cdc80bc3fec0e4fb1a44d493d7beba - Sigstore transparency entry: 2216225951
- Sigstore integration time:
-
Permalink:
ankushagrawal94/tuya-telemetry-archive@97a9433238d9beff68d839fafb7a9595a616e2f6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ankushagrawal94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97a9433238d9beff68d839fafb7a9595a616e2f6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tuya_telemetry_archive-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tuya_telemetry_archive-0.1.1-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36b558627e4c4a4d134be66dcbadb6de9d63342acd65bd699330797e26b46fac
|
|
| MD5 |
042714b304e9d839cf44afc6bca0aebf
|
|
| BLAKE2b-256 |
063283c6c70ac50694152944f6a907d381cd7fafd6606d8d503d4ee916824906
|
Provenance
The following attestation bundles were made for tuya_telemetry_archive-0.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on ankushagrawal94/tuya-telemetry-archive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tuya_telemetry_archive-0.1.1-py3-none-any.whl -
Subject digest:
36b558627e4c4a4d134be66dcbadb6de9d63342acd65bd699330797e26b46fac - Sigstore transparency entry: 2216225975
- Sigstore integration time:
-
Permalink:
ankushagrawal94/tuya-telemetry-archive@97a9433238d9beff68d839fafb7a9595a616e2f6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ankushagrawal94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@97a9433238d9beff68d839fafb7a9595a616e2f6 -
Trigger Event:
release
-
Statement type: