openHAB - Real-Time Clock Bricklet

Warning

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

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

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

Thing

UID:
  • tinkerforge:brickletrealtimeclock:[UID]
Required firmware version:
  • 2.0.1
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.

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

Basic Actions

brickletRealTimeClockSetDateTime(int year, short month, short day, short hour, short minute, short second, short centisecond, short weekday)
Parameters:
  • year – Type: int, Range: [2000 to 2099]
  • month – Type: short, Range: [1 to 12]
  • day – Type: short, Range: [1 to 31]
  • hour – Type: short, Range: [0 to 23]
  • minute – Type: short, Range: [0 to 59]
  • second – Type: short, Range: [0 to 59]
  • centisecond – Type: short, Range: [0 to 99]
  • weekday – Type: short, 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
brickletRealTimeClockGetDateTime()
Return Map:
  • year – Type: int, Range: [2000 to 2099]
  • month – Type: short, Range: [1 to 12]
  • day – Type: short, Range: [1 to 31]
  • hour – Type: short, Range: [0 to 23]
  • minute – Type: short, Range: [0 to 59]
  • second – Type: short, Range: [0 to 59]
  • centisecond – Type: short, Range: [0 to 99]
  • weekday – Type: short, Range: See constants

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

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
brickletRealTimeClockGetTimestamp()
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. The timestamp has an effective resolution of hundredths of a second and is an offset to 2000-01-01 00:00:00.000.

Advanced Actions

brickletRealTimeClockGetOffset()
Return Map:
  • offset – Type: byte, 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.

brickletRealTimeClockGetIdentity()
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

Trigger Channel Configuration Actions

brickletRealTimeClockSetAlarm(byte month, byte day, byte hour, byte minute, byte second, byte weekday, int interval)
Parameters:
  • month – Type: byte, Range: [-1, 1 to 12] with constants
  • day – Type: byte, Range: [-1, 1 to 31] with constants
  • hour – Type: byte, Range: [-1, 0 to 23] with constants
  • minute – Type: byte, Range: [-1, 0 to 59] with constants
  • second – Type: byte, Range: [-1, 0 to 59] with constants
  • weekday – Type: byte, 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

New in version 2.0.1 (Plugin).

brickletRealTimeClockGetAlarm()
Return Map:
  • month – Type: byte, Range: [-1, 1 to 12] with constants
  • day – Type: byte, Range: [-1, 1 to 31] with constants
  • hour – Type: byte, Range: [-1, 0 to 23] with constants
  • minute – Type: byte, Range: [-1, 0 to 59] with constants
  • second – Type: byte, Range: [-1, 0 to 59] with constants
  • weekday – Type: byte, 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

New in version 2.0.1 (Plugin).