Hubs

Pre-requisite: The user has to be signed in to perform the following operations.

A hub is a device (device.deviceType == DeviceType.HUB.value) that other devices pair through. Those child devices carry the hub’s id in device.parentDeviceId. Hubs and their children have their own cluster endpoints, so use InstaVision.hubService for them instead of the deviceServices cluster calls.

  • Calls that take a child device need device.parentDeviceId; without it onError receives an ApiError with code "400" and no request is sent.
  • Writes wake the hub or child first when it is an MCU device (isMcuSupported); reads do not. See Battery.
  • Callbacks run on a background thread.

A hub pairs like a camera, over BLE — over Ethernet when its model’s pairingNetworks contains "Ethernet". See Pairing via BLE.


Get a hub’s clusters

  • hub (required): The hub device.
InstaVision.hubService.getHubClusters(
  hub = hub,
  onSuccess = { deviceCluster ->
    val alarmSync = deviceCluster.alarmSyncEnabled()
  },
  onError = { error ->
    // The error object contains the error code and message
  },
)

The returned DeviceCluster works with the same extensions as a camera’s — see Device Clusters.


Update a hub cluster

  • hub (required): The hub device.
  • clusterId (required): The id of the cluster to update.
  • request (required): UpdateClusterRequest with the attributes to write.
InstaVision.hubService.updateHubCluster(
  hub = hub,
  clusterId = DeviceClusterTypes.SecurityState.id,
  request = UpdateClusterRequest(
    attributes = listOf(
      UpdateClusterAttribute(id = ClusterAttributeTypes.AlarmSyncEnabled.id, value = true)
    )
  ),
  onSuccess = { response ->
    // response.cluster is the updated Cluster
  },
  onError = { error -> },
)

To write a single attribute use updateHubClusterAttribute:

InstaVision.hubService.updateHubClusterAttribute(
  hub = hub,
  clusterId = DeviceClusterTypes.SecurityState.id,
  attributeId = ClusterAttributeTypes.AlarmSyncEnabled.id,
  request = UpdateClusterAttributeRequest(value = true),
  onSuccess = { response -> },
  onError = { error -> },
)

Delete a hub

InstaVision.hubService.deleteHub(
  hub = hub,
  onSuccess = {
    // The hub was deleted
  },
  onError = { error -> },
)

List a hub’s child devices

InstaVision.hubService.getHubChildDevices(
  hub = hub,
  onSuccess = { devices ->
    // List<Device>; each has parentDeviceId == hub.id
  },
  onError = { error -> },
)

Child device clusters

The child-device calls mirror the hub ones and take the child device:

Call Parameters onSuccess
getHubChildClusters device DeviceCluster
updateHubChildCluster device, clusterId, request: UpdateClusterRequest ClusterResponse
updateHubChildClusterAttribute device, clusterId, attributeId, request: UpdateClusterAttributeRequest ClusterResponse
deleteHubChildDevice device Unit
InstaVision.hubService.updateHubChildClusterAttribute(
  device = childDevice,
  clusterId = DeviceClusterTypes.PrivacyMode.id,
  attributeId = ClusterAttributeTypes.PrivacyMode.id,
  request = UpdateClusterAttributeRequest(value = true),
  onSuccess = { response -> },
  onError = { error -> },
)

deleteHubChildDevice removes the device from its hub; the hub itself stays paired.


This site uses Just the Docs, a documentation theme for Jekyll.