API
- class idasen.IdasenDesk(mac: BLEDevice | str, exit_on_fail: bool = False, disconnected_callback: Callable[[BleakClient], None] | None = None)[source]
Idasen desk.
- Parameters:
mac – Bluetooth MAC address of the desk, or an instance of a BLEDevice.
exit_on_fail – If set to True, failing to connect will call
sys.exit(1)
, otherwise the exception will be raised.disconnected_callback – Callback that will be scheduled in the event loop when the client is disconnected. The callable must take one argument, which will be this client object.
Note
There is no locking to prevent you from running multiple movement coroutines simultaneously.
Example
Basic Usage:
from idasen import IdasenDesk async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: # call methods here...
- async connect()[source]
Connect to the desk.
This method is an alternative to the context manager. When possible the context manager is preferred.
>>> async def example() -> bool: ... desk = IdasenDesk(mac="AA:AA:AA:AA:AA:AA") ... await desk.connect() # don't forget to call disconnect later! ... return desk.is_connected >>> asyncio.run(example()) True
- async disconnect()[source]
Disconnect from the desk.
This method is an alternative to the context manager. When possible the context manager is preferred.
>>> async def example() -> bool: ... desk = IdasenDesk(mac="AA:AA:AA:AA:AA:AA") ... await desk.connect() ... await desk.disconnect() ... return desk.is_connected >>> asyncio.run(example()) False
- async static discover() str | None [source]
Try to find the desk’s MAC address by discovering currently connected devices.
- Returns:
MAC address if found,
None
if not found.
>>> asyncio.run(IdasenDesk.discover()) 'AA:AA:AA:AA:AA:AA'
- async get_height() float [source]
Get the desk height in meters.
- Returns:
Desk height in meters.
>>> async def example() -> float: ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_to_target(1.0) ... return await desk.get_height() >>> asyncio.run(example()) 1.0
- async get_height_and_speed() Tuple[float, float] [source]
Get the desk height in meters and speed in meters per second.
- Returns:
Tuple of desk height in meters and speed in meters per second.
>>> async def example() -> [float, float]: ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_to_target(1.0) ... return await desk.get_height_and_speed() >>> asyncio.run(example()) (1.0, 0.0)
- async get_speed() float [source]
Get the desk speed in meters per second.
- Returns:
Desk speed in meters per second.
>>> async def example() -> float: ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_to_target(1.0) ... return await desk.get_speed() >>> asyncio.run(example()) 0.0
- property is_connected: bool[source]
True
if the desk is connected.>>> async def example() -> bool: ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... return desk.is_connected >>> asyncio.run(example()) True
- property mac: str[source]
Desk MAC address.
>>> async def example() -> str: ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... return desk.mac >>> asyncio.run(example()) 'AA:AA:AA:AA:AA:AA'
- async move_down()[source]
Move the desk downwards.
This command moves the desk downwards for a fixed duration (approximately one second) as set by your desk controller.
>>> async def example(): ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_down() >>> asyncio.run(example())
- async move_to_target(target: float)[source]
Move the desk to the target position.
- Parameters:
target – Target position in meters.
- Raises:
ValueError – Target exceeds maximum or minimum limits.
>>> async def example(): ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_to_target(1.1) >>> asyncio.run(example())
- async move_up()[source]
Move the desk upwards.
This command moves the desk upwards for a fixed duration (approximately one second) as set by your desk controller.
>>> async def example(): ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.move_up() >>> asyncio.run(example())
- async pair()[source]
Pair with the desk.
This method is not available on macOS. Instead of manually initiating paring, the user will be prompted to pair automatically as soon as it is required.
See
bleak.BleakClient.pair()
for more information.
- async wakeup()[source]
Wakeup the controller from sleep.
This exists for compatibility with the Linak DPG1C controller, it is not necessary with the original idasen controller.
>>> async def example(): ... async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk: ... await desk.wakeup() >>> asyncio.run(example())