Skip to main content

CSV logger for PyTado

Project description

pytadolog is a Python module which extends the python-tado package so that data can be logged from the Tado web API to a local CSV file.

Installation

Note about PyTado

This package requires python-tado to query the TADO web API, however development of the main package appears to have stalled. There are a number of forks available on PyPI with different APIs and varying aliases (python-tadoac, python-tado (PyPI), pytado). This package was developed with python-tado v0.2.9 cloned directly from GitHub, it has been tested to be compatible with commit 00a9ab1.

Therefore, before installing pytadolog you must first install the correct version of pytado. This can be achieved using the package manager pip as below:

pip install git+https://git@github.com/chrism0dwk/PyTado.git@00a9ab12569e84a5537c2a0517c3a6b5cbb9d535

pip can then be used to install pytadolog.

pip install pytadolog

Usage

pytadolog includes a helpful console script and can easily be invoked with:

>>> tadolog

Commandline arguments can also be provided to customise pytadolog. These can be explored using:

>>> tadolog -h

usage: __main__.py [-h] [-o OUTDIR] [--update-period UPDATE_PERIOD]
                   [--last-day LAST_DAY] [-m]

optional arguments:
  -h, --help            show this help message and exit
  -o OUTDIR, --outdir OUTDIR
                        path to output directory
  --update-period UPDATE_PERIOD
                        time in seconds between updates
  --last-day LAST_DAY   last day of week as 3 letter string
  --disable-multiproc   use single process for web query and csv saving
  -d, --debug           log debugging statements to file
  -v, --verbose         log info statements to file

CSV conversion

This package includes a handy script to convert created CSV files to Excel files. Conversion requires openpyxl to be installed. The script can be invoked from the console using:

>>> csv2excel path/to/csv

Again, console arguments can be passed to the script to customise execution:

>>> csv2excel -h

usage: csv2excel [-h] [-o OUTPATH] [--dropna] input

positional arguments:
  input                 path to csv to convert

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPATH, --outpath OUTPATH
                        path to output xlsx
  --dropna              drop NaN values in xlsx

Other methods for launching pytadolog

The package can be invoked using the main() method of the package:

>>> python -m pytadolog
Alternatively the class can be imported into Python and started explicitly:

```python
from pytadolog import TadoLogger


with TadoLogger() as tl:
    tl.start()  # Starts logging to CSV

Using the context manager ensures that scheduled events are cleaned up when the process is terminated. This can be handled explicitly by calling the close() method:

from pytadolog import TadoLogger


tl = TadoLogger()
try:
    tl.start()  # Starts logging to CSV
except KeyboardInterrupt:
    tl.close()  # Cancels scheduled events

Output

pytadolog creates a CSV file containing weather data for the registered home and set temperature, heating power, measured temperature and relative humidity of each zone in the home. This is structured using a pandas MultiIndex. The CSV is updated at the update_period which defaults to 30s as this is the fastest Tado queries connected devices. By default the CSVs will be stored in home/Documents/TadoLogs

The CSV will be structured like this:

Zone

We ather

We ather

We ather

Livin groom

Livin groom

Livin groom

Livin groom

Livin groom

Hall

Hall

Hall

Hall

Hall

Var iable

Ou tside Temp (°C)

Solar Int. (%)

We ather

Temp (°C)

R.H. (%)

Set Temp (°C)

He ating Power (%)

Open W indow

Temp (°C)

R.H. (%)

Set Temp (°C)

He ating Power (%)

Open W indow

2021- 02-20 19: 03:30

13.33

0.0

NI GHT_C LOUDY

23.88

45.0

20.0

0.0

FALSE

18.56

58.4

13.0

0.0

FALSE

2021- 02-20 19: 04:00

13.33

0.0

NI GHT_C LOUDY

23.88

45.0

20.0

0.0

FALSE

18.56

58.4

13.0

0.0

FALSE

2021- 02-20 19: 04:30

13.33

0.0

NI GHT_C LOUDY

23.88

45.0

20.0

0.0

FALSE

18.56

58.4

13.0

0.0

FALSE

pytadolog will also generate a logfile to track progress. This is stored in a logs/ subdirectory in the output directory, i.e. home/Documents/TadoLogs/logs by default.

Tado credentials

pytadolog uses keyring to store the Tado log in credentials securely using the operating system’s default keyring service.

From the keyring README:

These recommended keyring backends are supported:

Other keyring implementations are available through Third-Party Backends.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

[Black](https://black.readthedocs.io/) is used to format all Python files.

A GitHub action is set-up to automatically build and publish tagged releases to the [PyPI](https://pypi.org/project/pytadolog/) repository. All pushes to the master branch are built and published to the [TestPyPI](https://test.pypi.org/project/pytadolog/) repository.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytadolog-1.0.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytadolog-1.0.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file pytadolog-1.0.0.tar.gz.

File metadata

  • Download URL: pytadolog-1.0.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for pytadolog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 83199ec5c9553ade58b11444bc797cea2bce57fead81baecee67f8fa16ed5555
MD5 995248919e4c1c5ffdae68ec1a818099
BLAKE2b-256 1f1703d8cbcc2f2ace5b91ba8af9cecca1549b25efd81770c18e3ecdd1e924ed

See more details on using hashes here.

File details

Details for the file pytadolog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytadolog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for pytadolog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c73f589df2818993087bf971934053839befaa0eafddc23fe4f707dee418bc1f
MD5 8d6db70b8e98202726ebc8a097108ecf
BLAKE2b-256 d12463ed03f9382a35fa0f1da79d151447c3b8fd3c3f6fe83fd912ce0928d42d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page