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.

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
  • timespec: string, as defined by cron
  • calls: array of JSON objects, RPC methods and arguments to be invoked when the job gets executed. 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:

  • enable: boolean, true to be enabled, false otherwise. It is optional (true by default). Optional
  • timespec: string, should be a valid timespec, see cron. Required
  • calls: array of JSON objects, should contain at least one valid object as defined by the schedule job format in the beggining of this page. Required
Create a shcedule job that gets the informaion 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:

  • id: number, id of the job to be updated. Required
  • enable: boolean, true to be enabled, false otherwise. Optional
  • timespec: string, should be a valid timespec, see cron. Optional
  • calls: array of JSON objects, should contain at least one valid object as defined by the schedule job format. Optional
http://192.168.33.1/rpc/Schedule.Update?id=3&enable=false

Response#

Attributes in the result:

  • id: number, id of the updated job
The schedule job with id=3 is updated.
{
"id": 3
}

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#

Attributes in the result:

  • id: number, id of the deleted job
Schedule job with id=3 is deleted.
{
"id": 3
}

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