openHAB - Real-Time Clock Bricklet 2.0

This is the description of the openHAB API bindings for the Real-Time Clock Bricklet 2.0. General information and technical specifications for the Real-Time Clock Bricklet 2.0 are summarized in its hardware description.

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

Thing

UID:
  • tinkerforge:brickletrealtimeclockv2:[UID]
Required firmware version:
  • 2.0.0
Firmware update supported:
  • yes
Channels:
Actions:
Parameters:
  • Date Time Update Interval – Type: integer, Default: 1000, Unit: ms, Min: 0, Max: 4294967295
  • Specifies the update interval for the date time and timestamp in milliseconds. A value of 0 disables automatic updates.

  • Status LED Config – Type: Choice, Default: Show Status
  • The status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets. You can also turn the LED permanently on/off or show a heartbeat. If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
  • Options: Off, On, Show Heartbeat, Show Status

Channels

Date Time

The real-time clock handles leap year and inserts the 29th of February accordingly. But leap seconds are not handled. The time is stored as UTC on the clock and converted into your system's timezone when accessed by OpenHAB.

Type:
  • DateTime
UID:
  • tinkerforge:brickletrealtimeclockv2:[UID]:BrickletRealTimeClockV2DateTime
Read only:
  • No
Timestamp

the current date and the time of the real-time clock converted to seconds. The timestamp has an effective resolution of hundredths of a second.

Type:
  • Number:Time
UID:
  • tinkerforge:brickletrealtimeclockv2:[UID]:BrickletRealTimeClockV2Timestamp
Read only:
  • Yes
Unit:
  • Second
Alarm

This listener is triggered every time the current date and time matches the configured alarm (see the setAlarm action).

Type:
  • Trigger (system.trigger)
UID:
  • tinkerforge:brickletrealtimeclockv2:[UID]:BrickletRealTimeClockV2Alarm
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:brickletrealtimeclockv2:[UID]")
val hwVersion = actions.brickletRealTimeClockV2GetIdentity().get("hardwareVersion") as short[]
logInfo("Example", "Hardware version: " + hwVersion.get(0) + "." + hwVersion.get(1) + "." + hwVersion.get(2))

Basic Actions

brickletRealTimeClockV2SetDateTime(int year, int month, int day, int hour, int minute, int second, int centisecond, int weekday)
Parameters:
  • year – Type: int, Range: [2000 to 2099]
  • month – Type: int, Range: [1 to 12]
  • day – Type: int, Range: [1 to 31]
  • hour – Type: int, Range: [0 to 23]
  • minute – Type: int, Range: [0 to 59]
  • second – Type: int, Range: [0 to 59]
  • centisecond – Type: int, Range: [0 to 99]
  • weekday – Type: int, Range: See constants

Sets the current date (including weekday) and the current time.

If the backup battery is installed then the real-time clock keeps date and time even if the Bricklet is not powered by a Brick.

The real-time clock handles leap year and inserts the 29th of February accordingly. But leap seconds, time zones and daylight saving time are not handled.

The following constants are available for this function:

For weekday:

  • val WEEKDAY_MONDAY = 1
  • val WEEKDAY_TUESDAY = 2
  • val WEEKDAY_WEDNESDAY = 3
  • val WEEKDAY_THURSDAY = 4
  • val WEEKDAY_FRIDAY = 5
  • val WEEKDAY_SATURDAY = 6
  • val WEEKDAY_SUNDAY = 7
brickletRealTimeClockV2GetDateTime()
Return Map:
  • year – Type: int, Range: [2000 to 2099]
  • month – Type: int, Range: [1 to 12]
  • day – Type: int, Range: [1 to 31]
  • hour – Type: int, Range: [0 to 23]
  • minute – Type: int, Range: [0 to 59]
  • second – Type: int, Range: [0 to 59]
  • centisecond – Type: int, Range: [0 to 99]
  • weekday – Type: int, Range: See constants
  • timestamp – Type: long, Unit: 1 ms, Range: [-263 to 263 - 1]

Returns the current date (including weekday) and the current time of the real-time.

The timestamp represents the current date and the the current time of the real-time clock converted to milliseconds and is an offset to 2000-01-01 00:00:00.0000.

The following constants are available for this function:

For weekday:

  • val WEEKDAY_MONDAY = 1
  • val WEEKDAY_TUESDAY = 2
  • val WEEKDAY_WEDNESDAY = 3
  • val WEEKDAY_THURSDAY = 4
  • val WEEKDAY_FRIDAY = 5
  • val WEEKDAY_SATURDAY = 6
  • val WEEKDAY_SUNDAY = 7
brickletRealTimeClockV2GetTimestamp()
Return Map:
  • timestamp – Type: long, Unit: 1 ms, Range: [-263 to 263 - 1]

Returns the current date and the time of the real-time clock converted to milliseconds. The timestamp has an effective resolution of hundredths of a second and is an offset to 2000-01-01 00:00:00.0000.

Advanced Actions

brickletRealTimeClockV2GetOffset()
Return Map:
  • offset – Type: int, Unit: 217/100 ppm, Range: [-128 to 127]

Returns the offset as set by This function is not available in openHAB. Please use Brick Viewer to change persistant device settings.

brickletRealTimeClockV2GetChipTemperature()
Return Map:
  • temperature – Type: int, Unit: 1 °C, Range: [-215 to 215 - 1]

Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!

The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.

brickletRealTimeClockV2GetStatusLEDConfig()
Return Map:
  • config – Type: int, Range: See constants, Default: 3

Returns the configuration as set by the thing configuration

The following constants are available for this function:

For config:

  • val STATUS_LED_CONFIG_OFF = 0
  • val STATUS_LED_CONFIG_ON = 1
  • val STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2
  • val STATUS_LED_CONFIG_SHOW_STATUS = 3
brickletRealTimeClockV2GetSPITFPErrorCount()
Return Map:
  • errorCountAckChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountMessageChecksum – Type: long, Range: [0 to 232 - 1]
  • errorCountFrame – Type: long, Range: [0 to 232 - 1]
  • errorCountOverflow – Type: long, Range: [0 to 232 - 1]

Returns the error count for the communication between Brick and Bricklet.

The errors are divided into

  • ACK checksum errors,
  • message checksum errors,
  • framing errors and
  • overflow errors.

The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.

brickletRealTimeClockV2GetIdentity()
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 as position 'z'.

The device identifier numbers can be found here

Trigger Channel Configuration Actions

brickletRealTimeClockV2SetAlarm(int month, int day, int hour, int minute, int second, int weekday, int interval)
Parameters:
  • month – Type: int, Range: [-1, 1 to 12] with constants
  • day – Type: int, Range: [-1, 1 to 31] with constants
  • hour – Type: int, Range: [-1, 0 to 23] with constants
  • minute – Type: int, Range: [-1, 0 to 59] with constants
  • second – Type: int, Range: [-1, 0 to 59] with constants
  • weekday – Type: int, Range: [-1, 1 to 7] with constants
  • interval – Type: int, Unit: 1 s, Range: [-1, 1 to 231 - 1] with constants

Configures a repeatable alarm. The Alarm channel is triggered if the current date and time matches the configured alarm.

Setting a parameter to -1 means that it should be disabled and doesn't take part in the match. Setting all parameters to -1 disables the alarm completely.

For example, to make the alarm trigger every day at 7:30 AM it can be configured as (-1, -1, 7, 30, -1, -1, -1). The hour is set to match 7 and the minute is set to match 30. The alarm is triggered if all enabled parameters match.

The interval has a special role. It allows to make the alarm reconfigure itself. This is useful if you need a repeated alarm that cannot be expressed by matching the current date and time. For example, to make the alarm trigger every 23 seconds it can be configured as (-1, -1, -1, -1, -1, -1, 23). Internally the Bricklet will take the current date and time, add 23 seconds to it and set the result as its alarm. The first alarm will be triggered 23 seconds after the call. Because the interval is not -1, the Bricklet will do the same again internally, take the current date and time, add 23 seconds to it and set that as its alarm. This results in a repeated alarm that triggers every 23 seconds.

The interval can also be used in combination with the other parameters. For example, configuring the alarm as (-1, -1, 7, 30, -1, -1, 300) results in an alarm that triggers every day at 7:30 AM and is then repeated every 5 minutes.

The following constants are available for this function:

For month:

  • val ALARM_MATCH_DISABLED = -1

For day:

  • val ALARM_MATCH_DISABLED = -1

For hour:

  • val ALARM_MATCH_DISABLED = -1

For minute:

  • val ALARM_MATCH_DISABLED = -1

For second:

  • val ALARM_MATCH_DISABLED = -1

For weekday:

  • val ALARM_MATCH_DISABLED = -1

For interval:

  • val ALARM_INTERVAL_DISABLED = -1
brickletRealTimeClockV2GetAlarm()
Return Map:
  • month – Type: int, Range: [-1, 1 to 12] with constants
  • day – Type: int, Range: [-1, 1 to 31] with constants
  • hour – Type: int, Range: [-1, 0 to 23] with constants
  • minute – Type: int, Range: [-1, 0 to 59] with constants
  • second – Type: int, Range: [-1, 0 to 59] with constants
  • weekday – Type: int, Range: [-1, 1 to 7] with constants
  • interval – Type: int, Unit: 1 s, Range: [-1, 1 to 231 - 1] with constants

Returns the alarm configuration as set by SetAlarm().

The following constants are available for this function:

For month:

  • val ALARM_MATCH_DISABLED = -1

For day:

  • val ALARM_MATCH_DISABLED = -1

For hour:

  • val ALARM_MATCH_DISABLED = -1

For minute:

  • val ALARM_MATCH_DISABLED = -1

For second:

  • val ALARM_MATCH_DISABLED = -1

For weekday:

  • val ALARM_MATCH_DISABLED = -1

For interval:

  • val ALARM_INTERVAL_DISABLED = -1

Internal Actions

brickletRealTimeClockV2ReadUID()
Return Map:
  • uid – Type: long, Range: [0 to 232 - 1]

Returns the current UID as an integer. Encode as Base58 to get the usual string version.