Skip to main content
Version: 1.0

Schedule

This service allows execution of RPC methods at defined instances in time, using a cron library. Basic CRUD interface is exposed for manipulating schedule configurations. There is a limit of 20 schedule instances per device. A revision number is maintained which is incremented on every update of the schedules. It is returned in the result of RPC calls and is also included in the Status object of the Sys component.

Schedule Object Structure

A schedule job is represented in JSON in the following format:

PropertyTypeDescription

id

number

Id assigned to the job when it is created. This is used in subsequent Update / Delete calls

enable

boolean

true to enable the execution of this job, false otherwise. It is true by default.

timespec

string

As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set 8 instead of 08).

calls

array of objects

RPC methods and arguments to be invoked when the job gets executed. It must contain at least one valid object. There is a limit of 5 calls per schedule job

PropertyTypeDescription

method

string

Name of the RPC method. Required

params

object

The parameters used to invoke the RPC call. If the call requires no parameters params will be omitted

Example:

Schedule job which will turn the Switch with id=0 OFF, every day at 17:34:
{
"id": 1,
"enable": true,
"timespec": "0 34 17 * * SUN,MON,TUE,WED,THU,FRI,SAT",
"calls": [{
"method": "Switch.Set",
"params": {
"id": 0,
"on": false
}
}
]
}

Schedule.Create

This method creates a new schedule job.

Request

Parameters (their meaning is defined by the schedule job format in the beginning of this page):

PropertyTypeDescription

enable

boolean

true to enable the execution of this job, false otherwise. It is true by default.

timespec

string

As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set 8 instead of 08).

calls

array of objects

RPC methods and arguments to be invoked when the job gets executed. It must contain at least one valid object. There is a limit of 5 calls per schedule job

PropertyTypeDescription

method

string

Name of the RPC method. Required

params

object

The parameters used to invoke the RPC call. If the call requires no parameters params will be omitted

Response

Attributes in the result:

PropertyTypeDescription

id

number

Id of the created job

rev

number

Current revision number of the schedule instances

Example:

Schedule job which will turn the Switch with id=0 ON, every day at 9:03:
{
"enable":true,
"timespec":"0 3 9 * * SUN,MON,TUE,WED,THU,FRI,SAT",
"calls":[{
"method":"Switch.Set",
"params":{
"id":0,
"on":true
}
}
]
}

Schedule.Update

This method updates an existing schedule job.

Request

Parameters (their meaning is defined by the schedule job format in the beginning of this page):

PropertyTypeDescription

id

number

Id assigned to the job when it is created. This is used in subsequent Update / Delete calls

enable

boolean

true to enable the execution of this job, false otherwise. It is true by default.

timespec

string

As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set 8 instead of 08)

calls

array of objects

RPC methods and arguments to be invoked when the job gets executed. It must contain at least one valid object. There is a limit of 5 calls per schedule job

Response

Attributes in the result:

PropertyTypeDescription

rev

number

Current revision number of the schedule instances

Schedule.List

This method lists all existing schedules for this device.

Request

This method takes no parameters.

Response

Attributes in the result:

PropertyTypeDescription

jobs

array of objects

Each entry is a schedule job object (described above)

rev

number

Current revision number of the schedule instances

Schedule.Delete

This method deletes an existing schedule job.

Request

Parameters:

PropertyTypeDescription

id

number

Id of the job to be deleted Required

Response

Attributes in the result:

PropertyTypeDescription

rev

number

Current revision number of the schedule instances

Schedule.DeleteAll

This method deletes all existing schedule jobs.

Request

This method takes no parameters.

Response

Attributes in the result:

PropertyTypeDescription

rev

number

Current revision number of the schedule instances

Examples

Schedule.Create example

http://192.168.33.1/rpc/Schedule.Create?timespec="0 0 22 * * FRI"&calls=[{"method":"Shelly.GetDeviceInfo"}]

Response

{
"id": 3,
"rev": 5
}

Schedule.Update example

http://192.168.33.1/rpc/Schedule.Update?id=3&enable=false

Response

{
"rev": 11
}

Schedule.List example

http://192.168.33.1/rpc/Schedule.List

Response

{
"jobs": [
{
"id": 1,
"enable": true,
"timespec": "0 0 8 * * SUN,MON,TUE,WED,THU,FRI,SAT",
"calls": [
{
"method": "Switch.Set",
"params": {
"id": 0,
"on": false
}
}
]
},
{
"id": 2,
"enable": true,
"timespec": "0 30 19 * * MON,TUE,WED,THU,FRI",
"calls": [
{
"method": "Switch.Set",
"params": {
"id": 0,
"on": true
}
}
]
}
],
"rev": 4
}

Schedule.Delete example

http://192.168.33.1/rpc/Schedule.Delete?id=3

Response

{
"rev": 11
}

Schedule.DeleteAll example

http://192.168.33.1/rpc/Schedule.DeleteAll

Response

{
"rev": 11
}