# HomeGraph API . devices

## Instance Methods

Gets the current states in Home Graph for the given set of the third-party

Reports device state and optionally sends device notifications.

Requests Google to send an `action.devices.SYNC`

Gets all the devices associated with the given third-party user.

### Method Details

`query(body=None, x__xgafv=None)`

    Gets the current states in Home Graph for the given set of the third-party
    user's devices.

    The third-party user's identity is passed in via the `agent_user_id`
    (see QueryRequest).
    This request must be authorized using service account credentials from your
    Actions console project.

    Args:
      body: object, The request body.
        The object takes the form of:

    { # Request type for the
          # [`Query`](#google.home.graph.v1.HomeGraphApiService.Query) call.
        "requestId": "A String", # Request ID used for debugging.
        "agentUserId": "A String", # Required. Third-party user ID.
        "inputs": [ # Required. Inputs containing third-party device IDs for which to
            # get the device states.
          { # Device ID inputs to QueryRequest.
            "payload": { # Payload containing device IDs. # Payload containing third-party device IDs.
              "devices": [ # Third-party device IDs for which to get the device states.
                { # Third-party device ID for one device.
                  "id": "A String", # Third-party device ID.
                },
              ],
            },
          },
        ],
      }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response type for the
          # [`Query`](#google.home.graph.v1.HomeGraphApiService.Query) call.
          # This should follow the same format as the Google smart home
          # `action.devices.QUERY`
          # [response](https://developers.google.com/assistant/smarthome/reference/intent/query).
          # # Example
          #
          # ```json
          # {
          #   "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
          #   "payload": {
          #     "devices": {
          #       "123": {
          #         "on": true,
          #         "online": true
          #       },
          #       "456": {
          #         "on": true,
          #         "online": true,
          #         "brightness": 80,
          #         "color": {
          #           "name": "cerulean",
          #           "spectrumRGB": 31655
          #         }
          #       }
          #     }
          #   }
          # }
          # ```
        "requestId": "A String", # Request ID used for debugging. Copied from the request.
        "payload": { # Payload containing device states information. # Device states for the devices given in the request.
          "devices": { # States of the devices. Map of third-party device ID to struct of device
              # states.
            "a_key": {
              "a_key": "", # Properties of the object.
            },
          },
        },
      }

`reportStateAndNotification(body=None, x__xgafv=None)`

    Reports device state and optionally sends device notifications.
    Called by your smart home Action when the state of a third-party device
    changes or you need to send a notification about the device.
    See [Implement Report
    State](https://developers.google.com/assistant/smarthome/develop/report-state)
    for more information.

    This method updates the device state according to its declared
    [traits](https://developers.google.com/assistant/smarthome/concepts/devices-traits).
    Publishing a new state value outside of these traits will result in an
    `INVALID_ARGUMENT` error response.

    The third-party user's identity is passed in via the `agent_user_id`
    (see ReportStateAndNotificationRequest).
    This request must be authorized using service account credentials from your
    Actions console project.

    Args:
      body: object, The request body.
        The object takes the form of:

    { # Request type for the
          # [`ReportStateAndNotification`](#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification)
          # call. It may include states, notifications, or both. States and notifications
          # are defined per `device_id` (for example, "123" and "456" in the following
          # example).
          # # Example
          #
          # ```json
          # {
          #   "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
          #   "agentUserId": "1234",
          #   "payload": {
          #     "devices": {
          #       "states": {
          #         "123": {
          #           "on": true
          #         },
          #         "456": {
          #           "on": true,
          #           "brightness": 10
          #         }
          #       },
          #     }
          #   }
          # }
          # ```
        "agentUserId": "A String", # Required. Third-party user ID.
        "payload": { # Payload containing the state and notification information for devices. # Required. State of devices to update and notification metadata for devices.
          "devices": { # The states and notifications specific to a device. # The devices for updating state and sending notifications.
            "states": { # States of devices to update. See the **Device STATES** section
                # of the individual trait [reference
                # guides](https://developers.google.com/assistant/smarthome/traits).
              "a_key": "", # Properties of the object.
            },
            "notifications": { # Notifications metadata for devices. See the **Device NOTIFICATIONS**
                # section of the individual trait [reference
                # guides](https://developers.google.com/assistant/smarthome/traits).
              "a_key": "", # Properties of the object.
            },
          },
        },
        "requestId": "A String", # Request ID used for debugging.
        "followUpToken": "A String", # Token to maintain state in the follow up notification response.
            # Deprecated. See the [notifications
            # guide](https://developers.google.com/assistant/smarthome/develop/notifications)
            # for details on implementing follow up notifications.
        "eventId": "A String", # Unique identifier per event (for example, a doorbell press).
      }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response type for the
          # [`ReportStateAndNotification`](#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification)
          # call.
        "requestId": "A String", # Request ID copied from ReportStateAndNotificationRequest.
      }

`requestSync(body=None, x__xgafv=None)`

    Requests Google to send an `action.devices.SYNC`
    [intent](https://developers.google.com/assistant/smarthome/reference/intent/sync)
    to your smart home Action to update device metadata for the given user.

    The third-party user's identity is passed via the `agent_user_id`
    (see RequestSyncDevicesRequest).
    This request must be authorized using service account credentials from your
    Actions console project.

    Args:
      body: object, The request body.
        The object takes the form of:

    { # Request type for the
          # [`RequestSyncDevices`](#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices)
          # call.
        "async": True or False, # Optional. If set, the request will be added to a queue and a response will
            # be returned immediately. This enables concurrent requests for the given
            # `agent_user_id`, but the caller will not receive any error responses.
        "agentUserId": "A String", # Required. Third-party user ID.
      }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response type for the
          # [`RequestSyncDevices`](#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices)
          # call.
          #
          # Intentionally empty upon success. An HTTP response code is returned
          # with more details upon failure.
      }

`sync(body=None, x__xgafv=None)`

    Gets all the devices associated with the given third-party user.

    The third-party user's identity is passed in via the `agent_user_id`
    (see SyncRequest).
    This request must be authorized using service account credentials from your
    Actions console project.

    Args:
      body: object, The request body.
        The object takes the form of:

    { # Request type for the [`Sync`](#google.home.graph.v1.HomeGraphApiService.Sync)
          # call.
        "agentUserId": "A String", # Required. Third-party user ID.
        "requestId": "A String", # Request ID used for debugging.
      }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response type for the
          # [`Sync`](#google.home.graph.v1.HomeGraphApiService.Sync) call.
          # This should follow the same format as the Google smart home
          # `action.devices.SYNC`
          # [response](https://developers.google.com/assistant/smarthome/reference/intent/sync).
          # # Example
          #
          # ```json
          # {
          #   "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
          #   "payload": {
          #     "agentUserId": "1836.15267389",
          #     "devices": [{
          #       "id": "123",
          #       "type": "action.devices.types.OUTLET",
          #       "traits": [
          #         "action.devices.traits.OnOff"
          #       ],
          #       "name": {
          #         "defaultNames": ["My Outlet 1234"],
          #         "name": "Night light",
          #         "nicknames": ["wall plug"]
          #       },
          #       "willReportState": false,
          #       "deviceInfo": {
          #         "manufacturer": "lights-out-inc",
          #         "model": "hs1234",
          #         "hwVersion": "3.2",
          #         "swVersion": "11.4"
          #       },
          #       "customData": {
          #         "fooValue": 74,
          #         "barValue": true,
          #         "bazValue": "foo"
          #       }
          #     }]
          #   }
          # }
          # ```
        "payload": { # Payload containing device information. # Devices associated with the third-party user.
          "devices": [ # Devices associated with the third-party user.
            { # Third-party device definition.
              "structureHint": "A String", # Suggested name for the structure where this device is installed.
                  # Google attempts to use this value during user setup.
              "name": { # Identifiers used to describe the device. # Names given to this device by your smart home Action.
                "defaultNames": [ # List of names provided by the manufacturer rather than the user, such as
                    # serial numbers, SKUs, etc.
                  "A String",
                ],
                "nicknames": [ # Additional names provided by the user for the device.
                  "A String",
                ],
                "name": "A String", # Primary name of the device, generally provided by the user.
              },
              "notificationSupportedByAgent": True or False, # Indicates whether your smart home Action will report notifications
                  # to Google for this device via
                  # ReportStateAndNotification.
                  #
                  # If your smart home Action enables users to control device notifications,
                  # you should update this field and call
                  # RequestSyncDevices.
              "otherDeviceIds": [ # Alternate IDs associated with this device.
                  # This is used to identify cloud synced devices enabled for [local
                  # fulfillment](https://developers.google.com/assistant/smarthome/concepts/local).
                { # Alternate third-party device ID.
                  "agentId": "A String", # Project ID for your smart home Action.
                  "deviceId": "A String", # Unique third-party device ID.
                },
              ],
              "type": "A String", # Hardware type of the device.
                  # See [device
                  # types](https://developers.google.com/assistant/smarthome/guides).
              "attributes": { # Attributes for the traits supported by the device.
                "a_key": "", # Properties of the object.
              },
              "roomHint": "A String", # Suggested name for the room where this device is installed.
                  # Google attempts to use this value during user setup.
              "id": "A String", # Third-party device ID.
              "deviceInfo": { # Device information. # Device manufacturer, model, hardware version, and software version.
                "hwVersion": "A String", # Device hardware version.
                "swVersion": "A String", # Device software version.
                "manufacturer": "A String", # Device manufacturer.
                "model": "A String", # Device model.
              },
              "willReportState": True or False, # Indicates whether your smart home Action will report state of this device
                  # to Google via
                  # ReportStateAndNotification.
              "customData": { # Custom device attributes stored in Home Graph and provided to your
                  # smart home Action in each
                  # [QUERY](https://developers.google.com/assistant/smarthome/reference/intent/query)
                  # and
                  # [EXECUTE](https://developers.google.com/assistant/smarthome/reference/intent/execute)
                  # intent.
                "a_key": "", # Properties of the object.
              },
              "traits": [ # Traits supported by the device.
                  # See [device
                  # traits](https://developers.google.com/assistant/smarthome/traits).
                "A String",
              ],
            },
          ],
          "agentUserId": "A String", # Third-party user ID
        },
        "requestId": "A String", # Request ID used for debugging. Copied from the request.
      }