界面
物联网 
new Iot() 
实例化
- 返回: - 实例化Iot对象
 
- 详情: - 实例化 - Iot对象,可以调用物联网模块中的方法
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
console.log(iot)openById() 
根据设备ID打开设备
- 参数: - {String} id 需要打开的设备ID
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备ID打开设备后的返回信息
 
- 详情: - 根据设备ID打开设备 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.openById('123')
console.log(res)setStatusById() 
根据设备ID设置设备状态
- 参数: - {String} id 需要打开的设备ID
- {Boolean} status 需要打开的设备ID
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备ID设置设备状态后的返回信息
 
- 详情: - 根据设备ID设置设备状态 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.setStatusById('123', true)
console.log(res)closeById() 
根据设备ID关闭设备
- 参数: - {String} id 需要打开的设备ID
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备ID关闭设备后的返回信息
 
- 详情: - 根据设备ID关闭设备 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.closeById('123')
console.log(res)openByType() 
根据设备类型批量打开设备
- 参数: - {String} type 需要打开的设备类型
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备类型批量打开设备后的返回信息
 
- 详情: - 根据设备类型批量打开设备 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.openByType('light')
console.log(res)setStatusByType() 
根据设备类型批量设置设备状态
- 参数: - {String} type 需要打开的设备类型
- {Boolean} status 设置的状态,开/关(状态可自定义)
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备类型批量设置设备状态后的返回信息
 
- 详情: - 根据设备类型批量设置设备状态 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.setStatusByType('light', true)
console.log(res)closeByType() 
根据设备类型批量关闭设备
- 参数: - {String} type 需要打开的设备类型
- {Boolean} sync 是否要与其他客户端同步状态
 
- 返回: - 根据设备类型批量关闭设备后的返回信息
 
- 详情: - 根据设备类型批量关闭设备 
- 示例: 
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const iot = new kapi.Iot()
const res = await iot.closeByType('light')
console.log(res)