ZDM Client Python Library
Project description
Zerynth ZDM Client Python Library
A python library that emulates a device for the ZDM. It permits connect to the ZDM, send data and receives jobs.
Installation
The latest stable version is available on PyPI. 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 Cloud or the ZDM Cli). 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 tag ("bathroom", "bedroom", "living room") with a random temperature.
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 = ["bathroom", "bedroom", "living room"]
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for zdm_client_py-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | feb381c896b487a3e4c5bb768484e590809b100584b2339a059fb00689a2391e |
|
MD5 | f74ab5f0b0e0e40430394e12ffd4020b |
|
BLAKE2b-256 | 7456605feef3f19755be0f77720696ea0614b49e6ef95ad682b224dbd6c72143 |