# pyhoff.devices.BK9100 — pyhoff documentation

Skip to main content
`Ctrl`+`K`

# pyhoff.devices.BK9100

class pyhoff.devices.BK9100(host, port=502, bus_terminals=[], timeout=5, watchdog=0, debug=False)

  Bases: `BK9000`

  BK9100 ModBus TCP bus coupler

  Instantiate a new bus coupler base class.

  Parameters:

    - host (`str`) – ip or hostname of the bus coupler

    - port (`int`) – port of the modbus host

    - bus_terminals (`Iterable`[`type`[`BusTerminal`]]) – list of bus terminal classes for the connected terminals

    - debug (`bool`) – outputs modbus debug information

    - timeout (`float`) – timeout for waiting for the device response

    - watchdog (`float`) – time in seconds after the device sets all outputs to default state. A value of 0 deactivates the watchdog.

    - debug – If True, debug information is printed.

  Examples

      >>> from pyhoff.devices import *
      >>> bk = BK9000('192.168.0.23', bus_terminals=[KL3202, KL9010])
      >>> t1 = bk.terminals[0].read_temperature(1)
      >>> t2 = bk.terminals[0].read_temperature(2)
      >>> print(f"Temperature ch1: {t1:.1f} °C, Temperature ch2: {t2:.1f} °C")
      Temperature ch1: 23.2 °C, Temperature ch2: 22.1 °C

  add_bus_terminals(*new_bus_terminals)

    Add bus terminals to the bus coupler.

    Parameters:

      new_bus_terminals (`Union`[`type`[`BusTerminal`], `Iterable`[`type`[`BusTerminal`]]]) – bus terminal classes to add.

    Return type:

      `list`[`BusTerminal`]

    Returns:

      The corresponding list of bus terminal objects.

  get_error()

    Get the last error message.

    Return type:

      `str`

    Returns:

      The last error message.

  select(bus_terminal_type, terminal_number=0)

    Returns the n-th bus terminal instance of the given bus terminal type and terminal index.

    Parameters:

      - bus_terminals_type – The bus terminal class to select from.

      - terminal_number (`int`) – The index of the bus terminal to return. Counted for all bus terminals of the same type, not all bus terminals. Started for the first terminal with 0

    Return type:

      `TypeVar`(`_BT`, bound= BusTerminal)

    Returns:

      The selected bus terminal instance.

    Example

        >>> from pyhoff.devices import *
        >>> bk = BK9050("172.16.17.1", bus_terminals=[KL2404, KL2424])
        >>> # Select the first KL2425 terminal:
        >>> kl2404 = bk.select(KL2424, 0)