FibStack Python API Reference

This page describes the FibStack Python Application Programming Interface (API).

FibstackContext

This class keeps track of all PiSwitcher Plus boards connected. Each board has an associated FibstackBoard object. The FibstackContext object stores these objects internally.

Methods

get_total_boards()
Returns the number of total PiSwitcher Plus boards connected.

Returns:
the total number of PiSwitcher Plus boards.


update()
Updates the information for all connected boards.


get_board_by_index(index)
Returns the FibstackBoard object for the specified index.

Parameters:
index: The index of the FibstackBoard object.

Returns:
an instance of FibstackBoard object if found, None otherwise.


get_board_by_address(address)
Returns the FibstackBoard object for the specified address.

Parameters:
address: The I2C address of the FibstackBoard object.

Returns:
an instance of FibstackBoard object if found, None otherwise.


FibstackBoard

This class represents a PiSwitcher Plus board. Do not instantiate this class by yourself. Use the FibstackContext object to get an instance of the FibstackBoard object.

Attributes

address: The I2C address of the board.
description: A short description of the board.
total_devices: The number of total devices this board has.

Methods

update()
The method updates all the device information from the board.


get_device(device_id)
The method returns a FibstackDevice instance for the specified device Id parameter.

Parameters:
device_id: The device Id

Returns:
the FibstackDevice instance for the specified Id.


get_devices()
Returns a list of devices that the current board has.

Returns:
a list of FibstackDevice instances.


set_device_value(device_id, new_value)
The method sets the specified value for the specified device Id. If one of the input parameters is invalid or the board device is read-only, the method will raise a ValueError exception.

Parameters:
device_id: The Device Id.
new_value: The new value.


to_json()
The method returns the JSON representation of the FibstackBoard object.

Returns:
the JSON representation of the board.


FibstackDevice

A class used to represent a device on a board.

Attributes

id: The device ID.
description: The description of the device.
is_read_only: Specifies whatever the device is Read-Only.
value_type: Specifies the type of value this Device stores.
value: The value this device stores.

Methods

to_json()
The method returns the JSON representation of the FibstackDevice object.

Returns:
the JSON representation of the device.