Structure

interface Structure : HasId, HasHomeDevices, HasRooms, HasTraits, HasAutomations, HasCandidates, HasSuggestions


The top-level organizing construct for the Home. A Structure allows navigating to all the Rooms and devices (HomeDevice or MatterNode) within that Structure that a caller has permission to access. Each Structure can have a single Google Matter Fabric.

Summary

Public functions

Flow<T>

Gets a Flow that can be used to track changes to a specific Trait.

Public properties

String

User-given name for the Structure.

Extension functions

Flow<Set<DeviceTypeFactory<DeviceType>>>

Gets an observable flow indicating the device types for which the user has consented for the app.

Flow<Map<FeatureConsentTypeConsentStatus>>

Gets an observable flow indicating the feature consent status for the structure.

suspend UserMetadataTrait.UserMetadataValues?

Fetches signed-in user metadata.

suspend Unit

Initiate a link to the 3P cloud.

suspend Unit

Set the current structure as the default for the user's devices.

suspend Room

Create a Room within a Structure.

suspend Unit

Delete a Room within a Structure, based on the Room's ID.

suspend Unit

Delete a Room within a Structure.

suspend Unit
Structure.moveDevicesToRoom(roomId: Id, deviceIds: List<Id>)

Move HomeDevice devices to a different Room within a Structure, based on IDs.

suspend Unit

Move HomeDevice devices to a different Room within a Structure.

TypedExpression<TypedEntity<StructureType>>

An extension function of Structure that produces a TypedExpression of structure entity.

suspend Unit

Extension function to delete the history items with the given event type IDs for the structure.

HistoryManager

Extension function to get the history manager for a structure.

HomeBriefsManager

Extension function to get the home briefs manager for a structure.

Flow<UserPresenceSettings>

Gets an observable flow indicating the user presence settings for the structure.

Inherited functions

From com.google.home.automation.HasAutomations
HomeObjectsFlow<Automation>

List all automations belonging to the structure.

suspend Automation

Create an Automation.

suspend Unit

Delete an Automation.

suspend Unit
deleteAutomation(automationId: Id)

Delete an Automation using an ID.

From com.google.home.automation.HasCandidates
Flow<Set<NodeCandidate>>

Returns all the automation NodeCandidate instances for the receiver and its child objects.

Flow<Set<NodeCandidate>>

Returns all the automation NodeCandidate instances for the receiver.

From com.google.home.HasHomeDevices
HomeObjectsFlow<HomeDevice>
devices(enableMultipartDevices: Boolean)

Gets an observable flow of HomeDevices visible to the logged-in user, dependent on the context of the implementation (HomeManager, Structure, Room).

From com.google.home.HasRooms
HomeObjectsFlow<Room>

Gets an observable flow of Rooms visible to the logged-in user.

From com.google.home.automation.HasSuggestions
suspend Boolean

Clears the suggestion feedback for the given suggestionId.

suspend Boolean
dislikeSuggestion(suggestionId: String)

Dislikes the AutomationSuggestion with the given suggestionId.

suspend Boolean
likeSuggestion(suggestionId: String)

Likes the AutomationSuggestion with the given suggestionId.

suspend Set<AutomationSuggestion>

Returns all the AutomationSuggestion instances for the receiver.

From com.google.home.HasTraits
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.

Inherited properties

From com.google.home.HasId
Id

Opaque ID for the object.

Public functions

trait

@HomeExperimentalApi
fun <T : Trait> trait(trait: TraitFactory<T>): Flow<T>

Gets a Flow that can be used to track changes to a specific Trait. When a value is emitted on this Flow it represents a snapshot of the latest Trait attributes.

For example:

structure.trait(HubManagement)
Parameters
trait: TraitFactory<T>

the Trait to get a flow for.

Returns
Flow<T>

the flow for the specified Trait, otherwise an empty flow if the Trait is not supported by the structure.

Public properties

name

val nameString

User-given name for the Structure. Empty if not assigned.

Extension functions

consentedDeviceTypes

@HomeExperimentalApi
fun Structure.consentedDeviceTypes(): Flow<Set<DeviceTypeFactory<DeviceType>>>

Gets an observable flow indicating the device types for which the user has consented for the app.

Returns
Flow<Set<DeviceTypeFactory<DeviceType>>>

a flow of ConsentedDeviceTypesData.

featureConsentStatus

@HomeExperimentalApi
fun Structure.featureConsentStatus(): Flow<Map<FeatureConsentTypeConsentStatus>>

Gets an observable flow indicating the feature consent status for the structure.

Returns
Flow<Map<FeatureConsentTypeConsentStatus>>

a flow of maps, where each map is from a FeatureConsentType to its corresponding ConsentStatus.

fetchUserMetadata

@HomeExperimentalApi
suspend fun Structure.fetchUserMetadata(): UserMetadataTrait.UserMetadataValues?

Fetches signed-in user metadata.

Returns
UserMetadataTrait.UserMetadataValues?

a UserMetadata object containing the user's metadata.

initiateCloudLink

suspend fun Structure.initiateCloudLink(oauthCode: String): Unit

Initiate a link to the 3P cloud. Uses the current structure as the default for new devices.

Parameters
oauthCode: String

The OAuth authorization code which is short-lived and used to start an exchange for the Refresh/Access tokens. It originates from the calling app's OAuth server, provided by the app to the SDK.

Throws
com.google.home.HomeException

if the operation did not succeed. HomeException has suberrors to detail the specific error message and code.

setAsCloudLinkDefault

suspend fun Structure.setAsCloudLinkDefault(): Unit

Set the current structure as the default for the user's devices. This structure will be used anytime a new device is received via the cloud sync, as long as the sync response does not specify a structure explicitly.

Throws
com.google.home.HomeException

if the operation did not succeed. HomeException has suberrors to detail the specific error message and code.

createRoom

suspend fun Structure.createRoom(name: String): Room

Create a Room within a Structure.

Parameters
name: String

the name of the Room to create.

Returns
Room

the newly created Room.

deleteRoom

suspend fun Structure.deleteRoom(roomId: Id): Unit

Delete a Room within a Structure, based on the Room's ID.

Parameters
roomId: Id

the ID of the Room to delete.

deleteRoom

suspend fun Structure.deleteRoom(room: Room): Unit

Delete a Room within a Structure.

Parameters
room: Room

the Room to delete.

moveDevicesToRoom

suspend fun Structure.moveDevicesToRoom(roomId: Id, deviceIds: List<Id>): Unit

Move HomeDevice devices to a different Room within a Structure, based on IDs.

Parameters
roomId: Id

the ID of the Room to move devices to.

deviceIds: List<Id>

the list of device IDs for the HomeDevice devices to move.

moveDevicesToRoom

suspend fun Structure.moveDevicesToRoom(room: Room, devices: List<HomeDevice>): Unit

Move HomeDevice devices to a different Room within a Structure.

Parameters
room: Room

the Room to move devices to.

devices: List<HomeDevice>

the list of HomeDevice devices to move.

atExecutionTime

fun Structure.atExecutionTime(): TypedExpression<TypedEntity<StructureType>>

An extension function of Structure that produces a TypedExpression of structure entity.

deleteHistory

@HomeExperimentalApi
suspend fun Structure.deleteHistory(eventTypeIds: List<String>): Unit

Extension function to delete the history items with the given event type IDs for the structure.

getHistoryManager

@HomeExperimentalApi
fun Structure.getHistoryManager(pageSize: Int = 20): HistoryManager

Extension function to get the history manager for a structure.

getHomeBriefsManager

@HomeExperimentalApi
fun Structure.getHomeBriefsManager(): HomeBriefsManager

Extension function to get the home briefs manager for a structure.

userPresenceSettings

@HomeExperimentalApi
fun Structure.userPresenceSettings(): Flow<UserPresenceSettings>

Gets an observable flow indicating the user presence settings for the structure.