# MatterTraitImpl

# MatterTraitImpl


```
abstract class MatterTraitImpl : MatterTrait, TraitStateInvalidation
```

<br />

*** ** * ** ***

Extends the Trait interface to add the implementation details needed for all traits.

## Summary

| ### Public constructors |
|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#MatterTraitImpl(com.google.home.Trait.TraitMetadata,com.google.home.matter.MatterTraitClient)(metadata: https://developers.home.google.com/reference/kotlin/com/google/home/Trait.TraitMetadata, client: https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitClient)` |

| ### Public functions |
|---|---|
| `ObjectCommand` | `<REQUEST : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?> https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#createObjectCommand(com.google.home.matter.serialization.ScopedCommandId,kotlin.Any,com.google.home.matter.serialization.StructAdapter,kotlin.Boolean)( commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId, request: REQUEST, requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>, useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html )` Create an ObjectCommand to be used for batching |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `<REQUEST : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?> https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#sendCommand(com.google.home.matter.serialization.ScopedCommandId,kotlin.Any,com.google.home.matter.serialization.StructAdapter,kotlin.Boolean)( commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId, request: REQUEST, requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>, useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html )` Send Command |
| `suspend RESPONSE` | `<REQUEST : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?, RESPONSE : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?> https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#sendCommand(com.google.home.matter.serialization.ScopedCommandId,kotlin.Any,com.google.home.matter.serialization.StructAdapter,com.google.home.matter.serialization.StructAdapter,kotlin.Boolean)( commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId, request: REQUEST, requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>, responseAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<RESPONSE>, useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html )` Send Command and parse the response |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?> https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#write(com.google.home.matter.serialization.StructAdapter,kotlin.Any,kotlin.Boolean)( adapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<T>, attributes: T, useTimedInteraction: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html )` |

| ### Public properties |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitClient` | `https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#client()` a client for sending data to a trait |
| `open https://developers.home.google.com/reference/kotlin/com/google/home/Trait.TraitMetadata` | `https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitImpl#metadata()` |

| ### Inherited functions |
|---|
| From [com.google.home.TraitStateInvalidation](https://developers.home.google.com/reference/kotlin/com/google/home/TraitStateInvalidation) |---|---| | `open suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/TraitStateInvalidation#forceRead()()` | |

| ### Inherited properties |
|---|
| From [com.google.home.Trait](https://developers.home.google.com/reference/kotlin/com/google/home/Trait) |---|---| | `abstract https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | `https://developers.home.google.com/reference/kotlin/com/google/home/Trait#factory()` | |

## Public constructors

### MatterTraitImpl

```
MatterTraitImpl(metadata: Trait.TraitMetadata, client: MatterTraitClient)
```

| Parameters |
|---|---|
| `client: https://developers.home.google.com/reference/kotlin/com/google/home/matter/MatterTraitClient` | a client for sending data to a trait |

## Public functions

### createObjectCommand

```
fun <REQUEST : Any?> createObjectCommand(
    commandId: ScopedCommandId,
    request: REQUEST,
    requestAdapter: StructAdapter<REQUEST>,
    useTimedCommand: Boolean = false
): ObjectCommand
```

Create an ObjectCommand to be used for batching

| Parameters |
|---|---|
| `commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId` | The Command Your Batching |
| `request: REQUEST` | the request object |
| `requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>` | the adapter to serialize the request |
| `useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html = false` | Flag to indicate if a command is a Timed Command. |

### sendCommand

```
suspend fun <REQUEST : Any?> sendCommand(
    commandId: ScopedCommandId,
    request: REQUEST,
    requestAdapter: StructAdapter<REQUEST>,
    useTimedCommand: Boolean = false
): Unit
```

Send Command

| Parameters |
|---|---|
| `commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId` | The Command Your Sending |
| `request: REQUEST` | the request object |
| `requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>` | the adapter to serialize the request |
| `useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html = false` | Flag to indicate if a command is a Timed Command. |

### sendCommand

```
suspend fun <REQUEST : Any?, RESPONSE : Any?> sendCommand(
    commandId: ScopedCommandId,
    request: REQUEST,
    requestAdapter: StructAdapter<REQUEST>,
    responseAdapter: StructAdapter<RESPONSE>,
    useTimedCommand: Boolean = false
): RESPONSE
```

Send Command and parse the response

| Parameters |
|---|---|
| `commandId: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/ScopedCommandId` | The Command Your Sending |
| `request: REQUEST` | the request object |
| `requestAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<REQUEST>` | the adapter to serialize the request |
| `responseAdapter: https://developers.home.google.com/reference/kotlin/com/google/home/matter/serialization/StructAdapter<RESPONSE>` | the adapter to deserialize the response |
| `useTimedCommand: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html = false` | Flag to indicate if a command is a Timed Command. |

| Returns |
|---|---|
| `RESPONSE` | the response |

### write

```
suspend fun <T : Any?> write(
    adapter: StructAdapter<T>,
    attributes: T,
    useTimedInteraction: Boolean
): Unit
```

## Public properties

### client

```
val client: MatterTraitClient
```

a client for sending data to a trait

### metadata

```
open val metadata: Trait.TraitMetadata
```