Change device state
Changes the current state of user devices.
Example case where this request is sent: the user opens the
In response to this request, the provider changes the state of the requested user devices.
Smart home platform request format
The smart home platform sends a request to the provider's Endpoint URL (https://example.com/).
POST https://functions.yandexcloud.net/<function_id>?integration=raw
Request body format
{
"headers": {
"request_id": String,
"authorization": string
},
"request_type": String,
"payload": {
"devices":[
{
"id": String,
"custom_data": Object,
"capabilities": [
"<capability1>": Object,
"<capability2>": Object,
...
]
}
]
},
"api_version": Float
}
|
Parameter |
Type |
Description |
Required |
|
headers |
Object |
Object with additional request fields. |
Yes |
|
request_type |
String |
Request type. Acceptable values:
|
Yes |
|
payload |
Object |
Object with devices. |
Yes |
|
api_version |
Float |
The protocol version of Yandex Smart Home. |
Yes |
headers object
|
Parameter |
Type |
Description |
Required |
|
request_id |
String |
Request ID. Should be logged on the provider's side for investigating incidents and problems. |
Yes |
|
authorization |
String |
User's authorization token. |
Yes |
payload object
|
Parameter |
Type |
Description |
Required |
|
devices |
Array of objects |
Array of the user's devices. |
Yes |
devices object
|
Parameter |
Type |
Description |
Required |
|
id |
String |
Device ID. It must be unique among all the manufacturer's devices. |
Yes |
|
custom_data |
Object |
An object with the device that the provider sent in response to the Information about user devices request. Consists of a set of |
No |
|
capabilities |
Array of objects |
Array with information about device capabilities. |
Yes |
capabilities object
|
Parameter |
Type |
Description |
Required |
|
<capability1> |
Object |
Capability and command to change it. For more information about the list of available capabilities and their parameters, see About capabilities. |
Yes |
|
<capability2> |
Object |
Capability and command to change it. For more information about the list of available capabilities and their parameters, see About capabilities. |
Yes |
Provider response format
The provider must use the correct format to respond to the request received from the smart home platform.
For more information about returning status codes other than 200 OK, see the documentation.
HTTP/1.1 200 OK
{
"request_id": String,
"payload": {
"devices": [
{
"id": String,
"capabilities": [
"<capability1>": Object,
"<capability2>": Object,
...
],
"action_result": {
"status": String,
"error_code": String,
"error_message": String
}
},
...
]
}
}
|
Parameter |
Type |
Description |
Required |
|
request_id |
String |
Request ID. |
Yes |
|
payload |
Object |
Object with devices. |
Yes |
payload object
|
Parameter |
Type |
Description |
Required |
|
devices |
Array of objects |
Array of the user's devices. |
Yes |
devices object
|
Parameter |
Type |
Description |
Required |
|
id |
String |
Device ID. It must be unique among all the manufacturer's devices. |
Yes |
|
capabilities |
Array of objects |
Array with information about device capabilities. |
Yes, if the |
|
action_result |
Object |
Result of device state change. This parameter is required if Note We recommend that you return a parameter for each capability separately. If this is not possible, return the result for the entire device. The response to the request is considered successful ( |
Yes, if the |
capabilities object
|
Parameter |
Type |
Description |
Required |
|
<capability1> |
Object |
Command result. For more information about the list of available capabilities and their parameters, see About capabilities. |
No |
|
<capability2> |
Object |
Command result. For more information about the list of available capabilities and their parameters, see About capabilities. |
No |
action_result object
|
Parameter |
Type |
Description |
Required |
|
status |
String |
Status of the device state change. Acceptable values:
|
No |
|
error_code |
String |
An error code from the list. If the field is filled in, the |
No |
|
error_message |
String |
Extended human-readable description of a possible error. Available only on the Testing tab of the developer console. |
No |
HTTP/1.1 404 Not Found
Example
RequestResponse successfulResponse with errorcurl -i POST https://functions.yandexcloud.net/<function_id>?integration=raw \ -H 'Content-Type: application/json' \ -d '{ "headers": { "request_id": "1111-aaaa-2222-bbbb", "authorization": "Bearer 123qwe456a..." }, "request_type": "action", "payload": { "devices": [{ "id": "abc-123", "custom_data": { "foo": 1, "bar": "two", "baz": false, "qux": [1, "two", false], "quux": { "quuz": { "corge": [] } } }, "capabilities": [{ "type": "devices.capabilities.color_setting", "state": { "instance": "hsv", "value": { "h": 255, "s": 50, "v": 100 } } }, { "type": "devices.capabilities.on_off", "state": { "instance": "on", "value": false } } ] }, { "id": "sock-56GF-3", "capabilities": [{ "type": "devices.capabilities.on_off", "state": { "instance": "on", "value": false } }] }] }, "api_version": 1.0 }'HTTP/1.1 200 OK { "request_id": "1111-aaaa-2222-bbbb", "payload": { "devices": [{ "id": "abc-123", "capabilities": [{ "type": "devices.capabilities.color_setting", "state": { "instance": "hsv", "action_result": { "status": "ERROR", "error_code": "INVALID_ACTION", "error_message": "the human readable error message" } } }, { "type": "devices.capabilities.on_off", "state": { "instance": "on", "action_result": { "status": "DONE" } } }] }, { "id": "sock-56GF-3", "action_result": { "status": "ERROR", "error_code": "DEVICE_UNREACHABLE" } }] } }HTTP/1.1 404 Not Found
Frequently asked questions
Can I set up notifications about device state change?
An asynchronous protocol is required for such notifications. It's not used in Yandex Dialogs.
List of "key": value pairs separated by commas. The list is enclosed in curly brackets {}.
{
"name": "John",
"surname": "Smith"
}
String enclosed in quotation marks, for example: "Hello, world".
An array of elements separated by a comma. As array items, you can use standard JSON elements: a string, number, true, false, object, or array. Arrays are enclosed in square brackets []:
"cities": ["Moscow", "Tokyo", "New York"]
Floating-point number with a precision of 6-9 decimal digits.