wappstoiot 0.8.0
Simple Wappsto Python user-interface to Wappsto IoT
License: Apache-2.0
Requires Python: >=3.7.0

Wappsto IoT
===============================================================================
[![versions](https://img.shields.io/pypi/pyversions/wappstoiot.svg)](https://github.com/wappsto/python-wappsto-iot)
[![Test Status](https://github.com/Wappsto/python-wappsto-iot/actions/workflows/test.yml/badge.svg)](https://github.com/Wappsto/python-wappsto-iot/actions/workflows/test.yml)
[![Lint Status](https://github.com/Wappsto/python-wappsto-iot/actions/workflows/lint.yml/badge.svg)](https://github.com/Wappsto/python-wappsto-iot/actions/workflows/lint.yml)
[![Coverage](https://codecov.io/github/wappsto/python-wappsto-iot/branch/main/graph/badge.svg)](https://codecov.io/github/wappsto/python-wappsto-iot)
[![pypi](https://img.shields.io/pypi/v/wappstoiot.svg)](https://pypi.python.org/pypi/wappstoiot)
[![license](https://img.shields.io/github/license/wappsto/python-wappsto-iot.svg)](https://github.com/wappsto/python-wappsto-iot/blob/main/LICENSE)
[![SeluxitA/S](https://img.shields.io/badge/Seluxit_A/S-1f324d.svg?logo=data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAABVCAYAAAA49ahaAAAACXBIWXMAABOvAAATrwFj5o7DAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAACjNJREFUeJztnX+wVVUVxz9cHr8fj5EfFipYU/AktBkyB6icgn4gMk5/NE0/SU1Ek6k0tAisrIQkkHKG6AeYFSmafzU2088BE0RiypHIDJlS0IGJhygC7/Hg8b79se7lnXveOveee88597776Duz583b5+y91/nec87ae6211xkgiT6AEcBlwCVAKzAZmAiMyh9rBlqA14HjwAngKLAf2AM8D/wL2J0/VlcMqBOpg4F3AbOBWcB0YFAK/Z4CdgKb8+WpfF1NUWtSLwc+A3wCGFeD8V4DfgVsBJ4EanKxtSB1OLAAWIQ91vXCHuAHwAagI8uBsiS1GbgB+AowPqtBqkAbsA74PnYnp44sSM0BNwN3A+dV2PYopnT2AHuBQ5jiO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MDNc5xAFA+DEYn7ccnq2+0v5b4hEaFP3u/xHKNuJy+DZwK0rvALc4ohVB1rAp6tAUSYmEb37OxZER3PnW4gR7fhmRqr9iIqcpKwRlPtVibTJaVqmV2H2ComS3kMbMKeQwtxqS44j8XpZGGS9OhPRdJ46ZI8NViTql/xoFzYz4NJZovrDKjVN/nJn7aYyLnDvwmVaJdQqave0rFVYN+EhfgE9/jWptZjVyZSUONGzJmvRtS7QsqdHiCFmbteVwIHnn5ZodHyJzk5tD7WFDkjrS9mzM8SFRRBBoPPTPSRNhv5jTf00SaxVRQPr1KMHL+dcg0dF1/laoJPl2cOHt/FASOQ2edYn0NFw31RUm7kplbblBr7Pc8hB9N0Tbf5p61dgckJpAamwOSE0gNTYHpCaQGpsDUhNIjVfvgD9WFsGCdX/VsgAAAABJRU5ErkJggg==)](https://wappsto.com)

The wappstoiot module provide a simple python interface to [wappsto.com](https://wappsto.com/) for easy prototyping.


## Prerequisites

A [wappsto.com](https://wappsto.com/) Account, that the unit can connect to.

The wappsto module requires a set of certificates for authentication. The certificates can be downloaded from [wappsto.com](https://wappsto.com/), or with the build-in CLI tool: `python3 -m wappstoiot`.
The certificates provides the unit with the secure connection to wappsto.com.

To read more about how the Wappsto IoT inner workings, go [here](https://documentation.wappsto.com).

## The Basics

To understand how to use Wappsto IoT, there is some terms that need to be known.
* Control
    - Change request value.
* Report
    - The current value.
* Refresh
    - Value Update request.
* Delete
    - inform that a delete have happened.
* network -> device -> value
    - ...

## Getting Started


## Installation using pip

The wappsto module can be installed using PIP (Python Package Index) as follows:

```bash
$ pip install -U wappstoiot
```


Working examples of usage can be found in the [example folder](./example).

The needed certificates can be downloaded with [IoT Certificate Manager](https://wappsto.com/store/application/iot_certificate_manager).
Where path is the path to the config-folder, given in the following code example.


### Echo example

The following explains the example code found in [echo.py](./example/echo.py).


```python
wappstoiot.config(
    config_Folder="echo"
)
```

```python
network = wappstoiot.createNetwork(
    name="echo",
)
```

```python
device = network.createDevice(
    name="EchoDevice"
)
```

```python
value = device.createValue(
    name="Moeller",
    permission=wappstoiot.PermissionType.READWRITE,
    value_template=wappstoiot.ValueTemplate.STRING
)
```

```python
value.onControl(
    callback=lambda obj, new_value: obj.report(new_value)
)
```

```python
value.onRefresh(
    callback=lambda obj: obj.report(f"{obj.data} Refreshed!")
)
```

```python
try:
    while True:
        time.sleep(0.5)
except KeyboardInterrupt:
    pass
finally:
    wappstoiot.close()
```

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details.




v0.8.0 (Nov 17 2023)
===============================================================================

## Added
 * Period and Delta functionality.
 * Can now send log data. Log data are not shown as a new value update.
 * Option in `config` to set rpc_timeout.
 * Added `max_reconnect_retry_count` in config, when reach it will raise a ConnectionError.
 * Devices `createValue` now take `period` & `delta` settings.

## Fixed
 * Fixed an issue that resulted in refresh did not work.
 * Fix a issue there the Value type was not properly changed on value type change.

## Changed
 * `wait_for_offline_storage` now had a retry option, where it make a socket reconnect on timeout util the retry count reached.


v0.7.1 (Sep 26 2023)
===============================================================================
## Added
 * Added functionality to check offline storage stored size. (`wappsto.iot.offline_storage_size`)
 * Added functionality to wait for offline storage to upload all. (`wappsto.iot.wait_for_offline_storage`)
 * OfflineStorage ABC class now contain a `storage_size` method.
 * Functions `connect`, `disconnect` & `reconnect` is now implemented.

## Fixed
 * Issue where it could not resend offline data after migration to Pydantic 2.


v0.7.0 (Sep 22 2023)
===============================================================================

## Changed
 * Breaking Change! - If the server do not reply on any messages, it will now cast a `TimeoutError` exception.


v0.6.10 (Sep 15 2023)
===============================================================================
## Added
 * `remove_illegal_characters` function to help remove the illegal characters.

## Changed
 * Extended the legal characters list for name.
 * Migrated to Pydantic 2.

v0.6.9 (Aug 18 2023)
===============================================================================
## Removed
 * The CLI interface to create certificates. Use `https://wappsto.com/store/application/iot_certificate_manager` instead.
 * Remove the `Tracer` (Package flow tracing).

## Changed
 * Pydantic version to be between 1.0.0 & 2.0.0 for better compatibility.


v0.6.8 (Aug 04 2023)
===============================================================================
## Added
 * `report` now take a `LogValue` or a list of `LogValue`s.

## Changed
 * It will now bulk report data, if a list af `LogValue`s is given.
 * Bulk report data will now be sorted.

## Fixed
 * Handle a rare error case from the server.


v0.6.7 (Jul 07 2023)
===============================================================================
## Added
 * Scandinavian special letters to the legal list

## Changed
 * Updated the `wappstoiot.ValueTemplate` to version v0.0.5
 * Set Pydantic version to be `v1.10.11` until migration to `v2` is done.

v0.6.6 (Jun 22 2023)
===============================================================================
## Added
 * Code Stub.

## Changed
 * Now inform which characters are illegal in the given name.

## Fixed
 * The `getReportTimestamp` & `getControlTimestamp` now ensures the return is `None` or of type datetime.

v0.6.5 (Feb 28 2023)
===============================================================================
## Fixed
 * Report & Control now generate a timestamp in UTC time.

v0.6.4 (Feb 27 2023)
===============================================================================

## Added
 * onControlCancel
 * onReportCancel

## Fixed
 * Check on the argument count on callbacks on adding them.
 * Now the on-function returns the callback it was given.
 * Should now covert the timestamp correctly.
 * Fix an issue where it could not close the socket.

## Changed
 * Updated the `wappstoiot.ValueTemplate` to version 0.0.3

v0.6.3 (May 5 2022)
===============================================================================

## Fixed
 * Fixed a issue with the control method, there it broke if it got out of sink with the report.
 * `getReportData` now returns the Report data instead of control.
 * Fixed a issue that prevented in report/control values with old timestamps.

v0.6.2 (Mar 10 2022)
===============================================================================

## Fixed
 * Now `pathlib.Path` can also be used for the config config_folder input.
 * Fixed a issue where it always where asking for the value.
 * Fixed a issue where it did not create the need states, if the device existed. 
 * Fixed a issue where it will fail om the smallest schema change.

## Changed

 * Naming policy are now enforced. Have to be set, and may only contain:
    ALPHA/DIGIT/" . "/" ~ "/"(space)"/" - "/" _ "
 * Breaking Change! - Changes the 'ValueTypes' to 'ValueTemplates', which are a more meaningful name. The createValue input 'value_type', have also change to 'value_template'
 * Enforce the parameter-name for multiple inputs in the create-methods. 


v0.6.1 (Feb 21 2022)
===============================================================================

## Changed

 * Updated the ValueTypes to use the Default template values v0.0.1.


v0.6.0 (Jan 31 2022)
===============================================================================

## Added
 * Ping-pong option in the config-method.
 * fast_send option in the config-method.

## Fixed

 * Fix some issues that only happen on first time run.
 * Fix a issue where if config was not called, the config-folder was not set to current folder.
 * Fix a issue where offline storage, did not allow the program to stop, if there was still data to be send.
 * Fix a issue with the way the certificates was created the right way, and is also claimed.


v0.5.5 (Dec 21 2021)
===============================================================================

## Fixed

 * Fix a issue that prevented wappstoiot in creating a new value.


v0.5.4 (Dec 21 2021)
===============================================================================

## Added

 * New Default Value-Types. (CO2, Humidity & Pressure Pascal).


## Changed

 * The createValue, are now split into 5. `createValue` that uses the predefined ValueType given, and 1 for each base value types, for when a custom is needed. 
 * `permission` is now required.
 * `onControl`, `onReport`, `getControlData` & `getReportData` provides a float if the value was set to be a number.


## Fixed

 * offline_Storage warnings now fixed.
 * A issue where the `type`-value inside value where not set.
 * A issue where the step was set to a int, not a float.
 * `wappstoiot.onStatus` should not be working correctly.


v0.5.3 (Dec 9, 2021)
===============================================================================

## Added

 * Groove Examples for Raspberry Pi.
 * Checks of naming, so it reuses the object based on the name. (Naming are mandatory now.)
 * `wappstoiot.config` have been added to handle all the configs.
 * `wappstoiot.createNetwork` have been added to streamline the flow.
 * `value.getReportTimestamp()`, `value.getControlTimestamp()` have been added to make the timestamp for the last given value accessible.
 * `value.getControlData()` have been added to make the control data accessible.

## Removed

 * Remove the Module ids. (The Names are now the unique identifier.)
 * Remove `Rich` dependency.

## Changed

 * The names & naming convention to fix the other Wappsto Libraries.
 * All the connections & general configs are moved from the Network, to wappstoiot.
 * `value.data` have been changed to `value.getReportData()`

## Fixed

 * Fix the naming to fit the naming convention.


v0.5.2 (Nov 25, 2021)
===============================================================================

## Added

 * HTTP Proxy support. (Pulls #259, #353)

## Fixed

 * Make WappstoIoT python3.6 compatible.
 * Fix a Path issue that make the code not able to find the certificates in ipython.


v0.5.1 (Nov 23, 2021)
===============================================================================

## Added

 * Pip release.

## Fixed

 * Fix the name to fit the naming convention.


v0.5.0 (September 20, 2021)
===============================================================================

## Added

 * First Release.