0

I am unable to understand the syntax of Json for errors I have tried

return {
        "requestId": self.request_id,
        "payload": {
            "commands": [{
                "ids": [self.device_id],
                "status": "OFFLINE",
                "errorCode": "deviceTurnedOff"
            }]
        }
    }

and

return {
        "requestId": self.request_id,
        "payload": {
            "errorCode": "authFailure",
            "commands": [{
                "devices":  [{
                    "ids": [self.device_id],
                    "status": "ERROR",
                    "errorCode": "deviceTurnedOff"
                }]
            }]
        }
    }

and

return {
      "requestId": self.request_id,
      "payload": {
        "errorCode": self.error_code
      }
    }

none of above syntax are working, most of the time google home says that your actions is performed but I am returning error Json there.

I have read google actions documentation but failed to understand.

Umair
  • 119
  • 13

1 Answers1

1

I have come up with a few payloads and have managed to get them successfully triggering errors using the AoG simulator after consulting the docs.

Node.js snippet:

let resBody = {
    requestId: request.requestId,
    payload: {
        "errorCode": "notSupported"
    }
}
response.status(200).json(resBody);

Are you sure that the requestId is the same from the smart home request? How are you testing these errors?

Nick Felker
  • 11,536
  • 1
  • 21
  • 35
  • yes! request id is same and i have tried this json syntax for error response, not working. I am consulting the docs also but its not working, even before 2 days google home was not giving me response for "turn off device_name", today its giving me response for that and i have not change any piece of code. – Umair Aug 01 '17 at 04:35
  • What framework are you using to return these JSON messages? It doesn't seem like Node JS. Is your `return` object being processed correctly by whatever higher-level function is being used? – Nick Felker Aug 02 '17 at 00:20
  • I am using python (no framework) google home -> AWS API Gateway -> AWS lambda If this is an issue remaining skill will not be working. i am creating Google Home Smart Skill (**Thermostat**). I can change temperature, turn on/off, change mode, increase/decrease temperature everything is working fine except error response. I mean if device is offline i am returning `{ "requestId": "same as found in request", "payload": { "errorCode": "deviceTurnedOff" } }` I have tested json response with **Postman** also its same as define in doc – Umair Aug 02 '17 at 04:35
  • Looking at [the docs](http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html) for lambdas, I'm not sure that `self` is the appropriate variable to use to obtain values from a Smart Home request. You should be able to see the complete log of the output in the Lambda console. What does that look like? – Nick Felker Aug 02 '17 at 19:12
  • well sir! self in python means this class.I think you have no idea whats going on :) – Umair Aug 03 '17 at 04:18
  • I am not very familiar with lambdas or server-side Python, so I'm not sure exactly where the problem is coming from. Although it does not appear to be a problem with Smart Home specifically. – Nick Felker Aug 03 '17 at 19:08
  • Thanks for you help anyway :) – Umair Aug 04 '17 at 04:15