$appId
$appId :
App-Id 在开放平台申请: https://open.home.mi.com.
更方便的API调用.
Class Api
properties( $pid, string $voice = '') : array|mixed
读取属性 读取一个属性 : GET /api/v1/properties?pid=AAAD.1.1 读取多个属性:GET /api/v1/properties?pid=AAAD.1.1,AAAD.2.3 语音控制需要增加voice字段:GET /api/v1/properties?pid=AAAD.1.1,AAAD.2.3&voice={"recognition":"灯开了吗","semantics":"xxx"}.
$pid | ||
string | $voice |
subscript( $properties, $receiverUrl) : array|boolean|mixed
订阅属性变化 开始订阅: POST /api/v1/subscriptions Content-Type: application/json Content-Length: 134 * { "topic": "properties-changed", "properties": [ "AAAB.1.1", "AAAC.1.1", "AAAD.1.1", "AAAD.1.2" ], "receiver-url": "xxx" }.
订阅成功,应答如下: HTTP/1.1 207 Multi-Status Content-Type: application/json Content-Length: 156 { "expired": 36000, // 超时时间,单位为秒。 "properties": [ { "pid": "AAAB.1.1", "status": 0 }, { "pid": "AAAC.1.1", "status": -704002023 }, { "pid": "AAAD.1.1", "status": 0 } { "pid": "AAAD.1.2", "status": 705202023 } ] }
$properties | ||
$receiverUrl |
unSubscript( $properties) : array|boolean|mixed
退订属性变化 POST /api/v1/subscriptions Content-Type: application/json Content-Length: 134 * { "topic": "properties-changed", "properties": [ "AAAB.1.1", "AAAC.1.1", "AAAD.1.1", "AAAD.1.2" ], "receiver-url": "xxx" }.
退订成功,应答如下: HTTP/1.1 207 Multi-Status Content-Type: application/json Content-Length: 156 { "expired": 36000, // 超时时间,单位为秒。 "properties": [ { "pid": "AAAB.1.1", "status": 0 }, { "pid": "AAAC.1.1", "status": -704002023 }, { "pid": "AAAD.1.1", "status": 0 } { "pid": "AAAD.1.2", "status": 705202023 } ] }
$properties |
getPropertiesGraceful( $data) : array|boolean|mixed
按照名称获取多个设备属性.
$data | $data = ['AABBCD-did' => ['type' => 'urn:miot-spec-v2:device:light:0000A001:yeelink-color1:1', data => ['brightness', 'on']] ] |
setPropertyGraceful( $did, $type, $data) : array|boolean|mixed
按照名称设置属性.
$did | ||
$type | ||
$data | | $data = ['brightness' => 75, 'on' => true] |
setPropertiesGraceful( $data) : array|boolean|mixed
按照名称设置多个设备属性.
$data | $data = ['AABBCD-did' => ['type' => 'urn:miot-spec-v2:device:light:0000A001:yeelink-color1:1', data => ['brightness' => 75, 'on' => true]] ] |
httpClient() : \MiotApi\Util\Request
获取http Client.