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:
Property | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id assigned to the job when it is created. This is used in subsequent Update / Delete calls | |||||||||
| boolean |
| |||||||||
| string | As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set | |||||||||
| 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
|
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):
Property | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| boolean |
| |||||||||
| string | As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set | |||||||||
| 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:
Property | Type | Description |
---|---|---|
| number | Id of the created job |
| 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):
Property | Type | Description |
---|---|---|
| number | Id assigned to the job when it is created. This is used in subsequent Update / Delete calls |
| boolean |
|
| string | As defined by cron. Note that leading 0s are not supported (e.g.: for 8 AM you should set |
| 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:
Property | Type | Description |
---|---|---|
| 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:
Property | Type | Description |
---|---|---|
| array of objects | Each entry is a schedule job object (described above) |
| number | Current revision number of the schedule instances |
Schedule.Delete
This method deletes an existing schedule job.
Request
Parameters:
Property | Type | Description |
---|---|---|
| number | Id of the job to be deleted Required |
Response
Attributes in the result:
Property | Type | Description |
---|---|---|
| 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:
Property | Type | Description |
---|---|---|
| number | Current revision number of the schedule instances |
Examples
Schedule.Create example
- Schedule.Create HTTP GET Request
- Schedule.Create Curl Request
- Schedule.Create Mos Request
http://192.168.33.1/rpc/Schedule.Create?timespec="0 0 22 * * FRI"&calls=[{"method":"Shelly.GetDeviceInfo"}]
curl -X POST -d '{"id":1,"method":"Schedule.Create","params":{"timespec":"0 0 22 * * FRI","calls":[{"method":"Shelly.GetDeviceInfo"}]}}' http://${SHELLY}/rpc
mos --port ${PORT} call Schedule.Create '{"timespec":"0 0 22 * * FRI","calls":[{"method":"Shelly.GetDeviceInfo"}]}'
Response
- Schedule.Create HTTP GET Response
- Schedule.Create Curl Response
- Schedule.Create Mos Response
{
"id": 3,
"rev": 5
}
{
"id": 1,
"src": "shellypro4pm-f008d1d8b8b8",
"params": {
"id": 3,
"rev": 5
}
}
{
"id": 3,
"rev": 5
}
Schedule.Update example
- Schedule.Update HTTP GET Request
- Schedule.Update Curl Request
- Schedule.Update Mos Request
http://192.168.33.1/rpc/Schedule.Update?id=3&enable=false
curl -X POST -d '{"id":1,"method":"Schedule.Update","params":{"id":3,"enable":false}}' http://${SHELLY}/rpc
mos --port ${PORT} call Schedule.Update '{"id":3,"enable":false}'
Response
- Schedule.Update HTTP GET Response
- Schedule.Update Curl Response
- Schedule.Update Mos Response
{
"rev": 11
}
{
"id": 1,
"src": "shellyplus1-a8032abe54dc",
"params": {
"rev": 11
}
}
{
"rev": 11
}
Schedule.List example
- Schedule.List HTTP GET Request
- Schedule.List Curl Request
- Schedule.List Mos Request
http://192.168.33.1/rpc/Schedule.List
curl -X POST -d '{"id":1,"method":"Schedule.List"}' http://${SHELLY}/rpc
mos --port ${PORT} call Schedule.List
Response
- Schedule.List HTTP GET Response
- Schedule.List Curl Response
- Schedule.List Mos 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
}
{
"id": 1,
"src": "shellypro4pm-f008d1d8b8b8",
"params": {
"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
}
}
{
"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
- Schedule.Delete HTTP GET Request
- Schedule.Delete Curl Request
- Schedule.Delete Mos Request
http://192.168.33.1/rpc/Schedule.Delete?id=3
curl -X POST -d '{"id":1,"method":"Schedule.Delete","params":{"id":3}}' http://${SHELLY}/rpc
mos --port ${PORT} call Schedule.Delete '{"id":3}'
Response
- Schedule.Delete HTTP GET Response
- Schedule.Delete Curl Response
- Schedule.Delete Mos Response
{
"rev": 11
}
{
"id": 1,
"src": "shellyplus1-a8032abe54dc",
"params": {
"rev": 11
}
}
{
"rev": 11
}
Schedule.DeleteAll example
- Schedule.DeleteAll HTTP GET Request
- Schedule.DeleteAll Curl Request
- Schedule.DeleteAll Mos Request
http://192.168.33.1/rpc/Schedule.DeleteAll
curl -X POST -d '{"id":1,"method":"Schedule.DeleteAll"}' http://${SHELLY}/rpc
mos --port ${PORT} call Schedule.DeleteAll
Response
- Schedule.DeleteAll HTTP GET Response
- Schedule.DeleteAll Curl Response
- Schedule.DeleteAll Mos Response
{
"rev": 11
}
{
"id": 1,
"src": "shellyplus1-a8032abe54dc",
"params": {
"rev": 11
}
}
{
"rev": 11
}