Metadata-Version: 2.1
Name: pytrutankless
Version: 0.4.2
Summary: A Python client library for the TruTankless API
Home-page: https://github.com/colemamd/pytrutankless
Download-URL: https://github.com/CyanBook/pytrutankless/releases/latest
Author: @colemamd
License: MIT
Project-URL: Source, https://github.com/colemamd/pytrutankless
Project-URL: Bug Reports, https://github.com/colemamd/pytrutankless/issues
Project-URL: Release Notes, https://github.com/colemamd/pytrutankless/releases/)
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requirements.txt

# pytrutankless

Python interface for TRUTANKLESS branded water heaters

## Installation

```
pip install pytrutankless
```

## Usage

In order to obtain an auth token, a TruTanklessApi object must be instantiated and `api.authenticate` called.

```python
from pytrutankles.api import TruTanklessApiInterface(user, passwd, token[Optional])

email = "your@email.here"
password = "yoursecrethere"

api = await TruTanklessApiInterface(user=email, passwd=password)
auth = api.authenticate()
```

A Token object with the following parameters is returned;

```json
{
  "access_token": "str",
  "token_type": "str",
  "expires_in": "int",
  "expires_at": "datetime",
  "refresh_token": "str",
  "user_id": "str"
}
```

If a `Token` object is provided, it will be used for authentification unless expired. If the given `Token` is expired, a new one is retrieved from the API.

### Methods

### `authenticate()`

```
api.authenticate()
retun Token
```

Logs into service and retrieves `access_token`.

### `get_devices()`

```
api.get_devices()
```

Updates dictionaries of locations and devices.
Returns a dict of location(s) that are stored in `api._locations` and a dict of device(s) stored in `api.devices`.

### `refresh_device(device_id)`

```
api.refresh_device(device_id)
```

Given `device_id`, updates usage data for that device.
