Home

@ShowFirstParty
@RequiresApi(value = 27)
class Home : HomeClient, TokenRefresh


Entry point for the Home API.

Summary

Constants

const String

Public companion functions

HomeClient
getClient(activity: Activity, homeConfig: HomeConfig)

Creates an instance of the Home API.

HomeClient
getClient(context: Context, homeConfig: HomeConfig)

Creates an instance of the Home API.

Public functions

open HomeObjectsFlow<HomeDevice>

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

open Flow<PermissionsState>

Checks if the client has permissions to home data.

open suspend String

Refreshes OAuth tokens for the currentAccount.

open Unit

Registers an ActivityResultCaller that can be used to launch permissions-related UIs.

open suspend PermissionsResult

Triggers the permission-granting flow, getting OAuth consent from the user and completing initialization if needed.

open HomeObjectsFlow<Room>

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

open HomeObjectsFlow<Structure>

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

Constants

TAG

const val TAGString

Public companion functions

getClient

fun getClient(activity: Activity, homeConfig: HomeConfig = HomeConfig()): HomeClient

Creates an instance of the Home API.

Parameters
activity: Activity

the app activity to use for the instance.

Returns
HomeClient

an instance of the Home API.

getClient

fun getClient(context: Context, homeConfig: HomeConfig = HomeConfig()): HomeClient

Creates an instance of the Home API.

Parameters
context: Context

the app context to use for the instance.

homeConfig: HomeConfig = HomeConfig()

configuration parameters for SDK behavior.

Returns
HomeClient

an instance of the Home API.

Public functions

devices

open fun devices(): HomeObjectsFlow<HomeDevice>

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

Returns
HomeObjectsFlow<HomeDevice>

a flow of HomeDevices.

hasPermissions

open fun hasPermissions(): Flow<PermissionsState>

Checks if the client has permissions to home data.

Returns
Flow<PermissionsState>

a flow of client permissions.

refreshToken

open suspend fun refreshToken(): String

Refreshes OAuth tokens for the currentAccount. If sdk is unable to fetch a new OAuth token, empty string is returned.

registerActivityResultCallerForPermissions

open fun registerActivityResultCallerForPermissions(
    permissionsLauncher: ActivityResultCaller
): Unit

Registers an ActivityResultCaller that can be used to launch permissions-related UIs.

Parameters
permissionsLauncher: ActivityResultCaller

the ActivityResultCaller to register.

requestPermissions

open suspend fun requestPermissions(forceLaunch: Boolean): PermissionsResult

Triggers the permission-granting flow, getting OAuth consent from the user and completing initialization if needed.

Parameters
forceLaunch: Boolean

When false, only launch UIs in the absence of a valid account and/or OAuth token for the account. When true, always launch the UIs in order to grant additional permissions (accounts and/or structures).

Returns
PermissionsResult

the result of the permission-granting flow.

rooms

open fun rooms(): HomeObjectsFlow<Room>

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

Returns
HomeObjectsFlow<Room>

a flow of Rooms.

structures

open fun structures(): HomeObjectsFlow<Structure>

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

Returns
HomeObjectsFlow<Structure>

a flow of Structures.