API

class idasen.IdasenDesk(mac: str, exit_on_fail: bool = False)[source]

Idasen desk.

Parameters
  • mac – Bluetooth MAC address of the desk.

  • exit_on_fail – If set to True, failing to connect will call sys.exit(1), otherwise the exception will be raised.

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...
MAX_HEIGHT: float = 1.27[source]

Maximum desk height in meters.

MIN_HEIGHT: float = 0.62[source]

Minimum desk height in meters.

RETRY_COUNT: int = 3[source]

Number of times to retry upon failure to connect.

async classmethod discover() → Optional[str][source]

Try to find the desk’s MAC address by discovering currently connected devices.

Returns

MAC address if found, None if not found.

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 is_connected() → bool[source]

Check connection status of the desk.

Returns

Boolean representing connection status.

>>> async def example() -> bool:
...     async with IdasenDesk(mac="AA:AA:AA:AA:AA:AA") as desk:
...         return await desk.is_connected()
>>> asyncio.run(example())
True
property mac[source]

Desk MAC address.

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 stop()[source]

Stop desk movement.