Skip to main content

Schedule

This service allows execution of RPC methods at defined instances in time, using Mongoose's cron library. Basic CRUD interface is exposed for manipulating schedule configurations. There is a limit of 20 hook instances per device.

Schedule Object Structure#

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

  • 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 JSON 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
    • method: string, name of the RPC method. Required
    • params: any valid JSON value but normally an 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
}
}
]
}

Here are listed all methods supported by Schedule:

Schedule.List#

This method lists all existing schedules for this device.

Request#

This method takes no parameters.

http://192.168.33.1/rpc/Schedule.List

Response#

Attributes in the result:

  • jobs: array of JSON objects, each entry is a schedule job object (described above)
A device with two existing schedule jobs. The first turns the switch with id=0 off at 8:00 every day. The second turns the same switch on at 19:30 every week day.
{
"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
}
}
]
}
]
}

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):

  • enable: Optional
  • timespec: Required
  • calls: Required
Create a schedule job that gets the information about the device every Friday at 22:00.
curl -X POST -d '{"id":1, "src":"user_1", "method":"Schedule.Create",
"params":{"timespec":"0 0 22 * * FRI", "calls":[{"method": "Shelly.GetDeviceInfo"}]}}'\
http://${SHELLY}/rpc

Response#

Attributes in the result:

  • id: number, id of the created job
The newly created schedule job has id=3.
{
"id": 1,
"src": "shellypro4pm-f008d1d8b8b8",
"dst": "user_1",
"result": {
"id": 3
}
}

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):

  • id: Required
  • enable: Optional
  • timespec: Optional
  • calls: Optional
http://192.168.33.1/rpc/Schedule.Update?id=3&enable=false

Response#

This method returns null on success.

The schedule job with id=3 is updated.
null

Schedule.Delete#

This method deletes an existing schedule job.

Request#

Parameters:

  • id: number, id of the job to be deleted. Required
http://192.168.33.1/rpc/Schedule.Delete?id=3

Response#

This method returns null on success.

Schedule job with id=3 is deleted.
null

Schedule.DeleteAll#

This method deletes all existing schedule jobs.

Request#

This method takes no parameters.

http://192.168.33.1/rpc/Schedule.DeleteAll

Response#

The result from this method is null.

null