<br />

# CameraMotion Schema

[Nest Cam (legacy)](https://developers.google.com/nest/device-access/api/camera) [Nest Cam (outdoor or indoor, battery)](https://developers.google.com/nest/device-access/api/camera-battery) [Nest Cam with floodlight](https://developers.google.com/nest/device-access/api/camera-floodlight) [Nest Cam (indoor, wired)](https://developers.google.com/nest/device-access/api/camera-wired) [Nest Hub Max](https://developers.google.com/nest/device-access/api/display) [Nest Doorbell (legacy)](https://developers.google.com/nest/device-access/api/doorbell) [Nest Doorbell (battery)](https://developers.google.com/nest/device-access/api/doorbell-battery) [Nest Doorbell (wired)](https://developers.google.com/nest/device-access/api/doorbell-wired)

`sdm.devices.traits.CameraMotion`

This trait belongs to any device that supports motion detection events.

<br />

## Fields


There are no fields available for this trait.

<br />

## Commands

There are no commands available for this trait.

## Events

<br />

### Motion

[Updateable](https://developers.google.com/nest/device-access/api/events#updateable_notifications)

Motion has been detected by the camera.

This event supports updateable notifications. Existing app notifications created from this event can be updated using the content of an subsequent event with the same `eventThreadId`.

#### Motion event

### Payload

    {
      "eventId" : "12a0dca3-c060-4991-9701-3824f47a7f4d",
      "timestamp" : "2019-01-01T00:00:01Z",
      "resourceUpdate" : {
        "name" : "enterprises/project-id/devices/device-id",
        "events" : {
          "sdm.devices.events.CameraMotion.Motion" : {
            "eventSessionId" : "CjY5Y3VKaTZwR3o4Y19YbTVfMF...",
            "eventId" : "x-6TOHiOQfJwLapi8NgYIz__gg...",
          }
        }
      }
      "userId" : "AVPHwEuBfnPOnTqzVFT4IONX2Qqhu9EJ4ubO-bNnQ-yi",
      "eventThreadId" : "d67cd3f7-86a7-425e-8bb3-462f92ec9f59",
      "eventThreadState" : "STARTED",
      "resourceGroup" : [
        "enterprises/project-id/devices/device-id"
      ]
    }

#### Motion event fields

| Field | Description | Data Type |
|---|---|---|
| `eventSessionId` | [Nest Doorbell (battery)](https://developers.google.com/nest/device-access/api/doorbell-battery) [Nest Doorbell (wired)](https://developers.google.com/nest/device-access/api/doorbell-wired) An ID given to events occurring as part of a single session of related events. May be used for consolidating events. Use it to associate this event with the related [ClipPreview](https://developers.google.com/nest/device-access/traits/device/camera-clip-preview#clippreview) event of the CameraClipPreview trait. | `string` Example: "CjY5Y3VKaTZwR3o4Y19YbTVfMF..." |
| `eventId` | [Nest Cam (legacy)](https://developers.google.com/nest/device-access/api/camera) [Nest Hub Max](https://developers.google.com/nest/device-access/api/display) [Nest Doorbell (legacy)](https://developers.google.com/nest/device-access/api/doorbell) An ID associated with the event. Use it with the [GenerateImage command](https://developers.google.com/nest/device-access/traits/device/camera-event-image#generateimage) to download the camera image related to this event. | `string` Example: "x-6TOHiOQfJwLapi8NgYIz__gg..." |

#### Event payload fields

| Field | Description | Data Type |
|---|---|---|
| `eventId` | The unique identifier for the event. | `string` Example: "12a0dca3-c060-4991-9701-3824f47a7f4d" |
| `timestamp` | The time when the event occurred. | `string` Example: "2019-01-01T00:00:01Z" |
| `resourceUpdate` | An object that details information about the resource update. | `object` |
| `userId` | A unique, obfuscated identifier that represents the user. | `string` Example: "AVPHwEuBfnPOnTqzVFT4IONX2Qqhu9EJ4ubO-bNnQ-yi" |
| `eventThreadId` | [Updateable](https://developers.google.com/nest/device-access/api/events#updateable_notifications) The unique identifier for the event thread. | `string` Example: "d67cd3f7-86a7-425e-8bb3-462f92ec9f59" |
| `eventThreadState` | [Updateable](https://developers.google.com/nest/device-access/api/events#updateable_notifications) The state of the event thread. | `string` Values: "STARTED", "UPDATED", "ENDED" |
| `resourceGroup` | An object that indicates resources that might have similar updates to this event. The resource of the event itself (from the `resourceUpdate` object) will always be present in this object. | `object` |

See [Events](https://developers.google.com/nest/device-access/api/events) for more information on the different
types of events and how they work.

<br />


## Errors

The following error code(s) may be returned in relation to this trait:

| Error Message | RPC | Troubleshooting |
|---|---|---|
| Camera image is no longer available for download. | `DEADLINE_EXCEEDED` | Event images expire 30 seconds after the event is published. Make sure to download the image prior to expiration. |
| Event id does not belong to the camera. | `FAILED_PRECONDITION` | Use the correct `eventID` returned by the camera event. |

See the [API Error Code Reference](https://developers.google.com/nest/device-access/reference/errors/api) for
the full list of API error codes.

<br />