Skip to content

Instantly share code, notes, and snippets.

@andrew-malitchuk
Created July 19, 2025 16:47
Show Gist options
  • Select an option

  • Save andrew-malitchuk/ec50ba29ed9a880ba4f5ab5fa5a74c54 to your computer and use it in GitHub Desktop.

Select an option

Save andrew-malitchuk/ec50ba29ed9a880ba4f5ab5fa5a74c54 to your computer and use it in GitHub Desktop.
class Configure {
companion object {
// List of supported device types by this app:
val supportedTypes: List<DeviceTypeFactory<out DeviceType>> = listOf(
ContactSensorDevice,
ColorTemperatureLightDevice,
DimmableLightDevice,
AirPurifierDevice,
ExtendedColorLightDevice,
GenericSwitchDevice,
GoogleDisplayDevice,
GoogleTVDevice,
OccupancySensorDevice,
OnOffLightDevice,
OnOffLightSwitchDevice,
OnOffPluginUnitDevice,
OnOffSensorDevice,
RootNodeDevice,
SpeakerDevice,
ThermostatDevice,
GoogleAirCoolerDevice,
RoomAirConditionerDevice
)
// List of supported device traits by this app:
val supportedTraits: List<TraitFactory<out Trait>> = listOf(
AreaAttendanceState,
AreaPresenceState,
Assistant,
AssistantBroadcast,
AssistantFulfillment,
BasicInformation,
BooleanState,
OccupancySensing,
OnOff,
Notification,
LevelControl,
TemperatureControl,
TemperatureMeasurement,
Thermostat,
Time,
Volume,
ExtendedFanControl,
ExtendedThermostat
)
}
}
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
val factoryRegistry = FactoryRegistry(
types = supportedTypes,
traits = supportedTraits
)
val config = HomeConfig(
coroutineContext = Dispatchers.IO,
factoryRegistry = factoryRegistry
)
val homeClient = Home.getClient(context = this@MainActivity, homeConfig = config)
homeClient.registerActivityResultCallerForPermissions(this@MainActivity)
setContent {
App()
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment