Metadata-Version: 2.1
Name: zdm-client-py
Version: 1.0.0
Summary: ZDM Client Python Library
Home-page: https://github.com/zerynth/zdm-client-py.git
Author: Zerynth Team
Author-email: d.neri@zerynth.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3
Description-Content-Type: text/markdown
Requires-Dist: paho-mqtt
Requires-Dist: click

# Zerynth ZDM Client Python Library

A python library that emulates a device for the  ZDM (Zerynth Device Maanager).
The library permits: to connect to the ZDM, to send data and to receive jobs.

## Installation

The latest stable version [is available on PyPI](https://pypi.org/project/zdm-client-py/). Either add `zdm-client-py` to your `requirements.txt` file or install with pip:
```
pip install zdm-client-py
```

## Usage
Login to the ZDM platform (by using the [ZDM Web](https://zdm.zerynth.com) or the [ZDM CLI](https://www.zerynth.com/blog/docs/zdm/getting-started/the-zdm-command-line-interface/)).
Add a new device and generate a new password for the device.

Copy the obtained **Device Id** and **Password** in the example below.

In the example, the Client connects to the ZDM with the username e password.
Then it sends an infinite stream of messages onto three different tags ("bathroom", "bedroom", "living room") with a random temperature.

```python
import random
import time
import zdm

device_id = '!!! PUT YOU DEVICE_ID HERE !!!'
password = '!!! PUT YOU PASSWORD HER !!!'

device = zdm.ZDMClient(device_id=device_id)
device.set_password(password)
device.connect()

time.sleep(5)

tags = ["tag1", "tag2", "tag3"]

while True:
    temp = random.randint(10, 30)  # random temperature
    tag = random.choice(tags)      # random choice of the tag
    payload = {"temp": temp}
    device.publish_data(tag, payload)
    time.sleep(1)
```

You can find other examples in the `data/examples` folder.


=======
History
=======

1.0.0 (2020-07-24)
-----------------------
Official release of ZDM (Zerynth r2.6.0)
* Added conditions and removed events.
* Added requests_timestamp() method
* Renamed publish_data() into publish().
* Fix job args after expected status received.
* Renamed jobs parameters into jobs_dict of the ZDMClient.
* Parameters of publish(payload, tag) methods inverted. First parameter is payload and second is tag.

0.2.0 (2020-06-16)
----------------------------
* Added Conditions and removed the events.
* removed wait_for_publish()

0.1.0 (2020-05-14)
----------------------------
* added wait_for_publish() to the published msg in order to guarantee that the message is sent to the ZDM
* added the send_event() method for sending events to the ZDM.

0.0.11 (2020-05-04)
----------------------------
* fix json load arguments of job

0.0.10 (2020-04-27)
----------------------------
* Changed default endpoint to "mqtt.zdm.zerynth.com"
* Fix args of Jobs as ./json


0.0.7 (2020-04-09)
----------------------------
* modified examples
* copy examples in /usr/share/zdm/examples folder

0.0.6 (2020-03-30)
----------------------------

* Fix error in _handle_dn_msg decode msg to str with python3.5


0.0.5 (2020-03-29)
----------------------------

* Fix error manifest with empty jobs.


0.0.4 (2020-03-29)
----------------------------
New functionality:

* Verbose parameter to ZdmClient class


0.0.3 (2020-03-27)
----------------------------
Release with support Python >3

* Create ZDmClient
* Publish messages to ZDM
* Received Jobs from ZDM


