Device information and control: device
This topic describes the API calls for device information and control in the custom device panel software development kit (SDK).
Background information
For information about how to install the SDK and call APIs, see Getting Started.
Get the device TSL model
getDeviceTSL
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter Type | Subparameter | Subparameter type | Description |
tsl | object | events | array | Events. |
properties | array | Properties. | ||
services | array | Services. | ||
... | ... | ... |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getDeviceTSL({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
"schema": "http://aliyun/iot/thing/desc/schema",
"profile": {
"productKey": "xxxxxxx",
"deviceName": "xxxxxxxxxxxxxxxx"
},
"link": "/sys/a1xxxxpck/YzqEnxxxx2pjjo/thing/",
"services": [
{
"outputData": [],
"identifier": "ToggleLightSwitch",
"inputData": [],
"method": "thing.service.ToggleLightSwitch",
"name": "Flip main light switch",
"required": false,
"callType": "async"
}
],
"properties": [
{
"identifier": "LightSwitch",
"dataType": {
"specs": {
"0": "Off",
"1": "On"
},
"type": "bool"
},
"name": "Main light switch",
"accessMode": "rw",
"required": true
}
],
"events": [
{
"outputData": [
{
"identifier": "ErrorCode",
"dataType": {
"specs": {
"0": "Normal"
},
"type": "enum"
},
"name": "Error code"
}
],
"identifier": "Error",
"method": "thing.event.Error.post",
"name": "Report error",
"type": "info",
"required": true
}
]
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get product information
getProductInfo
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
info | object | categoryKey | string | The category identifier. |
categoryName | string | The category name. | ||
categoryId | int | Category ID | ||
gmtCreate | int | The time when the device record was created. For IoT Platform, this is the time when the device certificate was generated during mass production. | ||
gmtModified | int | The time when the device record was last modified. This field is for internal use and can be ignored. | ||
image | string | The category image. | ||
netType | string | The network connection type of the device. | ||
nodeType | string | The type of the device. The value is determined by how the device was created in IoT Platform. Devices in mass production are typically of the DEVICE type. Valid values: VIRTUAL (virtual device), VIRTUAL_SHADOW (virtual shadow device), and DEVICE (real device). | ||
name | string | The device name. | ||
... | ... | ... |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getProductInfo({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get device information
getDeviceInfo
Request parameters
Parameter | Type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Type | Subparameter | Subparameter type | Description |
info | object | identityId | string | The user's identity ID. |
iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | ||
productKey | string | The Device ID is the unique identifier that the IoT Platform issues to a device. | ||
deviceName | string | The device name. This is part of the device certificate information. The name is custom or system-generated when the device is registered and is unique within the product. | ||
productName | string | The product name of the device. | ||
productImage | string | The product image of the device. | ||
productModel | string | The product model of the device. | ||
nickName | string | The nickname that the user gives to the device. | ||
netType | string | The network connection type of the device. | ||
thingType | string | The type of the device. The value is determined by how the device was created in IoT Platform. Devices in mass production are typically of the DEVICE type. Valid values: VIRTUAL (virtual device), VIRTUAL_SHADOW (virtual shadow device), and DEVICE (normal device). | ||
nodeType | String | The node type of the device. Valid values: DEVICE and GATEWAY. | ||
status | Int | The device status. 0: not activated. 1: online. 3: offline. 8: disabled. | ||
owned | Int | 0: sharer. 1: owner. | ||
identityAlias | String | The user's display name. The value can be a mobile number, login name, or email address. | ||
gmtModified | Long | The time when the binding was modified. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getDeviceInfo({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get device group details
getDeviceGroupInfo
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | homeId | string | The home ID. This is a unique identifier that IoT Platform assigns to a home. | Yes |
controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | Yes |
Response parameters
info | object | controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. |
name | string | The name of the device group. | ||
createMillis | Long | The time when the device group was created. The value is a UNIX timestamp in milliseconds. | ||
productKey | String | The product key of the product to which the device group belongs. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | ||
productImage | String | The URL of the icon for the product to which the device group belongs. Example: https://***/***.png. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getDeviceGroupInfo({
homeId:'xxx',
controlGroupId:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Subscribe to device or group events
subscribeAll
Request parameters
Parameter | Parameter Type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No |
iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes | ||
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
result | array | code | string | The returned result. The first element (index 0) in the array is the subscription result for the current device or the primary device of the group. The second element (index 1) is the subscription result for the device group. |
message | string | The returned message. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.subscribeAll({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
[
// Subscription result for the (primary) device
{
code: '200',
message: 'success
},
// Subscription result for the device group
{
code: '200',
message: 'success
}
]API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Unsubscribe from device or group events
unsubscribeAll
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No |
iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes | ||
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
result | array | code | string | The returned result. The first element (index 0) in the array is the subscription result for the current device or the primary device of the group. The second element (index 1) is the subscription result for the device group. |
message | string | The returned message. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.unsubscribeAll({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
[
// Unsubscription result for the (primary) device
{
code: '200',
message: 'success
},
// Unsubscription result for the device group
{
code: '200',
message: 'success
}
]API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get device properties
getProps
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
props | object | [identifier] | number | string | boolean | A device property, such as a switch. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getProps({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
powerstate: 0,
mode: 33,
brightness: 5
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Listen for device property change events
onPropsChange
Request parameters
Parameter | Parameter Type | Description | Required |
callback | Function | The callback function for device property change events. | Yes |
Response parameters
Parameter | Type | Subparameter | Subparameter type | Description |
props | object | [identifier] | number | string | boolean | A device property, such as a switch. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.onPropsChange((props)=>{
console.log(props)
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get the online or offline status of a device from the cloud
getStatus
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Type | Description |
status | int | The device status. 0: not activated. 1: online. 3: offline. 8: disabled. |
Example request
device.getStatus({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
3API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Listen for device cloud online or offline status events
onStatusChange
Request parameters
Parameter | Parameter type | Description | Required |
callback | Function | Device Offline Event Callback | Yes |
Response parameters
Parameter | Parameter type | Description |
status | int | The device status. 0: not activated. 1: online. 3: offline. 8: disabled. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.onStatusChange((status)=>{
console.log(props)
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Get device events
getEvents
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes |
Response parameters
Parameter | Parameter type | Description |
events | array | Device events. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getEvents({
iotId:'xxx',
productKey:'xxx'
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
[
{
"identifier": "Error",
"time": 1517420842314,
"type": "info",
"value": {
"Shrink5": 12,
"Shrink20": {
"testKey2": "val2",
"testKey": "val"
}
}
}
]API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Set device properties
setProps
Request parameters
Parameter | Parameter Type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. | ||
props | object | [identifier] | number | string | boolean | The value of a device property. Example: powerstate:0. | Yes |
extends | object | - | - | Extension fields. This parameter is optional. | No |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
result | object | code | string | The return value. |
message | string | The returned message. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.setProps({
iotId:'xxx',
productKey:'xxx'
},{
powerstate:0,
mode:2
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
code:'200',
message:'success'
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Set a device service
callService
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No | ||
skillId | int | Skill ID | Required for the Tmall Genie app. | ||
serviceName | string | - | - | The service name. | Yes |
params | object | [key] | number | string | boolean | Service parameters. | Yes |
extends | object | [key] | number | string | boolean | Extension parameters. | No |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
result | object | code | string | The return value. |
message | string | The returned message. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.callService({
iotId:'xxx',
productKey:'xxx'
}, 'CommonService',{
method: 0,
flag: 0,
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
code:'200',
message:'success'
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Start a local connection
startLocalConnect
When this API is called, the app connects to a Wi-Fi device over a local area network (LAN), or to a Bluetooth Low Energy (BLE) or mesh device over Bluetooth.
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter Type | Subparameter | Subparameter type | Description |
result | object | result | string | The return value. |
Example request
device.startLocalConnect({
iotId:'xxx',
productKey:'xxx'
},).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
result:'success',
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Stop a local connection
stopLocalConnect
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | No | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
result | object | result | string | The return value. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.stopLocalConnect({
iotId:'xxx',
productKey:'xxx'
},).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
result:'success',
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✔︎ |
Query the local connection state
getLocalConnectionState
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
connectionState | object | localConnectionState | int | The connection state. 1: connected. 2: not connected. 3: connecting. |
type | int | The connection type. 0: unknown. 1: Wi-Fi LAN. 2: Bluetooth. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getLocalConnectionState({
iotId:'xxx',
productKey:'xxx'
},).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
localConnectionState: 1,
type: 2
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Query the local connection state of a device group
getGroupLocalConnectionState
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | controlGroupId | string | The device group ID. This is a unique identifier that IoT Platform assigns to a device group. | Yes |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
groupConnectionState | object | groupLocalStatus | int | The connection state of the group devices. 0: all online. 1: partially online. 2: all offline. |
devicesLocalStatus | array | The details of the online status of the group devices. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getGroupLocalConnectionState({
iotId:'xxx',
productKey:'xxx'
},).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
groupLocalStatus: 1,
devicesLocalStatus: [
{
"iotId":"xxx1"
"productKey":"X5eCzh6fEH7",
"deviceName":"5gJtxDVeGAkaEztpisjX",
"time":1510292697471,
"status":3
},
{
"iotId":"xxx2"
"productKey":"X5eCzh6fEH7",
"deviceName":"5gJtxDVeGAkaEztpisjX",
"time":1510292697471,
"status":1
},
]
}
// Note: status indicates the device lifecycle. Valid values: 1 (locally online) and 3 (locally offline). time indicates the start time of the current status.API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Listen for device local connection state events
onLocalConnectChange
Request parameters
Parameter | Parameter Type | Description | Required |
callback | Function | The callback function for device local connection events. | Yes |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
connectionState | object | localConnectionState | int | The connection state. 1: connected. 2: not connected. 3: connecting. |
type | int | The connection type. 0: unknown. 1: Wi-Fi LAN. 2: Bluetooth. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.onLocalConnectChange((msg)=>{
console.log(msg)
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Listen for device detach events
deviceUnbindEvent
Request parameters
Parameter | Parameter Type | Description | Required |
callback | Function | The callback function for device detach events. | Yes |
Response parameters
Parameter | Type | Subparameter | Subparameter type | Description |
res | - | - | - | - |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.deviceUnbindEvent((msg)=>{
console.log(msg)
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✔︎ | ✔︎ | ✖︎ |
Get the corpus
getFunctionCorpus
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Yes | ||
isInfrared | boolean | - | - | Is this an infrared device? | No |
Response parameters
Parameter | Type | Description |
functionCorpus | array | The list of corpora. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getFunctionCorpus({
iotId:'xxx',
productKey:'xxx'
},).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
[
{ functionName: "Switch", corpusList: ["Turn on the light", "Turn off the light"] },
{ functionName: "Switch", corpusList: ["Turn on the light", "Turn off the light"] }
]API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✖︎ | ✖︎ | ✔︎ |
Query parent and sub-device information
getSubDevice
Request parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description | Required |
deviceIdentify | object | iotId | string | The device ID. This is a unique identifier that IoT Platform issues to the device. | Yes |
productKey | string | The product key. This is part of the device certificate information. It is a globally unique identifier that IoT Platform issues to the product when the product is created. | Yes | ||
skillId | int | The skill ID. | Required for the Tmall Genie app. |
Response parameters
Parameter | Parameter type | Subparameter | Subparameter type | Description |
subDeviceInfo | object | childrenDevices | array | The list of sub-devices. |
hasSubDevice | boolean | - |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.getSubDevice({
iotId:'xxx',
productKey:'xxx',
skillId: 3404
}).then((res)=>{
// success
}).catch((err)=>{
// fail
})Example response
{
hasSubDevice: true,
childrenDevices:[
{
alias: "Switch"
childrenDevices: null
devId: "a80171c72e190156567f2a5d3c04931ae1"
devType: "Switch"
devTypeEn: "switch"
elementCode: "e1"
gmtCreate: "2023-06-20T06:16:34.000Z"
icon: "https://ai-genie-center.oss-cn-hangzhou.aliyuncs.com/app-data/iot-center/1f9e27pdq_segment.png"
linkType: 1
parentDeviceId: "a80171c72e190156567f2a5d3c04931a"
productKey: "18427591",
skillId: 3404
status: "{\"sceneNumber\":\"10312\",\"sceneOn\":\"10331\",\"sceneOff\":\"10332\",\"onlinestate\":\"offline\",\"sdkVersion\":\"14\",\"vendorModelVersion\":\"10\",\"powerstate\":\"0\",\"versionNumber\":\"66306\",\"subscribeGroupAddr\":\"61952\",\"tid\":\"182\"}"
typeGroup: "Switch"
userId: "1368863065974110870"
zone: "",
shareInfo:{
isShareDevice: false
ownerNickName: null
shareId: 0
status: 0
supportShare: false
supportShareControl: false
}
}
]
}API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✖︎ | ✖︎ | ✔︎ |
Listen for mesh device connection status events
onMeshStatusChange
This event combines the cloud (gateway) connection status with the local connection status. A device is considered online if it is connected either to the cloud or locally. It is considered offline if both connections are unavailable. If you use this event, you do not need to use onStatusChange to listen for the online or offline status from the cloud.
Request parameters
Parameter | Type | Description | Required |
callback | Function | The callback function for mesh device connection status events. | Yes |
Response parameters
Parameter | Parameter Type | Subparameter | Subparameter type | Description |
status | object | deviceId | string | The device group ID is a unique identifier assigned to a device group by the IoT Platform. |
onlineState | string | The ignore option is not supported for offline detection. Online Offline | ||
skillId | string | The skill ID of the device. |
Example request
import { device } from 'aliyun-livinglink-sdk';
device.onMeshStatusChange((msg)=>{
console.log(msg)
})API support
Cloud Intelligence | Proprietary Brand | Tmall Genie |
✖︎ | ✖︎ | ✔︎ |