openHAB - Piezo Speaker Bricklet

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

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

Thing

UID:
  • tinkerforge:brickletpiezospeaker:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:

Channels

Beep Finished

This channel is triggered if a beep set by the beep action is finished.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletpiezospeaker:[UID]:BrickletPiezoSpeakerBeepFinished
Read only:
  • No
Morse Code Finished

This channel is triggered if the playback of the morse code set by the morseCode action is finished.

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletpiezospeaker:[UID]:BrickletPiezoSpeakerMorseCodeFinished
Read only:
  • No

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:brickletpiezospeaker:[UID]")
val hwVersion = actions.brickletPiezoSpeakerGetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletPiezoSpeakerBeep(long duration, int frequency)
Parameters:
  • duration – Type: long, Unit: 1 ms, Range: [0 to 232 - 1] with constants
  • frequency – Type: int, Unit: 1 Hz, Range: [585 to 7100]

Beeps with the given frequency for the given duration.

Changed in version 2.0.2 (Plugin): A duration of 0 stops the current beep if any, the frequency parameter is ignored. A duration of 4294967295 results in an infinite beep.

The Piezo Speaker Bricklet can only approximate the frequency, it will play the best possible match by applying the calibration (see This function is not available in openHAB. Please use Brick Viewer to change persistant device settings).

The following constants are available for this function:

For duration:

  • val BEEP_DURATION_OFF = 0
  • val BEEP_DURATION_INFINITE = 4294967295
brickletPiezoSpeakerMorseCode(String morse, int frequency)
Parameters:
  • morse – Type: String, Length: up to 60
  • frequency – Type: int, Unit: 1 Hz, Range: [585 to 7100]

Sets morse code that will be played by the piezo buzzer. The morse code is given as a string consisting of "." (dot), "-" (minus) and " " (space) for dits, dahs and pauses. Every other character is ignored.

For example: If you set the string "...---...", the piezo buzzer will beep nine times with the durations "short short short long long long short short short".

Advanced Actions

brickletPiezoSpeakerGetIdentity()
Return Map:
  • uid – Type: String, Length: up to 8
  • connectedUid – Type: String, Length: up to 8
  • position – Type: char, Range: ['a' to 'h', 'i', '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). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an Isolator Bricklet is always as position 'z'.

The device identifier numbers can be found here