# HasTraits

# HasTraits


```
interface HasTraits
```

<br />

Known direct subclasses [HomeDevice](https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice), [Structure](https://developers.home.google.com/reference/kotlin/com/google/home/Structure)

|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/HomeDevice` | A device supporting traits, commands, and subscriptions. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/Structure` | The top-level organizing construct for the `https://developers.home.google.com/reference/kotlin/com/google/home/Home`. |

*** ** * ** ***

An entity with associated traits and trait metadata.

## Summary

| ### Public functions |
|---|---|
| `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. |

## Public functions

### getSourceConnectivity

```
fun <T : Trait> getSourceConnectivity(trait: TraitFactory<T>): SourceConnectivity?
```

Gets metadata, such as network locality and connectivity state, about the source of data for a particular trait.

| Parameters |
|---|---|
| `trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<T>` | the factory for the trait. |

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/SourceConnectivity?` | the trait's data source metadata, or null if metadata is not available or this object does not have the trait. |

### has

```
fun <T : Trait> has(trait: TraitFactory<T>): Boolean
```

Checks if a trait is supported by a device.

When building the device object, the list of supported traits and types is available during initialization. This list is used to verify support.

For example:

```kotlin
device.has(OnOff)
```

| Parameters |
|---|---|
| `trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<T>` | the `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` to check for. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | true if the device supports the Trait, false otherwise. |