# HomeDevice


```
interface HomeDevice : HasId, HasTraits, HasDeviceTypes, HasConnectivityState, HasCandidates, HasCustomAppData, HasGenericTypes
```

<br />

*** ** * ** ***

A device supporting traits, commands, and subscriptions.

## Summary

| ### Public functions |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationPartPath?` | `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#automationPart(com.google.home.DeviceType)(deviceType: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType)` Returns a new `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationPartPath` with the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` added to the path. |
| `suspend https://developers.home.google.com/reference/kotlin/com/google/home/DecommissionEligibility` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#checkDecommissionEligibility()()` Checks if the device is eligible for decommissioning. |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/Id>` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#decommissionDevice()()` Initiates the decommissioning of this device. |
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/Id>` | `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#initiateDecommissioningWithConsent()()` Initiates the device decommissioning process with consent. |
| `suspend https://developers.home.google.com/reference/kotlin/com/google/home/Room?` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#room()()` Gets the up-to-date `https://developers.home.google.com/reference/kotlin/com/google/home/Room` this device is a part of. |
| `suspend https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#setName(kotlin.String)(newName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Sets the user-given name of this device. |
| `suspend https://developers.home.google.com/reference/kotlin/com/google/home/Structure?` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#structure()()` Gets the up-to-date `https://developers.home.google.com/reference/kotlin/com/google/home/Structure` this device is a part of. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#isMatterDevice()` If this device is backed by Matter. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#name()` The user-given name of this device. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/Id?` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#roomId()` The ID of the `https://developers.home.google.com/reference/kotlin/com/google/home/Room` this device is a part of. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/Id?` | `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#structureId()` The ID of the `https://developers.home.google.com/reference/kotlin/com/google/home/Structure` this device is a part of. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/Tag>>>` | `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#tags()` The tags on parts of this device. |

| ### Extension functions |
|---|---|
| `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice.https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#(com.google.home.HomeDevice).deleteHistory()()` Extension function to delete the history items for a device. |
| `suspend https://developers.home.google.com/reference/kotlin/com/google/home/HistoryItemsPage` | `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice.https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice#(com.google.home.HomeDevice).getHistoryItems(kotlin.Int)(pageSize: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` |

### Inherited functions

From [com.google.home.automation.HasCandidates](https://developers.home.google.com/reference/kotlin/com/google/home/automation/HasCandidates) `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/automation/NodeCandidate>>` `https://developers.home.google.com/reference/kotlin/com/google/home/automation/HasCandidates#allCandidates()()`

Returns all the automation `https://developers.home.google.com/reference/kotlin/com/google/home/automation/NodeCandidate` instances for the receiver and its child objects.
`https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/automation/NodeCandidate>>` `https://developers.home.google.com/reference/kotlin/com/google/home/automation/HasCandidates#candidates()()`

Returns all the automation `https://developers.home.google.com/reference/kotlin/com/google/home/automation/NodeCandidate` instances for the receiver.
From [com.google.home.HasCustomAppData](https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData) `suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#deleteValue(kotlin.String)(key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`

Deletes the value associated with the given `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#deleteValue(kotlin.String)`.
`suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#getValue(kotlin.String)(key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`

Retrieves the value associated with the given `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#getValue(kotlin.String)`.
`suspend https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#updateValue(kotlin.String,kotlin.String)(key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`

Updates the value associated with the given `https://developers.home.google.com/reference/kotlin/com/google/home/HasCustomAppData#updateValue(kotlin.String,kotlin.String)`.
From [com.google.home.HasDeviceTypes](https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes) `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` `<T : https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType> https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#has(com.google.home.DeviceTypeFactory)(type: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<T>)`

Checks if a device type is supported by this device.
`open https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T>` `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi
<T : https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType> https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#part(com.google.home.DeviceTypeFactory,kotlin.Array)(type: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<T>, vararg tags: https://developers.home.google.com/reference/kotlin/com/google/home/Tag)`

Gets a flow on the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` using the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory` and `https://developers.home.google.com/reference/kotlin/com/google/home/Tag`.
`open https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T?>` `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi
<T : https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType> https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#partOrNull(com.google.home.DeviceTypeFactory,kotlin.Array)(type: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<T>, vararg tags: https://developers.home.google.com/reference/kotlin/com/google/home/Tag)`

Gets a flow on the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` using the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory` and `https://developers.home.google.com/reference/kotlin/com/google/home/Tag`.
`open https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>>` `@https://developers.home.google.com/reference/kotlin/com/google/home/annotation/HomeExperimentalApi
https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#parts()()`

Gets a flow on the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType`s that are parts of this `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice`.
`https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T>` `<T : https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType> https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#type(com.google.home.DeviceTypeFactory,kotlin.Array)(type: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<T>, vararg tags: https://developers.home.google.com/reference/kotlin/com/google/home/Tag)`

Gets a flow on the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` using the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory`.
`https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T?>` `<T : https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType> https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#typeOrNull(com.google.home.DeviceTypeFactory,kotlin.Array)(type: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<T>, vararg tags: https://developers.home.google.com/reference/kotlin/com/google/home/Tag)`

Gets a flow on the `DeviceType` using the given `DeviceTypeFactory`.
`https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>>` `https://developers.home.google.com/reference/kotlin/com/google/home/HasDeviceTypes#types()()`

Gets a list of all available types on the `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice`.
From [com.google.home.HasGenericTypes](https://developers.home.google.com/reference/kotlin/com/google/home/HasGenericTypes) `https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/GenericDeviceType>>` `https://developers.home.google.com/reference/kotlin/com/google/home/HasGenericTypes#genericTypes()()` From [com.google.home.HasTraits](https://developers.home.google.com/reference/kotlin/com/google/home/HasTraits) `https://developers.home.google.com/reference/kotlin/com/google/home/SourceConnectivity?` `<T : https://developers.home.google.com/reference/kotlin/com/google/home/Trait> https://developers.home.google.com/reference/kotlin/com/google/home/HasTraits#getSourceConnectivity(com.google.home.TraitFactory)(trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<T>)`

Gets metadata, such as network locality and connectivity state, about the source of data for a particular trait.
`https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` `<T : https://developers.home.google.com/reference/kotlin/com/google/home/Trait> https://developers.home.google.com/reference/kotlin/com/google/home/HasTraits#has(com.google.home.TraitFactory)(trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<T>)`

Checks if a trait is supported by a device.

### Inherited properties

From [com.google.home.HasConnectivityState](https://developers.home.google.com/reference/kotlin/com/google/home/HasConnectivityState) `https://developers.home.google.com/reference/kotlin/com/google/home/SourceConnectivity` `https://developers.home.google.com/reference/kotlin/com/google/home/HasConnectivityState#sourceConnectivity()`

Source Connectivity for the device.
From [com.google.home.HasId](https://developers.home.google.com/reference/kotlin/com/google/home/HasId) `https://developers.home.google.com/reference/kotlin/com/google/home/Id` `https://developers.home.google.com/reference/kotlin/com/google/home/HasId#id()`

Opaque ID for the object.

## Public functions

### automationPart

```
@HomeExperimentalApi
fun automationPart(deviceType: DeviceType): AutomationPartPath?
```

Returns a new `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationPartPath` with the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` added to the path.

| Parameters |
|---|---|
| `deviceType: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` | the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` to add to the path. |

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationPartPath?` | a new `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationPartPath` with the given `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` added to the path, or null if the device type is not found in the path. |

### checkDecommissionEligibility

```
suspend fun checkDecommissionEligibility(): DecommissionEligibility
```

Checks if the device is eligible for decommissioning.

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/DecommissionEligibility` | a data class representing the device's eligibility for decommissioning. |

### decommissionDevice

```
suspend fun decommissionDevice(): Set<Id>
```

Initiates the decommissioning of this device. Throws an exception if the device is not eligible for decommissioning.

If the device requires consent for decommissioning (e.g. some cameras), this method will automatically initiate the consent flow and retry if consent is granted.

| Returns |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/Id>` | the set of device IDs that were affected by the decommissioning of this device. |

### initiateDecommissioningWithConsent

```
@HomeExperimentalApi
suspend fun initiateDecommissioningWithConsent(): Set<Id>
```

Initiates the device decommissioning process with consent. Opens a Google-hosted consent WebView and calls standard Matter decommission trait.

| Returns |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://developers.home.google.com/reference/kotlin/com/google/home/Id>` | the set of device IDs that were affected by the decommissioning. |

| Throws |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeException` | if the device is not eligible for decommissioning or the decommissioning process fails due to other reasons such as invalid/missing consent token. |

### room

```
suspend fun room(): Room?
```

Gets the up-to-date `https://developers.home.google.com/reference/kotlin/com/google/home/Room` this device is a part of.

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/Room?` | the Room this device is a part of, or null if the device is not in a Room. |

### setName

```
suspend fun setName(newName: String): HomeDevice
```

Sets the user-given name of this device.

| Parameters |
|---|---|
| `newName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | the new name for this device. |

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice` | an updated `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice`, with the new name, or previous name if the update failed. |

| Throws |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeException` | if the update failed. |
| `CancellationException` | if the update is cancelled. |

### structure

```
suspend fun structure(): Structure?
```

Gets the up-to-date `https://developers.home.google.com/reference/kotlin/com/google/home/Structure` this device is a part of.

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/Structure?` | the Structure this device is a part of, or null if the device is not in a Structure. |

## Public properties

### isMatterDevice

```
val isMatterDevice: Boolean
```

If this device is backed by Matter.

### name

```
val name: String
```

The user-given name of this device.

### roomId

```
val roomId: Id?
```

The ID of the `https://developers.home.google.com/reference/kotlin/com/google/home/Room` this device is a part of. Null if the device is not in a Room.

### structureId

```
val structureId: Id?
```

The ID of the `https://developers.home.google.com/reference/kotlin/com/google/home/Structure` this device is a part of. Null if the device is not in a Structure.

### tags

```
@HomeExperimentalApi
val tags: Map<DeviceTypeFactory<DeviceType>, List<Set<Tag>>>
```

The tags on parts of this device. A device can have multiple parts with same type but different tags. This allows us to identify the part by tags. Key is the `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory` of the part, and the value is a list of `https://developers.home.google.com/reference/kotlin/com/google/home/PartTags` which can be used to uniquely identify a part.

## Extension functions

### deleteHistory

```
@HomeExperimentalApi
suspend fun HomeDevice.deleteHistory(): Unit
```

Extension function to delete the history items for a device.

### getHistoryItems

```
@HomeExperimentalApi
suspend fun HomeDevice.getHistoryItems(pageSize: Int = 20): HistoryItemsPage
```