openHAB - IO-4 Bricklet

Bemerkung

Die openHAB-Dokumentation ist nur auf Englisch verfügbar.

Warnung

The openHAB bindings are still in beta, but the development was stopped.

This is the description of the openHAB API bindings for the IO-4 Bricklet. General information and technical specifications for the IO-4 Bricklet are summarized in its hardware description.

An installation guide for the openHAB API bindings is part of their general description.

Thing

UID:
  • tinkerforge:brickletio4:[UID]
Required firmware version:
  • 2.0.1
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Pin Configuration 0 – Type: Choice, Default: Input with pull-up
  • Configures pin 0 as input or output. Inputs without pull-up will be floating if nothing is connected. Outputs can have an initial state of low or high.
  • Options: Input with pull-up, Input without pull-up, Output (Initial high), Output (Initial low)

  • Pin Configuration 1 – Type: Choice, Default: Input with pull-up
  • Configures pin 1 as input or output. Inputs without pull-up will be floating if nothing is connected. Outputs can have an initial state of low or high.
  • Options: Input with pull-up, Input without pull-up, Output (Initial high), Output (Initial low)

  • Pin Configuration 2 – Type: Choice, Default: Input with pull-up
  • Configures pin 2 as input or output. Inputs without pull-up will be floating if nothing is connected. Outputs can have an initial state of low or high.
  • Options: Input with pull-up, Input without pull-up, Output (Initial high), Output (Initial low)

  • Pin Configuration 3 – Type: Choice, Default: Input with pull-up
  • Configures pin 3 as input or output. Inputs without pull-up will be floating if nothing is connected. Outputs can have an initial state of low or high.
  • Options: Input with pull-up, Input without pull-up, Output (Initial high), Output (Initial low)

Channels

Input Value 0

The logic level that is currently measured on the pin.

Type:
  • Contact
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Input0
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 0 is one of Input with pull-up, Input without pull-up.
Input Value 1

The logic level that is currently measured on the pin.

Type:
  • Contact
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Input1
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 1 is one of Input with pull-up, Input without pull-up.
Input Value 2

The logic level that is currently measured on the pin.

Type:
  • Contact
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Input2
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 2 is one of Input with pull-up, Input without pull-up.
Input Value 3

The logic level that is currently measured on the pin.

Type:
  • Contact
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Input3
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 3 is one of Input with pull-up, Input without pull-up.
Output Value 0

The logic level that is currently set on the pin.

Type:
  • Switch
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Output0
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 0 is one of Output (Initial high), Output (Initial low).
Output Value 1

The logic level that is currently set on the pin.

Type:
  • Switch
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Output1
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 1 is one of Output (Initial high), Output (Initial low).
Output Value 2

The logic level that is currently set on the pin.

Type:
  • Switch
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Output2
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 2 is one of Output (Initial high), Output (Initial low).
Output Value 3

The logic level that is currently set on the pin.

Type:
  • Switch
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Output3
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 3 is one of Output (Initial high), Output (Initial low).
Monoflop 0

Triggers a monoflop as configured.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Monoflop0
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 0 is one of Output (Initial high), Output (Initial low).
Commands:
  • Accepts any string
Parameters:
  • Monoflop Duration – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • The time that the pin should hold the configured value.

  • Monoflop Value – Type: boolean, Default: true
  • The desired value of the pin.
Monoflop 1

Triggers a monoflop as configured.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Monoflop1
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 1 is one of Output (Initial high), Output (Initial low).
Commands:
  • Accepts any string
Parameters:
  • Monoflop Duration – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • The time that the pin should hold the configured value.

  • Monoflop Value – Type: boolean, Default: true
  • The desired value of the pin.
Monoflop 2

Triggers a monoflop as configured.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Monoflop2
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 2 is one of Output (Initial high), Output (Initial low).
Commands:
  • Accepts any string
Parameters:
  • Monoflop Duration – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • The time that the pin should hold the configured value.

  • Monoflop Value – Type: boolean, Default: true
  • The desired value of the pin.
Monoflop 3

Triggers a monoflop as configured.

Type:
  • Commands (String)
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4Monoflop3
Read only:
  • No
Predicate:
  • This channel will only be available if Pin Configuration 3 is one of Output (Initial high), Output (Initial low).
Commands:
  • Accepts any string
Parameters:
  • Monoflop Duration – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • The time that the pin should hold the configured value.

  • Monoflop Value – Type: boolean, Default: true
  • The desired value of the pin.
Edge Count 0

The current value of the edge counter of the pin.

This channel will only update after the configured update interval, not on changed values.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4EdgeCount0
Read only:
  • Yes
Predicate:
  • This channel will only be available if Pin Configuration 0 is one of Input with pull-up, Input without pull-up.
Parameters:
  • Edge Type – Type: Choice, Default: Rising
  • Configures if rising edges, falling edges or both are counted.
  • Options: Rising, Falling, Both

  • Debounce Time – Type: integer, Default: 100, Min: 0, Max: 4294967295
  • The debounce time is the minimum time between two count increments.

  • Reset Edge Counter On Update – Type: boolean, Default: false
  • Enabling this will reset the edge counter after openHAB reads its value. Use this if you want relative counts per update.

  • Update Interval – Type: integer, Default: 1000, Unit: ms
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.
Edge Count 1

The current value of the edge counter of the pin.

This channel will only update after the configured update interval, not on changed values.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4EdgeCount1
Read only:
  • Yes
Predicate:
  • This channel will only be available if Pin Configuration 1 is one of Input with pull-up, Input without pull-up.
Parameters:
  • Edge Type – Type: Choice, Default: Rising
  • Configures if rising edges, falling edges or both are counted.
  • Options: Rising, Falling, Both

  • Debounce Time – Type: integer, Default: 100, Min: 0, Max: 4294967295
  • The debounce time is the minimum time between two count increments.

  • Reset Edge Counter On Update – Type: boolean, Default: false
  • Enabling this will reset the edge counter after openHAB reads its value. Use this if you want relative counts per update.

  • Update Interval – Type: integer, Default: 1000, Unit: ms
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.
Edge Count 2

The current value of the edge counter of the pin.

This channel will only update after the configured update interval, not on changed values.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4EdgeCount2
Read only:
  • Yes
Predicate:
  • This channel will only be available if Pin Configuration 2 is one of Input with pull-up, Input without pull-up.
Parameters:
  • Edge Type – Type: Choice, Default: Rising
  • Configures if rising edges, falling edges or both are counted.
  • Options: Rising, Falling, Both

  • Debounce Time – Type: integer, Default: 100, Min: 0, Max: 4294967295
  • The debounce time is the minimum time between two count increments.

  • Reset Edge Counter On Update – Type: boolean, Default: false
  • Enabling this will reset the edge counter after openHAB reads its value. Use this if you want relative counts per update.

  • Update Interval – Type: integer, Default: 1000, Unit: ms
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.
Edge Count 3

The current value of the edge counter of the pin.

This channel will only update after the configured update interval, not on changed values.

Type:
  • Number:Dimensionless
UID:
  • tinkerforge:brickletio4:[UID]:BrickletIO4EdgeCount3
Read only:
  • Yes
Predicate:
  • This channel will only be available if Pin Configuration 3 is one of Input with pull-up, Input without pull-up.
Parameters:
  • Edge Type – Type: Choice, Default: Rising
  • Configures if rising edges, falling edges or both are counted.
  • Options: Rising, Falling, Both

  • Debounce Time – Type: integer, Default: 100, Min: 0, Max: 4294967295
  • The debounce time is the minimum time between two count increments.

  • Reset Edge Counter On Update – Type: boolean, Default: false
  • Enabling this will reset the edge counter after openHAB reads its value. Use this if you want relative counts per update.

  • Update Interval – Type: integer, Default: 1000, Unit: ms
  • Specifies the update interval in milliseconds. A value of 0 disables automatic updates.

Actions

Actions can be used in rules by creating an action object. All actions return a Map<String, Object>. Returned values can be accessed by name, sometimes the type deduction needs some hints, as shown below:

val actions = getActions("tinkerforge", "tinkerforge:brickletio4:[UID]")
val hwVersion = actions.brickletIO4GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletIO4SetValue(short valueMask)
Parameters:
  • valueMask – Type: short, Range: [0 to 15]

Sets the output value (high or low) with a bitmask (4bit). A 1 in the bitmask means high and a 0 in the bitmask means low.

For example: The value 3 or 0b0011 will turn the pins 0-1 high and the pins 2-3 low.

All running monoflop timers will be aborted if this function is called.

Bemerkung

This function does nothing for pins that are configured as input. Pull-up resistors can be switched on with the thing configuration.

brickletIO4GetValue()
Return Map:
  • valueMask – Type: short, Range: [0 to 15]

Returns a bitmask of the values that are currently measured. This function works if the pin is configured to input as well as if it is configured to output.

brickletIO4GetConfiguration()
Return Map:
  • directionMask – Type: short, Range: [0 to 15]
  • valueMask – Type: short, Range: [0 to 15]

Returns a value bitmask and a direction bitmask. A 1 in the direction bitmask means input and a 0 in the bitmask means output.

For example: A return value of (3, 5) or (0b0011, 0b0101) for direction and value means that:

  • pin 0 is configured as input pull-up,
  • pin 1 is configured as input default,
  • pin 2 is configured as output high and
  • pin 3 is are configured as output low.
brickletIO4GetEdgeCount(short pin, boolean resetCounter)
Parameters:
  • pin – Type: short, Range: [0 to 3]
  • resetCounter – Type: boolean
Return Map:
  • count – Type: long, Range: [0 to 232 - 1]

Returns the current value of the edge counter for the selected pin. You can configure the edges that are counted with the configuration of Edge Count 0.

If you set the reset counter to true, the count is set back to 0 directly after it is read.

Neu in Version 2.0.1 (Plugin).

Advanced Actions

brickletIO4SetSelectedValues(short selectionMask, short valueMask)
Parameters:
  • selectionMask – Type: short, Range: [0 to 15]
  • valueMask – Type: short, Range: [0 to 15]

Sets the output value (high or low) with a bitmask, according to the selection mask. The bitmask is 4 bit long, true refers to high and false refers to low.

For example: The parameters (9, 4) or (0b0110, 0b0100) will turn pin 1 low and pin 2 high, pin 0 and 3 will remain untouched.

Running monoflop timers for the selected pins will be aborted if this function is called.

Bemerkung

This function does nothing for pins that are configured as input. Pull-up resistors can be switched on with the thing configuration.

brickletIO4SetMonoflop(short selectionMask, short valueMask, long time)
Parameters:
  • selectionMask – Type: short, Range: [0 to 15]
  • valueMask – Type: short, Range: [0 to 15]
  • time – Type: long, Unit: 1 ms, Range: [0 to 232 - 1]

Configures a monoflop of the pins specified by the first parameter as 4 bit long bitmask. The specified pins must be configured for output. Non-output pins will be ignored.

The second parameter is a bitmask with the desired value of the specified output pins. A 1 in the bitmask means high and a 0 in the bitmask means low.

The third parameter indicates the time that the pins should hold the value.

If this function is called with the parameters (9, 1, 1500) or (0b1001, 0b0001, 1500): Pin 0 will get high and pin 3 will get low. In 1.5s pin 0 will get low and pin 3 will get high again.

A monoflop can be used as a fail-safe mechanism. For example: Lets assume you have a RS485 bus and an IO-4 Bricklet connected to one of the slave stacks. You can now call this function every second, with a time parameter of two seconds and pin 0 set to high. Pin 0 will be high all the time. If now the RS485 connection is lost, then pin 0 will get low in at most two seconds.

brickletIO4GetMonoflop(short pin)
Parameters:
  • pin – Type: short, Range: [0 to 3]
Return Map:
  • value – Type: short, Range: [0 to 1]
  • time – Type: long, Unit: 1 ms, Range: [0 to 232 - 1]
  • timeRemaining – Type: long, Unit: 1 ms, Range: [0 to 232 - 1]

Returns (for the given pin) the current value and the time as set by Monoflop 0 as well as the remaining time until the value flips.

If the timer is not running currently, the remaining time will be returned as 0.

brickletIO4GetEdgeCountConfig(short pin)
Parameters:
  • pin – Type: short, Range: [0 to 3]
Return Map:
  • edgeType – Type: short, Range: See constants, Default: 0
  • debounce – Type: short, Unit: 1 ms, Range: [0 to 255], Default: 100

Returns the edge type and debounce time for the selected pin as set by the configuration of Edge Count 0.

The following constants are available for this function:

For edgeType:

  • val EDGE_TYPE_RISING = 0
  • val EDGE_TYPE_FALLING = 1
  • val EDGE_TYPE_BOTH = 2

Neu in Version 2.0.1 (Plugin).

brickletIO4GetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'z']
  • hardwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • firmwareVersion – Type: short[], Length: 3
    • 0: major – Type: short, Range: [0 to 255]
    • 1: minor – Type: short, Range: [0 to 255]
    • 2: revision – Type: short, Range: [0 to 255]
  • deviceIdentifier – Type: int, Range: [0 to 216 - 1]

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.

The device identifier numbers can be found here