Metadata-Version: 2.1
Name: pytrutankless
Version: 0.4.3
Summary: A Python client library for the TruTankless API
Author-email: Matt Coleman <mdcoleman001@gmail.com>
License: MIT License        
        Copyright (c) 2022 Matt Coleman        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/colemamd/pytrutankless
Project-URL: Download, https://github.com/CyanBook/pytrutankless/releases/latest
Project-URL: Source Code, 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
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp
Provides-Extra: dev
Requires-Dist: black ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pyyaml ; extra == 'dev'
Requires-Dist: yamllint ; extra == 'dev'

# 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.
