toio.cube.api.battery module

class toio.cube.api.battery.BatteryInformation(payload: bytearray)[source]

Bases: CubeResponse

Cube remaining battery level response

battery_level

Battery level ( 0 <= battery_level <= 100)

Type:

int

References

https://toio.github.io/toio-spec/en/docs/ble_battery#read-operations

static is_myself(payload: bytearray) bool[source]

If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.

Parameters:

data (GattReadData) – received data from the cube.

__init__(payload: bytearray)[source]
__str__() str[source]

Return str(self).

toio.cube.api.battery.BatteryResponseType

Response type of battery characteristic

class toio.cube.api.battery.Battery(interface: CubeInterface, device: Any)[source]

Bases: CubeCharacteristic

Battery characteristic

References

https://toio.github.io/toio-spec/en/docs/ble_battery

static is_my_data(payload: bytearray) BatteryInformation | None[source]

If payload is my characteristic response, this function returns CubeResponse object. Otherwise, it returns None.

Parameters:

payload (GattReadData) – received data from the cube.

__init__(interface: CubeInterface, device: Any)[source]
async read() BatteryInformation | None[source]

Read the battery level

Returns:

BatteryInformation or None (None returns when read fails)

References

https://toio.github.io/toio-spec/en/docs/ble_battery#read-operations