1. TrainScanner

from intelino.trainlib import TrainScanner
class trainlib.TrainScanner(device_identifier: Optional[str] = None, timeout: float = 5.0)

Obtaining a Train object using the with statement.

Connecting to a single train (basic usage):

with TrainScanner() as train:

Connecting to multiple trains:

trains = TrainScanner(timeout=3.0).get_trains(2)
for train in trains:
__init__(device_identifier: Optional[str] = None, timeout: float = 5.0)
  • device_identifier (str) – The Bluetooth/UUID address of the Bluetooth peripheral sought. If not specified, it will return the first found intelino train.

  • timeout (float) – Optional timeout to wait for detection of specified peripheral before giving up. Defaults to 5.0 seconds.

get_train(**kwargs) trainlib.train.Train

Get a blocking train instance synchronously.

Keyword Arguments

adapter (str) – Bluetooth adapter to use for discovery.


TrainNotFoundError – If no train is found.


A connected Train instance.

get_trains(count: Optional[int] = None, **kwargs) List[trainlib.train.Train]

Get a list of blocking train instances synchronously.


count (int) – Optional detection limit. If not satisfied, raises an exception. If omited or 0, it searches for all trains in the surroundings until it timeouts.

Keyword Arguments
  • at_most (int) – Connect to at most N trains. No exception is raised if the count argument is omitted.

  • adapter (str) – Bluetooth adapter to use for discovery.


TrainNotFoundError – If the requested number of trains is not found.


A list of Train instances.


>>> # connect to all trains in 5 seconds (always takes 5 seconds)
>>> trains = TrainScanner(timeout=5.0).get_trains()
>>> # connect to exactly 2 trains, max. waiting time 3 seconds
>>> trains = TrainScanner(timeout=3.0).get_trains(2)
>>> # connect to 0 - 4 trains within 10 seconds
>>> trains = TrainScanner(timeout=10.0).get_trains(at_most=4)