HasTraits

interface HasTraits

Known direct subclasses
HomeDevice

A device supporting traits, commands, and subscriptions.

Structure

The top-level organizing construct for the Home.


An entity with associated traits and trait metadata.

Summary

Public functions

SourceConnectivity?

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

Boolean
<T : Trait> has(trait: 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: TraitFactory<T>

the factory for the trait.

Returns
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:

device.has(OnOff)
Parameters
trait: TraitFactory<T>

the Trait to check for.

Returns
Boolean

true if the device supports the Trait, false otherwise.