Skip to content

LaMetric Binding ​

The LaMetric binding allows to connect openHAB to LaMetric Time connected clock devices, providing following features:

  • Control the LaMetric Time Device
    • Control Display Brightness
    • Change Audio Volume
    • Enable / Disable Bluetooth
    • Activate an Application
  • Send notifications messages
  • Control the core (built-in) apps

Supported Things ​

The device acts as a bridge and is exposed as "LaMetric Time" Thing. The "LaMetric Time" Thing is directly responsible for device operations which include the display, audio, bluetooth, and notifications. All apps are implemented as separate things under the bridge.

AppThing TypeDescription
ClockclockAppClock that displays time and date
TimercountdownAppA countdown timer that counts by seconds
RadioradioAppStreaming radio player
StopwatchstopwatchAppStopwatch that counts up by seconds
WeatherweatherAppCurrent weather conditions as well as a forecast

Discovery ​

The binding supports two levels of discovery - device and apps. Device discovery is accomplished via UPnP. Once a device is added, discovery will find all apps installed on the device and suggest them as individual things with the device being the bridge.

Binding Configuration ​

The binding requires no special configuration.

Thing Configuration ​

Bridge (Thing ID: "device") ​

The bridge requires a host and an API key. The key can be found by visiting the LaMetric dev portal.

Configuration ParameterTypeDescriptionDefaultRequired
hosttextHost name or network address of the LaMetric TimeYes
apiKeytextAPI key to access LaMetric TimeYes

Core (Built-in) Apps (Thing ID: "clockApp", "countdownApp", "radioApp", "stopwatchApp", "weatherApp") ​

The core app things can be defined with no configuration at all. The package name is defaulted for you. If you do not specify a widget ID, the first available one will be used automatically. Widgets are instances of the application. For example, if you duplicated the weather app for two locations, the app would have two widgets.

Configuration ParameterTypeDescriptionDefaultRequired
widgetIdtextThe identifier for the exact instance of the app (widget)The first widget ID foundNo

Sample Thing Configuration ​

dsl
Bridge lametrictime:device:demo [ host="somehost", apiKey="ksfjsdkfsksjfs" ]
{
    Thing clockApp     clock       [ widgetId="generatedcorewidgetid1" ]
    Thing countdownApp timer
    Thing radioApp     radio
    Thing stopwatchApp stopwatch
    Thing weatherApp   weather     [ widgetId="generatedcorewidgetid2" ]
}

Channels ​

Device ​

Channel IDItem TypeDescription
brightnessDimmerThe brightness of the display. Please note that changing the brightness will automatically set the 'brightnessMode' to 'manual'.
brightnessModeString (possible values are 'auto' and 'manual')The mode for the display brightness. If set to 'auto' the brightness is set by the device automatically based on environment illumination. If set to 'manual' the brightness can be changed via 'brightness' channel.
volumeDimmerThe volume of the device speaker.
bluetoothSwitchThe status of Bluetooth audio streaming on the device.
appStringThe active application on the device. State options for UIs are determined at runtime automatically. The value must be formatted as <package name>:<widget ID>.
infoStringSend informational notifications to the device.
warningStringSend warning notifications to the device.
alertStringSend alert notifications to the device.

Apps ​

Note that app channels have no defined state from the device. They exist as one-way communication only.

Clock App ​

Channel IDItem TypeDescription
setAlarmDateTimeSet the alarm using the given time (note that the date is not used)
commandStringSend a command to the app (disableAlarm)

Timer App ​

Channel IDItem TypeDescription
durationNumberSet the duration of the timer in seconds
commandStringSend a command to the app (start, pause, reset)

Radio App ​

Channel IDItem TypeDescription
controlPlayerControl interface to manipulate the radio

Stopwatch App ​

Channel IDItem TypeDescription
commandStringSend a command to the app (start, pause, reset)

Weather App ​

Channel IDItem TypeDescription
commandStringSend a command to the app (forecast)

How Tos ​

The following configuration examples assume the device was added with the Thing id lametrictime:device:demo. Replace the Thing id in all the configurations with your real Thing id which can be looked up the UI.

Notifications ​

Simple text notifications ​

The binding provides three simple notification channels for info messages (channel id info), warning messages (channel id warning) and alert messages (channel id alert).

To post messages to these channels, simply map them to a String item, e.g. like this:

java
String DeviceNotifyInfo "Info Message" {channel="lametrictime:device:demo:info"}

By setting a text on the item, the binding will send the notification which is then shown on the LaMetric device.

In a rule this can be done the following way:

java
DeviceNotifyInfo.sendCommand("My Information Message to be displayed")

Items ​

Sample item configuration:

dsl
Dimmer DeviceBrightness         "Brightness"                                { channel="lametrictime:device:demo:brightness" }
String DeviceBrightnessMode     "Brightness Mode"                           { channel="lametrictime:device:demo:brightnessMode" }
Dimmer DeviceVolume             "Volume"                                    { channel="lametrictime:device:demo:volume" }
Switch DeviceBluetooth          "Bluetooth"                                 { channel="lametrictime:device:demo:bluetooth" }
String DeviceApp                "Application"                               { channel="lametrictime:device:demo:app" }

String DeviceNotifyInfo         "Info Message"                              { channel="lametrictime:device:demo:info" }
String DeviceNotifyWarning      "Warning Message"                           { channel="lametrictime:device:demo:warning" }
String DeviceNotifyAlert        "Alert Message"                             { channel="lametrictime:device:demo:alert" }
Switch NotifyInfo               "Notify Info"
Switch NotifyWarning            "Notify Warning"
Switch NotifyAlert              "Notify Alert"

DateTime ClockSetAlarm          "Set Alarm"                                 { channel="lametrictime:clockApp:demo:clock:setAlarm" }
String   ClockCommand           "Clock Command"                             { channel="lametrictime:clockApp:demo:clock:command" }
Switch   SetAlarmIn1Min         "Set Alarm in 1 min"

Number TimerDuration            "Timer Duration"                            { channel="lametrictime:countdownApp:demo:timer:duration" }
String TimerCommand             "Timer Command"                             { channel="lametrictime:countdownApp:demo:timer:command" }
Switch Set2MinTimer             "Set 2 Minute Timer"

Player RadioControl             "Player"                                    { channel="lametrictime:radioApp:demo:radio:control" }

String StopwatchCommand         "Stopwatch Command"                         { channel="lametrictime:stopwatchApp:demo:stopwatch:command" }

String WeatherCommand           "Weather Command"                           { channel="lametrictime:weatherApp:demo:weather:command" }

Sitemap ​

Sample sitemap configuration:

Note: Populating switch or selection options automatically from the state description is not currently possible with sitemaps. For this reason, the brightness modes and example applications are repeated here.

dsl
  Text label="LaMetric Time Demo" {
      Frame label="Device Controls" {
          Slider item=DeviceBrightness
          Switch item=DeviceBrightnessMode mappings=[AUTO="Automatic",MANUAL="Manual"]
          Slider item=DeviceVolume
          Switch item=DeviceBluetooth
          Selection item=DeviceApp mappings=["com.lametric.clock:widgetid"="Clock","com.lametric.countdown:widgetid"="Timer"]
      }
      Frame label="Device Notifications" {
          Switch item=NotifyInfo
          Switch item=NotifyWarning
          Switch item=NotifyAlert
      }
      Frame label="Clock" {
          Switch item=SetAlarmIn1Min
          Selection item=ClockCommand mappings=["disableAlarm"="Disable Alarm"]
      }
      Frame label="Timer" {
          Switch item=Set2MinTimer
          Selection item=TimerCommand mappings=["start"="Start","pause"="Pause","reset"="Reset"]
      }
      Frame label="Radio" {
          Default item=RadioControl
      }
      Frame label="Stopwatch" {
          Selection item=StopwatchCommand mappings=["start"="Start","pause"="Pause","reset"="Reset"]
      }
      Frame label="Weather" {
          Selection item=WeatherCommand mappings=["forecast"="Forecast"]
      }
  }

Rules ​

Sample rules:

rules
import java.util.Calendar

rule "Notify Info"
    when
        Item NotifyInfo changed to ON
    then
        NotifyInfo.postUpdate(OFF)

        logInfo("demo.rules", "Sending info notification")
        DeviceNotifyInfo.sendCommand("INFO!")
end

rule "Notify Warning"
    when
        Item NotifyWarning changed to ON
    then
        NotifyWarning.postUpdate(OFF)

        logInfo("demo.rules", "Sending warning notification")
        DeviceNotifyWarning.sendCommand("WARNING!")
end

rule "Notify Alert"
    when
        Item NotifyAlert changed to ON
    then
        NotifyAlert.postUpdate(OFF)

        logInfo("demo.rules", "Sending alert notification")
        DeviceNotifyAlert.sendCommand("ALERT!")
end

rule "Set Alarm in 1 Minute"
    when
         Item SetAlarmIn1Min changed to ON
    then
         SetAlarmIn1Min.postUpdate(OFF)

         logInfo("demo.rules", "Setting alarm for 1 minute from now")

         val cal = Calendar.getInstance()
         cal.add(Calendar.MINUTE, 1)
         ClockSetAlarm.sendCommand(new DateTimeType(cal))
end

rule "Set 2 Minute Timer"
    when
         Item Set2MinTimer changed to ON
    then
         Set2MinTimer.postUpdate(OFF)

         logInfo("demo.rules", "Configure timer for 2 minutes without starting")
         TimerDuration.sendCommand(120)
end