Closed chiranjeeviBchiru closed 5 years ago
You need to import the JSON file, not pass the filename, ie.
const app = smarthome({
jwt: require('./MyFirstProject_7XXfd.json')
});
Thank you so much for replying, I added that now, again I am getting the error :
Report state failed sync{ "error": { "code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND" }}
If you are getting a 404, then that likely means the agentUserId
you are providing does not yet exist in the homegraph, either because the user disconnected or the user was never added.
I am using my project ID as agentuserId, and hardcoding the device for testing purpose am I going in a rite way or I am not getting exactly what to send in a agentuserId.. can u please help me out on this thank you.
The agentUserId needs to be the same user ID you pass in the SYNC response the first time, and used later on to report the state.
Thank you for your help its working fine now, I am able to sync data in smart home dashboard now, but while testing through Smart Home Test Suite its getting failed for example "turn on light" its getting failed, may I know where exactly I am doing wrong.
It's not clear where in the system the command is failing. You may need to do some manual debugging.
can you please provide me the exact payload structure needs to be for Sync , Query and execute.
because I am getting Invalid JSON payload received.
The documentation for processing intents shows the structures you're supposed to send. If you are using the Node.js library with Typescript, you can get the structure as type bindings.
yes i am using Node.js, even for report state do I need to send the same payload ? if answer is yes then I am sending the same payload in report state as per the documentation you have mentioned in above comment but am getting the error.
This is the payload I am sending for SYNC request in report state api:
"devices":[{"id":"97_fueb4_Switch_Light2","type":"action.devices.types.LIGHT","traits":["action.devices.traits.OnOff"],"name":{"name":"Light2"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Switch","itemTag":"Lighting","openhabVersion":"2.1"}},{"id":"97_fueb4_Switch_Light1","type":"action.devices.types.LIGHT","traits":["action.devices.traits.OnOff"],"name":{"name":"Light1"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Switch","itemTag":"Lighting","openhabVersion":"2.1"}},{"id":"97_fueb4_Switch_Dim","type":"action.devices.types.LIGHT","traits":["action.devices.traits.Brightness","action.devices.traits.OnOff"],"name":{"name":"Dimmer"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Dimmer","itemTag":"Lighting","openhabVersion":"2.1"}}]}
The error I am getting is:
Report state failed sync{ "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name \"devices\" at 'payload': Proto field is not repeating, cannot start list.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "payload", "description": "Invalid JSON payload received. Unknown name \"agent_user_id\" at 'payload': Cannot find field." }, { "field": "payload", "description": "Invalid JSON payload received. Unknown name \"devices\" at 'payload': Proto field is not repeating, cannot start list." } ] } ] } }
Whatever the state I am updating, its updating in the report state dashboard as well when I click refresh button.
But in smart home test suite I am getting this result for the same states updated in the above screenshot, I am confused why some of the test cases are getting failed.
It seems like you may not be reporting on: false
in the last case for the Dimmer, if the screenshots were taken at the same time.
For Report State you should be following a payload similar to what you'd return for a QUERY.
yes i am using Node.js, even for report state do I need to send the same payload ? if answer is yes then I am sending the same payload in report state as per the documentation you have mentioned in above comment but am getting the error.
This is the payload I am sending for SYNC request in report state api:
"devices":[{"id":"97_fueb4_Switch_Light2","type":"action.devices.types.LIGHT","traits":["action.devices.traits.OnOff"],"name":{"name":"Light2"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Switch","itemTag":"Lighting","openhabVersion":"2.1"}},{"id":"97_fueb4_Switch_Light1","type":"action.devices.types.LIGHT","traits":["action.devices.traits.OnOff"],"name":{"name":"Light1"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Switch","itemTag":"Lighting","openhabVersion":"2.1"}},{"id":"97_fueb4_Switch_Dim","type":"action.devices.types.LIGHT","traits":["action.devices.traits.Brightness","action.devices.traits.OnOff"],"name":{"name":"Dimmer"},"willReportState":true,"attributes":{},"deviceInfo":{"manufacturer":"openHAB","model":"Lighting","hwVersion":"2.1","swVersion":"2.1"},"customData":{"itemType":"Dimmer","itemTag":"Lighting","openhabVersion":"2.1"}}]}
The error I am getting is:
Report state failed sync{ "error": { "code": 400, "message": "Invalid JSON payload received. Unknown name "devices" at 'payload': Proto field is not repeating, cannot start list.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "payload", "description": "Invalid JSON payload received. Unknown name "agent_user_id" at 'payload': Cannot find field." }, { "field": "payload", "description": "Invalid JSON payload received. Unknown name "devices" at 'payload': Proto field is not repeating, cannot start list." } ] } ] } }
can you please have a look on this as well
Your report state should look similar to the snippet below. It returns states. It should not be the same as a SYNC response, but like a QUERY response (but slightly modified).
app.reportState({
requestId: '123ABC',
agentUserId: 'user-123',
payload: {
devices: {
states: {
"light-123": {
on: true
}
}
}
}
})
if I execute this file I am getting error like No key or keyfile set