Using a job allows you to control a group of loads.
The loads can be configured using the attribute target_states
and/or button_ctrl
.
Its also possible to change system-flags flag_values
or even to run user-scripts scripts
.
You can create a job with multiple-sections. That means, that it can contain target_states
and button_ctrl
.
See below in the examples how to run the sections separately or even all sections (whole job).
Jobs are triggered in different/multiple ways:
-
internally from a timer
-
in combination with a smartbutton
-
and probably the most important, over the REST-API
Do not forget to include the authentication token in all your requests!
🐮 My
job
is to eat a lot of fresh grass and mytarget_state
is to getting full!
Lets configure a job that turn on some loads (e.g. lights) of your installation.
The attribute target_states
maps with the Loads-target_state attributes.
Request header:
POST /api/jobs HTTP/1.1
Content-Type: application/json
host: example.com
Request body:
{
"target_states": [
{
"load": 1,
"bri": 10000
},
{
"load": 2,
"bri": 10000
}
]
}
Response header:
HTTP/1.1 200 OK
Content-Type: application/json
Response body:
{
"data": {
"id": 20,
"target_states": [
{
"load": 1,
"bri": 10000
},
{
"load": 2,
"bri": 10000
}
]
},
"status": "success"
}
The attribute button_ctrl
maps with the Loads-ctrl attributes.
Request header:
POST /api/jobs HTTP/1.1
Content-Type: application/json
host: example.com
Request body:
{
"button_ctrl": {
"event": "click",
"button": "on",
"loads": [1, 2]
}
}
Response header:
HTTP/1.1 200 OK
Content-Type: application/json
Response body:
{
"data": {
"id": 30,
"button_ctrl": {
"ctrl_input_channel": 16,
"event": "click",
"button": "on",
"loads": [1, 2]
}
},
"status": "success"
}
Now lets run the jobs.
Be in mind that the response of the job, doesn't means that the loads (e.g. lights) reached the final target-states. It's just a job that has been executed.
This will run the target_states
-section of your job.
Request header:
GET /api/jobs/20/run HTTP/1.1
host: example.com
Response header:
HTTP/1.1 200 OK
Content-Type: application/json
Response body:
{
"data": {
"id": 20,
"target_states": [
{
"load": 1,
"bri": 10000
},
{
"load": 2,
"bri": 10000
}
]
},
"status": "success"
}
This will run the button_ctrl
-section of your job.
Request header:
GET /api/jobs/30/run HTTP/1.1
host: example.com
Response header:
HTTP/1.1 200 OK
Content-Type: application/json
Response body:
{
"data": {
"id": 30,
"button_ctrl": {
"ctrl_input_channel": 16,
"event": "click",
"button": "on",
"loads": [1, 2]
}
},
"status": "success"
}
This will trigger the whole job (all sections).