actions-on-google / smart-home-dashboard

Apache License 2.0
73 stars 27 forks source link

I am getting ERROR: No key or keyFile set #22

Closed chiranjeeviBchiru closed 5 years ago

chiranjeeviBchiru commented 5 years ago

const {smarthome} = require('actions-on-google'); const app = smarthome({ jwt:'./MyFirstProject_7XXfd.json' });

app.reportState({ requestId: XXXX, agentUserId: 'XXX-XXX-XX105', payload:{ devices: { states: { "light-123": { on: true } } } } }) .then((res) => { // Report state was successful console.log("Report state was successful in sync"); }) .catch((res) => { // Report state failed console.log("Report state failed sync" + res); });

if I execute this file I am getting error like No key or keyfile set

Fleker commented 5 years ago

You need to import the JSON file, not pass the filename, ie.

const app = smarthome({
  jwt: require('./MyFirstProject_7XXfd.json')
});
chiranjeeviBchiru commented 5 years ago

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" }}

Fleker commented 5 years ago

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.

chiranjeeviBchiru commented 5 years ago

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.

Fleker commented 5 years ago

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.

chiranjeeviBchiru commented 5 years ago

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.

Fleker commented 5 years ago

It's not clear where in the system the command is failing. You may need to do some manual debugging.

chiranjeeviBchiru commented 5 years ago

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.

Fleker commented 5 years ago

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.

chiranjeeviBchiru commented 5 years ago

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." } ] } ] } }

chiranjeeviBchiru commented 5 years ago

Whatever the state I am updating, its updating in the report state dashboard as well when I click refresh button.

Screen Shot 2019-05-15 at 3 36 04 PM

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.

Screen Shot 2019-05-15 at 3 48 43 PM

Fleker commented 5 years ago

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.

chiranjeeviBchiru commented 5 years ago

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

Fleker commented 5 years ago

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
        }
      }
    }
  }
})