我们为Google助手开发了一个智能家居操作,我们的“分期操作”通过了智能家居的测试套件。既然我们想要获得“生产操作”的认证,测试套件就没有通过,没有一个命令起作用。设备的状态更改正确,但是测试套件返回了以下错误: AssertionError:预期状态包含:{"on": true },实际状态:{}:预期为true
我们以前遇到过“暂存操作”的问题,并将其确定为HomeGraph同步问题。我们把它修好了然后它就起作用了。“生产操作的”代码与“暂存操作”的代码完全相同,设置也是相同的。所以我们不知道我们能做些什么让测试套件通过。有人知道问题出在哪里吗?
下面是我们代码的摘录:
const { smarthome } = require('actions-on-google');
// creating app in constructor
this._app = smarthome({ jwt, debug: this._options.debug || false });
// code-snipped sending state to HomeGraph after creating the state object from our device states
console.info('Report state:');
console.info(inspect(state, {depth: null, showHidden: false}));
this._app.reportState(state)
.then(res => console.info('report state succeeded', res))
.catch(err => console.error('report state failed', err));下面是相应的日志:
Report state:
{
requestId: 'c82c0c20-a10d-4ded-a456-319109188501',
agentUserId: '730f1842168ade4dcf9be3e40ea279e7ac4e6f21c002c09909f9d9a0341d2214',
payload: {
devices: {
states: {
'500dc011398fd3c191efdfa8e13a1062f7ef4d1c': { on: true, online: true }
}
}
}
}
report state succeeded {
"requestId": "c82c0c20-a10d-4ded-a456-319109188501"
}如果出现错误,我们预计如下所示:
misconfigured
但它成功了。
编辑:
在将状态发送到HomeGraph后,我们通过直接从HomeGraph读取状态来调整代码,以查看HomeGraph是否从我们那里得到了任何信息:
const auth = new google.auth.GoogleAuth({
credentials: jwt,
scopes: ['https://www.googleapis.com/auth/homegraph']
});
this._hg = google.homegraph({
version: 'v1',
auth: auth,
});
this._app = smarthome({ jwt, debug: this._options.debug || false });
this._app.reportState(state).then(async res => {
const request = {
requestBody: {
agentUserId: state.agentUserId,
inputs: [{
payload: {
devices: Object.keys(state.payload.devices.states).map(id => ({id}))
}
}]
}
};
console.info(require('util').inspect(request, {depth: null}));
const readStates = await this._hg.devices.query(request);
console.info('########## STATES in HOMEGRAPH #######################');
console.info(readStates.data);
return res;
})
.catch(err => console.error('report state failed', err));州是空的。
我们还实现了一个简单的node.js应用程序,通过HomeGraph API读取所有设备状态。所有设备状态在任何时候都是空的。
主要问题是:为什么调用this._app.reportState(状态)从未遇到捕获处理程序?我们把状态发送给HomeGraph一定出了什么问题,但是我们没有得到任何错误.?
发布于 2020-06-23 06:01:08
谢谢!这个问题不知怎么解决了。也许谷歌有一个错误,但我们没有做任何事情,测试现在通过了。
发布于 2020-06-18 15:39:21
如果您将{}作为实际的状态值,那么测试套件似乎无法从主图中读取数据。这有两个可能的原因。
在您的生产项目中,您的测试帐户有不同的agentUserId
https://stackoverflow.com/questions/62449940
复制相似问题