{"action":"created","issue":{"url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/2","repository_url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk","labels_url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/2/comments","events_url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/2/events","html_url":"https://github.com/zzyss86/mi-aqara-sdk/issues/2","id":315820561,"number":2,"title":"怎么用这个项目在linux服务器中控制米家设备中的灯的开关","user":{"login":"yyzhou0811","id":30650510,"avatar_url":"https://avatars2.githubusercontent.com/u/30650510?v=4","gravatar_id":"","url":"https://api.github.com/users/yyzhou0811","html_url":"https://github.com/yyzhou0811","followers_url":"https://api.github.com/users/yyzhou0811/followers","following_url":"https://api.github.com/users/yyzhou0811/following{/other_user}","gists_url":"https://api.github.com/users/yyzhou0811/gists{/gist_id}","starred_url":"https://api.github.com/users/yyzhou0811/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yyzhou0811/subscriptions","organizations_url":"https://api.github.com/users/yyzhou0811/orgs","repos_url":"https://api.github.com/users/yyzhou0811/repos","events_url":"https://api.github.com/users/yyzhou0811/events{/privacy}","received_events_url":"https://api.github.com/users/yyzhou0811/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-19T10:35:12Z","updated_at":"2018-04-23T04:24:57Z","closed_at":null,"author_association":"NONE","body":"我新建了一个js文件test.js,代码如下:\r\nconst MiAqara = require('mi-aqara-sdk');\r\n\r\nMiAqara.create([{\r\n   sid: '7811dcb90fb3',\r\n   password: '9432979075174A29'\r\n}], {\r\n   onReady () { // Íø¹Ø¼°×ÓÉè±¸ÒÑÕÒµ½, ¶à¸öÍø¹Ø¿ÉÄÜ»áµ÷ÓÃ¶à´Î\r\n     //console.log('onReady', msg);\r\n    },\r\n   onMessage () { // ËùÓÐÏûÏ¢ÀàÐÍ\r\n     //console.log('onMessage', msg);\r\n    }\r\n});\r\nMiAqara.start();\r\n\r\nconsole.log(MiAqara.getGatewayBySid('7811dcb90fb3'));\r\nconsole.log(MiAqara.getDevicesByGatewaySid('7811dcb90fb3'));\r\n//console.log(MiAqara.getDevicesByModel('switch'));\r\n//MiAqara.controlLight({sid:'7811dcb90fb3',power:true});\r\nMiAqara.controlLight({sid:'7811dcb90fb3',power:false});\r\n//console.log(MiAqara.getDevicesByGatewaySid('7811dcb90fb3'));\r\n//console.log(MiAqara.getDeviceBySid('158d00021177c0'));\r\n//console.log(MiAqara.getDeviceList())\r\n//console.log(MiAqara.getDevicesByGatewaySidAndModel('7811dcb90fb3', 'switch'));\r\n//console.log(MiAqara.getGatewayList());\r\n\r\n\r\n然后使用node test.js执行命令会报错，\r\ncrypto.js:146\r\n  var ret = this._handle.update(data, inputEncoding);\r\n                         ^\r\n\r\nTypeError: Cipher data must be a string or a buffer\r\n    at TypeError (native)\r\n    at Cipheriv.update (crypto.js:146:26)\r\n    at Object.cipher (/root/node_modules/mi-aqara-sdk/libs/utils.js:40:26)\r\n    at GatewayHelper.write (/root/node_modules/mi-aqara-sdk/libs/GatewayHelper.js:127:34)\r\n    at GatewayHelper.controlLight (/root/node_modules/mi-aqara-sdk/libs/GatewayHelper.js:158:14)\r\n    at Object.<anonymous> (/root/node_modules/test.js:20:9)\r\n    at Module._compile (module.js:577:32)\r\n    at Object.Module._extensions..js (module.js:586:10)\r\n    at Module.load (module.js:494:32)\r\n    at tryModuleLoad (module.js:453:12)\r\n\r\n\r\n不能控制灯的开关，用米家可以控制灯的开关，跪求，麻烦帮忙看看,而且也获取不到子设备列表"},"comment":{"url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/comments/383450592","html_url":"https://github.com/zzyss86/mi-aqara-sdk/issues/2#issuecomment-383450592","issue_url":"https://api.github.com/repos/zzyss86/mi-aqara-sdk/issues/2","id":383450592,"user":{"login":"GitCHQL","id":19940879,"avatar_url":"https://avatars2.githubusercontent.com/u/19940879?v=4","gravatar_id":"","url":"https://api.github.com/users/GitCHQL","html_url":"https://github.com/GitCHQL","followers_url":"https://api.github.com/users/GitCHQL/followers","following_url":"https://api.github.com/users/GitCHQL/following{/other_user}","gists_url":"https://api.github.com/users/GitCHQL/gists{/gist_id}","starred_url":"https://api.github.com/users/GitCHQL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GitCHQL/subscriptions","organizations_url":"https://api.github.com/users/GitCHQL/orgs","repos_url":"https://api.github.com/users/GitCHQL/repos","events_url":"https://api.github.com/users/GitCHQL/events{/privacy}","received_events_url":"https://api.github.com/users/GitCHQL/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T04:24:57Z","updated_at":"2018-04-23T04:24:57Z","author_association":"NONE","body":"你试试sid和data不加双引号\r\n"}}
{"actor":{"display_login":"GitCHQL"}}