API reference

Auto-generated reference for the public surface of bleak_smlight — the names exported from the top-level package. For how these pieces fit together, see the architecture overview; for task-oriented examples, see usage.

Everything documented here is re-exported from bleak_smlight directly, so the import you write in application code is, for example:

from bleak_smlight import SMLIGHTConnectionManager, SMLIGHTDeviceConfig

High-level entry point

SMLIGHTConnectionManager is the standalone, Home-Assistant-free way to drive a SLZB BLE proxy: hand it a device config, await start(), and it owns the proxy client and scanner registration for you.

class bleak_smlight.SMLIGHTConnectionManager(config)

Manage a scanner for a SMLIGHT SLZB BLE proxy.

Construction is side-effect-free and does not require a running event loop; all asyncio work happens in start(). The underlying BleProxyClient owns its own connect/retry loop, so the manager only has to register the scanner with the habluetooth manager and start the proxy client.

Parameters:

config (SMLIGHTDeviceConfig)

async start()

Build the scanner, register it, and start the BLE proxy client.

Call once per manager instance; a second call raises RuntimeError rather than leaking the prior proxy client and its background reconnect task.

Raises:

RuntimeError – if start() has already been called.

Return type:

None

async stop()

Stop the BLE proxy client and unregister the scanner.

Every teardown step runs even if an earlier one raises, so a failure stopping the client cannot leave the scanner registered (which would block recreating a manager for the same source). State is cleared up front, so a failed stop() still leaves the manager in a stopped state. An exception, if any, propagates once all steps have run; if several steps raise, they are chained (the last surfaces with the earlier ones as its __context__).

Return type:

None

class bleak_smlight.SMLIGHTDeviceConfig

Configuration for one SMLIGHT SLZB BLE proxy device.

source: str
name: str
host: str
port: NotRequired[int]

Low-level escape hatch

connect_scanner is for advanced callers that manage their own scanner registration and proxy-client lifecycle. It builds a SMLIGHTScanner plus a pysmlight.BleProxyClient and returns the assembled SMLIGHTClientData, but leaves scanner setup, manager registration, and client start/stop up to you. Read the docstring carefully before reaching for it.

bleak_smlight.connect_scanner(source, name, host, port=5050)

Build a scanner and BLE proxy client for an SLZB device.

source is the stable unique identifier for the proxy (typically its MAC address); name is the human-friendly adapter name; host is the IP/hostname the UDP proxy server listens on.

The caller is responsible for:

  1. Calling data.scanner.async_setup().

  2. Registering data.scanner with the habluetooth manager (and unregistering it on teardown).

  3. Calling await data.client.start() to begin receiving advertisements, and data.client.stop() on teardown.

SMLIGHTConnectionManager wires all of this up for the common standalone case.

Parameters:
Return type:

SMLIGHTClientData

class bleak_smlight.SMLIGHTClientData(scanner, client)

The scanner and its BLE proxy client for one SLZB device.

Parameters:
  • scanner (SMLIGHTScanner)

  • client (BleProxyClient)

scanner: SMLIGHTScanner
client: BleProxyClient
bleak_smlight.SLZB_BLE_SERVER_PORT = 5050

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4