# Smart Home OccupancySensing Trait Schema

`action.devices.traits.OccupancySensing` - This trait belongs to devices that can detect occupancy, whether through PIR, ultrasonic, or physical contact sensing.

## Device ATTRIBUTES

Devices with this trait may report the following
attributes as part of the [`SYNC`](https://developers.home.google.com/cloud-to-cloud/intents/sync) operation. To learn
more about handling `SYNC` intents, see
[Intent fulfillment](https://developers.home.google.com/cloud-to-cloud/integration/sync).

| Attributes | Type | Description |
|---|---|---|
| `occupancySensorConfiguration` | *Array* | A list of objects, each containing the sensor type and its associated delays and event threshold. |
| `[*item, ...*]` | *Object* | A sensor type and its associated delays and event threshold, if applicable. |
| `occupancySensorType` | *String* | **Required.** <br /> Supported values: `PIR` :   The device supports sensing occupancy through passive infrared (PIR) sensing. `ULTRASONIC` :   The device supports sensing occupancy through ultrasonic sensing. `PHYSICAL_CONTACT` :   The device supports occupancy through physical contact sensing. |
| `occupiedToUnoccupiedDelaySec` | *Integer* | Represents the time delay, in seconds, before the reported occupancy changes to an unoccupied state after the last detected event. |
| `unoccupiedToOccupiedDelaySec` | *Integer* | Represents the time delay, in seconds, before the reported occupancy changes to an occupied state after the last detected event. Required if `occupiedToUnoccupiedDelaySec` is set. |
| `unoccupiedToOccupiedEventThreshold` | *Integer* | Specifies the number of detection events that must occur in the `unoccupiedToOccupiedDelaySec` period before the reported occupancy changes to an occupied state. Required if `unoccupiedToOccupiedDelaySec` is set. |

#### Examples

*Occupancy sensor which supports PIR and ultrasonic sensing.*

```
{
  "occupancySensorConfiguration": [
    {
      "occupancySensorType": "PIR",
      "occupiedToUnoccupiedDelaySec": 10,
      "unoccupiedToOccupiedDelaySec": 10,
      "unoccupiedToOccupiedEventThreshold": 2
    },
    {
      "occupancySensorType": "ULTRASONIC",
      "occupiedToUnoccupiedDelaySec": 10,
      "unoccupiedToOccupiedDelaySec": 10,
      "unoccupiedToOccupiedEventThreshold": 2
    }
  ]
}
```

## Device STATES

Entities with this trait may report the following
states as part of the [`QUERY`](https://developers.home.google.com/cloud-to-cloud/intents/query) operation. To learn
more about handling `QUERY` intents, see
[Intent fulfillment](https://developers.home.google.com/cloud-to-cloud/integration/query-execute).

| States | Type | Description |
|---|---|---|
| `occupancy` | *String* | **Required.** Indicates whether the device senses occupancy. Supported values: `OCCUPIED` :   The device detects occupancy. `UNOCCUPIED` :   The device does not detect occupancy. `UNKNOWN_OCCUPANCY_STATE` :   The current occupancy state detected by the device is unknown. |

#### Examples

*Does the sensor detect occupancy in the office?*

```
{
  "occupancy": "OCCUPIED"
}
```

## Device COMMANDS

None.

## Device ERRORS

See the full list of [errors and exceptions](https://developers.home.google.com/cloud-to-cloud/intents/errors-exceptions).