Zerynth Device Manager Client¶
Zerynth Device Manager can be used for orchestrating both MCU (micro-controller) and CPU (micro-processor) based devices. If you want to connect a MCU device like a RapsberryPI, a SBC (Single Board Computer) a PC and any Python application general, the ZDM Client Python Library is what you need.
The Zerynth ZDM Client is a Python implementation of a client of the ZDM. It can be used to emulate a Zerynth device and connect it to the ZDM.
The ZDMClient class¶
-
class
ZDMClient
(cred=None, cfg=None, jobs_dict={}, condition_tags=[], on_timestamp=None, on_open_conditions=None, verbose=False)¶ Creates a ZDM client instance.
cred
is the object that contains the credentials of the device. If None the configurations are read from zdevice.json file.cfg
is the object that contains the mqtt configurations. If None set the default configurations.jobs_dict
is the dictionary that defines the device’s available jobs (default None).condition_tags
is the list of condition tags that the device can open and close (default []).verbose
boolean flag for verbose output (default False).on_timestamp
callback called when the ZDM responds to the timestamp request. on_timestamp(client, timestamp)on_open_conditions
callback called when the ZDM responds to the open conditions request. on_open_conditions(client, conditions)
-
id
(pw)¶ Return the device id.
-
connect
()¶ Connect your device to the ZDM.
-
publish
(payload, tag)¶ Publish a message to the ZDM.
payload
is a dictionary containing the payload.tag
is the tag associated to the published payload.
-
request_timestamp
()¶ Request the timestamp to the ZDM. When the timestamp is received, the callback
on_timestamp
is called.
-
request_open_conditions
()¶ Request all the open conditions of the device not yet closed. When the open conditions are received, the callback
on_open_conditions
is called.
-
new_condition
(condition_tag)¶ Create and return a new condition.
condition_tag
the tag as string of the new condition.
-
class
Condition
(client, tag)¶ Creates a Condition on a tag.
client
is the object ZDMClient object used to open and close the condition.tag
is the tag associated with the condition.
-
open
(payload, finish)¶
Open a condition.
payload
is a dictionary containing custom data to associated with the open operation.start
is a time (RFC3339) used to set the opening time. If None is automatically set with the current time.
-
close
(payload, finish)¶
Close a condition.
payload
is a dictionary containing custom data to associated with the close operation.finish
is a time (RFC3339) used to set the closing time. If None is automatically set with the current time.
-
reset
()¶ Reset the condition by generating a new id.
-
is_open
()¶ Return True if the condition is open. False otherwise.