In addition, the ZDM-client Python lib permits also to define a set of jobs on the client that can be invoked by the ZDM.
The jobs are passed to the ZDMClient as a dictionary, where the key is the name of the job and the value is the corresponding function to execute.
The example below illustrates a simple example of a client exposing one job named set_temp.
Upon the device receiving the Job, it executes the corresponding function and returns a result of a JSON object.
Copy the following script into a new file hello_jobs.py.
Now, you can schedule the job in two different ways: by using the ZDM UI or the ZDM CLI.
Steps needed to execute the job “set_led” on the device by using the ZDM UI:
- Login to the ZDM (https://zdm.zerynth.com/login)
- Click on the workspace where the device is associated.
- On the section “My Devices”, click the checkbox of the device
- Click on the button “Jobs”, and on the popup select the job Name “set_temp” in the Job Name dropdown menu.
- Add to the “Arguments” section any arguments of the function in json format (if any). For this example, you can leave the field empty.
- Click on “Launch Job” button.
Steps needed to execute the job “set_led” on the device by using the ZDM CLI.
Make sure you have configured the ZDM CLI (https://www.zerynth.com/blog/docs/the-tools/zdm/getting-started/).
In order to schedule the job, type the following command (where the DEVICE_ID must be substituted with the actual id of the device):
If the job has been correctly scheduled to the zdm client py, the following message will appear in the console:
That’s all! Edit the script file and build your own ZDM powered IOT project!