Skip to content

pb_client.service.Service.connect_hub async

connect_hub(*, hub_id=None, name=None, transport=None)

Connect to a hub and leave it connected.

The connection outlives this client: that is the point of the service.

With neither hub_id nor name, the hub is the one chosen with use_hub if there is one; otherwise one already connected; otherwise the only hub switched on. Several hubs switched on and nothing to say which is refused rather than guessed at.

Parameters:

Name Type Description Default
hub_id str | None

The hub's id, from scan.

None
name str | None

Connect to the hub with this name instead. One already connected is handed back; several switched on are refused.

None
transport str | None

Reach the hub this way, such as "usb" or "ble". Left out, the service uses whichever it can, preferring USB where a hub is reachable both ways.

None

Returns:

Type Description
HubInfo

The connected hub. If it was connected already, it is handed back

HubInfo

as it is, with already_connected set.

Raises:

Type Description
JsonRpcError

With ErrorCode.HUB_AMBIGUOUS when several hubs were found and none was named or chosen, or several have the name asked for or chosen. Its data lists them, in the shape hub.scan reports, and names that shared name.