Skip to content

MQTT Awtrix 3 Binding ​

This binding allows you to control Awtrix 3 (formerly Awtrix Light) LED matrix displays via MQTT. Awtrix 3 is a firmware for a 32x8 LED matrix display that can show various information like time, weather, notifications and custom text/graphics. The most popular choice for a device that supports the Awtrix 3 firmware is the Ulanzi tc0001 clock.

The binding also supports clocks that run AWTRIX NG, see AWTRIX NG.

Supported Things ​

This binding supports two types of things:

Thing TypeDescription
awtrix-clock (Bridge)Represents an Awtrix 3 display device. Acts as a bridge for apps.
awtrix-appRepresents an app running on the Awtrix display. Apps can show text, icons, notifications, etc.

The binding was tested with the Ulanzi tc0001 clock.

Discovery ​

The binding can automatically discover Awtrix 3 devices that publish their status to the configured MQTT broker. Make sure to use a mqtt prefix that starts with awtrix for discovery to work. It is however recommended to use a prefix with two topic levels, for example awtrix/clock1 so that you can discover and control multiple devices. Once a device is discovered, it will appear in the inbox. There is no need to trigger a discovery scan manually. Default Awtrix apps can also be discovered if discoverDefaultApps is enabled on the bridge. This is however not recommended as the default apps cannot be controlled with this binding.

Binding Configuration ​

The Awtrix 3 binding does not offer any binding configuration parameters.

Thing Configuration ​

Bridge Configuration (awtrix-clock) ​

ParameterDescriptionDefaultRequired
basetopicThe MQTT base topic for the Awtrix device"awtrix"Yes
appLockTimeoutTimeout in seconds before releasing the lock to a selected app and returning to normal app cycle (see App Configuration for more details).10Yes
discoverDefaultAppsEnable discovery of default apps. Since default apps cannot be controlled by this binding this should usually be disabled.falseYes
lowBatteryThresholdBattery level threshold for low battery warning.25Yes

App Configuration (awtrix-app) ​

ParameterDescriptionDefaultRequired
appnameName of the app-Yes
useButtonsEnable button control for this appfalseNo

When you enable the button control for an app, you can lock the app to the display by pushing the select button on the clock device. A red indicator will be shown while the app is locked and will start to blink shortly before the lock ends. The lock will last for the appLockTimeout set for the bridge. As long as the app is locked the normal app cycle is disabled and you can control the app by pressing the left and right buttons or the select button on the clock device. Pressing a button while the app is locked will reset the lock timeout to the value set for appLockTimeout. Left and right button presses will emit button events on the clock itself and the selected app. The button events can be used by rules to change the displayed app or perform any other actions (for example change the text color of the app or skip the current song playing on your audio device).

Channels ​

Bridge Channels (awtrix-clock) ​

ChannelTypeRead/WriteDescription
appStringRCurrently active app: Will show the name of the app that is currently shown on the display.
auto-brightnessSwitchRWAutomatic brightness control: The clock will adjust the display brightness automatically based on ambient light.
battery-levelNumberRBattery level: The battery level of the internal battery in percent.
brightnessDimmerRWDisplay brightness: The brightness of the display in percent.
button-leftTriggerRLeft button press event: Triggered when the left button is pressed/released (Event PRESSED or RELEASED).
button-rightTriggerRRight button press event: Triggered when the right button is pressed/released (Event PRESSED or RELEASED).
button-selectTriggerRSelect button press event: Triggered when the select button is pressed/released (Event PRESSED or RELEASED).
displaySwitchRWDisplay on/off: Switches the display on or off. The clock will still stay on while the display is off.
humidityNumber:DimensionlessRRelative humidity: Relative humidity in percent. For the Ulanzi clock values are usually very inaccurate.
indicator-1SwitchRWControl first indicator LED: Switches the first indicator LED on or off. The color of the LED will be green but can be customised by using Thing actions (you can also use blinking/fading effects).
indicator-2SwitchRWControl second indicator LED: Switches the second indicator LED on or off.The color of the LED will be green but can be customised by using Thing actions (you can also use blinking/fading effects).
indicator-3SwitchRWControl third indicator LED: Switches the third indicator LED on or off. The color of the LED will be green but can be customised by using Thing actions (you can also use blinking/fading effects).
low-batterySwitchRLow battery warning: Will be switched ON as soon as the battery level drops below the lowBatteryThreshold set for the bridge.
luxNumber:IlluminanceRAmbient light level: Ambient light level in lux as measured by the built-in light sensor.
rssiNumber:DimensionlessRWiFi signal strength (RSSI): WiFi signal strength (RSSI) in dBm.
rtttlStringWPlay RTTTL ringtone: Play a ringtone specified in RTTTL format (see https://de.wikipedia.org/wiki/Ring_Tones_Text_Transfer_Language)
screenStringRScreen image: Allows you to mirror the screen image from the clock. The screen image will be updated automatically when the app changes but can be updated manually by sending a RefreshType command to the channel.
soundStringWPlay sound file: The sound file must be available on the clock device in the MELODIES folder. Save a file with a valid RTTTL string (e.g. melody.txt) in this folder and play it by sending a String command to the channel with the filename without file extension (e.g. "melody").
temperatureNumber:TemperatureRDevice temperature: Temperature in °C as measured by the built-in temperature sensor. For the Ulanzi clock values are usually very inaccurate.

App Channels (awtrix-app) ​

ChannelTypeRead/WriteDescription
active*SwitchRWEnable/disable the app: Switches the app on or off. Note that channels of inactive apps will be reset to their default values during a restart of openHAB.
autoscaleSwitchRWEnable/disable autoscaling for bar and line chart.
backgroundColorRWSets a background color.
barStringRWShows a bar chart: Send a string with values separated by commas (e.g. "value1,value2,value3"). Only the last 16 values will be displayed.
blinkNumber:TimeRWBlink text: Blink the text in the specified interval. Ignored if rainbow or gradient-color is set.
centerSwitchRWCenter short text horizontally and disable scrolling.
colorColorRWText, bar or line chart color.
durationNumber:TimeRWDisplay duration in seconds.
effectStringRWDisplay effect (see https://blueforcer.github.io/awtrix3/#/effects for possible values).
effect-blendSwitchRWEnable smoother effect transitions. Only to be used with effect.
effect-paletteStringRWColor palette for effects (see https://blueforcer.github.io/awtrix3/#/effects for possible values and how to create custom palettes). Only to be used with effect.
effect-speedNumber:DimensionlessRWEffect animation speed: Higher means faster (see https://blueforcer.github.io/awtrix3/#/effects). Only to be used with effect.
fadeNumber:TimeRWFade text: Fades the text in and out in the specified interval. Ignored if rainbow, gradient-color or blink is set.
gradient-colorColorRWSecondary color for gradient effects. Use color for setting the primary color.
iconStringRWIcon name to display: Install icons on the clock device first.
lifetime*Number:TimeRWApp lifetime: Define how long the app will remain active on the clock.
lifetime-mode*StringRWLifetime mode: Define if the app should be deleted (Command DELETE) or marked as stale (Command STALE) after lifetime.
lineStringRWShows a line chart: Send a string with values separated by commas (e.g. "value1,value2,value3"). Only the last 16 values will be displayed.
overlayStringRWEnable overlay mode: Shows a weather overlay effect (can be any of clear, snow, rain, drizzle, storm, thunder, frost).
progressNumber:DimensionlessRWProgress value: Shows a progress bar at the bottom of the app with the specified percentage value.
progress-backgroundColorRWProgress bar background color: Background color for the progress bar.
progress-colorColorRWProgress bar color: Color for the progress bar.
push-iconStringRWPush icon animation (STATIC=Icon doesn't move, PUSHOUT=Icon moves with text and will not appear again, PUSHOUTRETURN=Icon moves with text but appears again when the text starts to scroll again).
rainbowSwitchRWEnable rainbow effect: Uses a rainbow effect for the displayed text. Overrides color, gradient-color, blink and fade.
reset*SwitchRWReset app to default state: All channels will be reset to their default values.
scroll-speedNumber:DimensionlessRWText scrolling speed: Provide as percentage value. The original speed is 100%. Values above 100% will increase the scrolling speed, values below 100% will decrease it. Setting this value to 0 will disable scrolling completely.
textStringRWText to display. Supports inline color formatting with font color tags (see Text Color Tags section below for details).
text-caseNumber:DimensionlessRWSet text case (0=default, 1=uppercase, 2=unchanged).
text-offsetNumber:DimensionlessRWText offset position: Horizontal offset of the text in pixels.
top-textSwitchRWDraws the text on the top of the display.

* Cannot be used with notification Actions (see section Actions)

Text Color Tags ​

The text channel supports inline color formatting using simple HTML-like font color tags. This allows you to display text with multiple colors in a single app.

Syntax ​

Use the following format to apply colors to specific parts of your text:

html
<font color="#RRGGBB">colored text</font>

Where RRGGBB is a 6-digit hexadecimal color code (e.g., FF0000 for red, 00FF00 for green, 0000FF for blue).

Examples ​

dsl
// Multiple colored segments - "Hello" and "in" will use the color from the color channel, "World" and "Color" will use the specified colors
items.Custom_Text.sendCommand("Hello <font color=\"#FF0000\">World</font> in <font color=\"#00FF00\">Color</font>")

// All text in custom color
items.Custom_Text.sendCommand("<font color=\"#FF6600\">Temperature: 25°C</font>")

Important Notes ​

  • Default color: Text outside of <font> tags will be displayed in the color defined by the color channel.
  • Text effects: When color tags are used, the gradient-color and rainbow channel are ignored. Therefore blink and fade will also work in conjunction with text color tags even when rainbow and/or gradient-color were set.
  • Tags cannot be nested: <font> tags must not be placed inside other <font> tags. Nesting is not supported and will result in incorrect parsing.
  • Case-insensitive hex values: Both uppercase and lowercase hex values are supported (e.g., #FF0000 or #ff0000).
  • Malformed tags: If a tag is malformed (e.g., missing closing tag), the parser will gracefully handle it by applying the default color.

Actions ​

The binding supports various actions that can be used in rules to control the Awtrix display. To use these actions, you need to import them in your rules (see examples below).

The following actions are supported:

Action NameDescriptionParameter TypeParameter NameParameter Description
blinkIndicatorBlink an indicator LED.intindicatorId1 for top indicator, 2 for center indicator or 3 for bottom indicator.
int[]rgbProvide an array with exactly 3 values for red, green and blue (in the range 0-255).
intblinkTimeInMsProvide the blink time in milliseconds.
fadeIndicatorFade an indicator LED in and out.intindicatorId1 for top indicator, 2 for center indicator or 3 for bottom indicator.
int[]rgbProvide an array with exactly 3 values for red, green and blue (in the range 0-255).
intfadeTimeInMsProvide the fade time in milliseconds.
activateIndicatorActivate an indicator LED.intindicatorId1 for top indicator, 2 for center indicator or 3 for bottom indicator.
int[]rgbProvide an array with exactly 3 values for red, green and blue (in the range 0-255).
deactivateIndicatorDeactivate an indicator LED.intindicatorId1 for top indicator, 2 for center indicator or 3 for bottom indicator.
rebootReboot the device
sleepMake the device sleep for a number of seconds.intsecondsDevice will wake up after the specified number of seconds. Sleep can only be interrupted by a press of the select button.
upgradeUpgrade the device if a firmware update is available.
playSoundPlay a sound file saved on the device.StringmelodyThe sound file name saved in the clocks MELODIES folder (without the file extension).
playRtttlPlay a rtttl sound.StringrtttlThe rtttl string to play.
showNotificationShow a notification.StringmessageThe message to show.
StringiconThe name of the icon saved on the device that is shown with the message.
showCustomNotificationShow a notification with maximal customization options.Map<String, Object>appParamsMap that holds any parameter that is available for an Awtrix App as shown in the App Channels section of the documentation. Use the channel ids in the App Channels section as keys.
booleanholdWhether the notification should stay on the screen until the user presses the select button.
booleanwakeUpWhether the notification should wake up the device if the display is currently switched off.
booleanstackWhether the notification should be stacked on top of the previous notification or replace the currently active notification.
StringrtttlPlay the specified rtttl sound when displaying the notification.
StringrtttlPlay the specified rtttl ringtone when displaying the notification. Set to null for no sound or when the sound parameter is set.
StringsoundPlay the specified sound file when displaying the notification. Set to null for no sound or when the rtttl parameter is set.
booleanloopSoundWhether the sound should be played in a loop until the notification is dismissed.
dismissNotificationDismisses the currently shown notification.

Full Example ​

Things ​

dsl
Bridge mqtt:broker:myBroker [ host="localhost", port=1883 ]
{
    Bridge mqtt:awtrix-clock:myBroker:myAwtrix "Living Room Display" (mqtt:broker:myBroker) [ basetopic="awtrix", appLockTimeout=10, lowBatteryThreshold=25 ] {
        Thing awtrix-app washing "My Washing Machine App" [ appname="washing", useButtons=true ]
        Thing awtrix-app doorbell "My Doorbell App" [ appname="doorbell" ]
        Thing awtrix-app mediaplayer "My MediaPlayer App" [ appname="mediaplayer" ]
        Thing awtrix-app other "My Other App" [ appname="other" ]
    }
}

Items ​

dsl
// Bridge items (Living Room Display)
Group gAwtrix "Living Room Awtrix Display" <screen>
Dimmer Display_Brightness "Brightness [%d %%]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:brightness" }
Switch Display_Screen "Screen" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:display" }
String Display_SoundFile "Sound File" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:sound" }
Switch Display_AutoBrightness "Auto Brightness" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:auto-brightness" }
Number:Temperature Display_Temperature "Temperature [%.1f °C]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:temperature" }
Number:Dimensionless Display_Humidity "Humidity [%d %%]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:humidity" }
Number Display_Battery "Battery Level [%d %%]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:battery-level" }
Switch Display_LowBattery "Low Battery" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:low-battery" }
Number:Power Display_WiFi "WiFi Signal [%d dBm]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:rssi", unit="dBm" }
String Display_CurrentApp "Active App [%s]" (gAwtrix) { channel="mqtt:awtrix-clock:myBroker:myAwtrix:app" }

// Washing Machine App items
Group gAwtrixWashing "Washing Machine App"
Switch Washing_Active "Washing Active" (gAwtrixWashing) { channel="mqtt:awtrix-app:myBroker:myAwtrix:washing:active" }
String Washing_Text "Washing Text" (gAwtrixWashing) { channel="mqtt:awtrix-app:myBroker:myAwtrix:washing:text" }
Color Washing_Color "Washing Color" (gAwtrixWashing) { channel="mqtt:awtrix-app:myBroker:myAwtrix:washing:color" }
Number Washing_Duration "Washing Duration" (gAwtrixWashing) { channel="mqtt:awtrix-app:myBroker:myAwtrix:washing:duration" }

// Doorbell App items
Group gAwtrixDoorbell "Doorbell App"
Switch Doorbell_Active "Doorbell Active" (gAwtrixDoorbell) { channel="mqtt:awtrix-app:myBroker:myAwtrix:doorbell:active" }
String Doorbell_Text "Doorbell Text" (gAwtrixDoorbell) { channel="mqtt:awtrix-app:myBroker:myAwtrix:doorbell:text" }
String Doorbell_Icon "Doorbell Icon" (gAwtrixDoorbell) { channel="mqtt:awtrix-app:myBroker:myAwtrix:doorbell:icon" }
Color Doorbell_Color "Doorbell Color" (gAwtrixDoorbell) { channel="mqtt:awtrix-app:myBroker:myAwtrix:doorbell:color" }
Switch Doorbell_Top_Text "Doorbell Top Text" (gAwtrixDoorbell) { channel="mqtt:awtrix-app:myBroker:myAwtrix:doorbell:top-text" }

// Media Player App items with advanced features
Group gAwtrixMediaPlayer "Media Player App"
Switch MediaPlayer_Active "Media Player Active" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:active" }
String MediaPlayer_Text "Media Player Text" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:text" }
String MediaPlayer_Icon "Media Player Icon" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:icon" }
Color MediaPlayer_Color "Media Player Color" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:color" }
Color MediaPlayer_Background "Background Color" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:background" }
Number:Dimensionless MediaPlayer_ScrollSpeed "Scroll Speed" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:scroll-speed" }
Switch MediaPlayer_Center "Center Text" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:center" }
Number:Dimensionless MediaPlayer_Progress "Progress [%d %%]" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:progress" }
Color MediaPlayer_ProgressColor "Progress Color" (gAwtrixMediaPlayer) { channel="mqtt:awtrix-app:myBroker:myAwtrix:mediaplayer:progress-color" }

Sitemap ​

dsl

sitemap awtrix label="Awtrix Display" {
    Frame label="Display Control" {
        Switch item=Display_Power
        Slider item=Display_Brightness
        Switch item=Display_Screen
        Switch item=Display_Sound
        Switch item=Display_AutoBrightness
        Text item=Display_Temperature
        Text item=Display_Humidity
        Text item=Display_Battery visibility=[Display_LowBattery==ON]
        Text item=Display_WiFi
        Text item=Display_CurrentApp
    }
    
    Frame label="Washing Machine App" {
        Switch item=Washing_Active
        Text item=Washing_Text
        Colorpicker item=Washing_Color
        Slider item=Washing_Duration
    }
    
    Frame label="Doorbell App" {
        Switch item=Doorbell_Active
        Text item=Doorbell_Text
        Text item=Doorbell_Icon
        Colorpicker item=Doorbell_Color
        Switch item=Doorbell_Top_Text
    }
    
    Frame label="Media Player App" {
        Switch item=MediaPlayer_Active
        Text item=MediaPlayer_Text
        Text item=MediaPlayer_Icon
        Colorpicker item=MediaPlayer_Color
        Colorpicker item=MediaPlayer_Background
        Slider item=MediaPlayer_ScrollSpeed
        Switch item=MediaPlayer_Center
        Slider item=MediaPlayer_Progress
        Colorpicker item=MediaPlayer_ProgressColor
    }
}

Actions ​

The binding provides various actions that can be used in rules to control the Awtrix display. To use these actions, you need to import them in your rules.

Rules DSL:

rules
val awtrixActions = getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix")

JS Scripting:

rules
var awtrixActions = actions.thingActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix");

Indicator Control ​

Control the three indicator LEDs on the Awtrix display (JS Scripting):

java
// Blink indicator 1 in red for 1 second
awtrixActions.blinkIndicator(1, [255,0,0], 1000)

// Fade indicator 2 to blue over 2 seconds
awtrixActions.fadeIndicator(2, [0,0,255], 2000)

// Turn on indicator 3 in green
awtrixActions.activateIndicator(3, [0,255,0])

// Turn off indicator 1
awtrixActions.deactivateIndicator(1)

Device Control ​

Control basic device functions:

java
// Reboot the device
awtrixActions.reboot()

// Put device to sleep for 60 seconds
awtrixActions.sleep(60)

// Perform firmware upgrade
awtrixActions.upgrade()

Sound Control ​

Play sounds and melodies:

java
// Play a predefined sound file (without extension)
awtrixActions.playSound("notification")

// Play an RTTTL melody
awtrixActions.playRtttl("Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6")

Notifications ​

Display notifications on the screen:

rules
// Show simple notification with icon
awtrixActions.showNotification("Hello World", "alert")

// Show custom notification with advanced options
val params = newHashMap(
    'text' -> 'Custom Message',
    'icon' -> 'warning',
    'color' -> newArrayList(255,165,0),  // Orange color
    'rainbow' -> true,
    'duration' -> 10
)
awtrixActions.showCustomNotification(
    params,     // Notification parameters
    false,      // hold: Keep notification until manually cleared
    true,       // wakeUp: Wake up from screen saver
    true,       // stack: Add to notification stack
    "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6", // RTTTL sound to play (not both sound and rtttl)
    "alert",    // Sound file to play (not both sound and rtttl)
    false       // loopSound: Loop the sound until manually stopped
)

Custom Notification Parameters ​

The action method parameters:

ParameterTypeDescription
holdBooleanKeep notification until manually cleared
wakeUpBooleanWake up from screen saver
stackBooleanAdd to notification stack
rtttlStringRTTTL melody to play
soundStringSound file to play (without extension)
loopSoundBooleanLoop the sound
paramsMapNotification parameters

The showCustomNotification action accepts all app channels as shown above as parameters in the params map.

Rule Examples ​

Here are some example rules demonstrating various features:

rules

rule "Battery Status Indicator Demo"
when
    Item Display_Battery changed
then
    if (Display_Battery.state <= 20) {
        // Show low battery warning with blinking red indicator
        getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").blinkIndicator(1, [255,0,0], 500)
        getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").showNotification("Low Battery!", "battery-alert")
    } else if (Display_Battery.state <= 50) {
        // Show yellow indicator for medium battery
        getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").setIndicator(1, [255,255,0])
    } else {
        // Show green indicator for good battery
        getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").setIndicator(1, [0,255,0])
    }
end

rule "Door Bell Demo"
when
    Item Doorbell_Button changed to ON
then
    // Play sound and show notification
    getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").playRtttl("doorbell:d=4,o=6,b=100:8e,8g,8e,8c")
    
    var params = newHashMap(
        'text' -> "Doorbell",
        'icon' -> "bell-ring",
        'color' -> newArrayList(0,255,255),  // Cyan color
        'pushIcon' -> "PUSHOUT",
        'center' -> true
    )
    getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").showCustomNotification(
        params, false, true, true, "", "", false
    )
end

rule "Progress Bar Demo"
when
    Item Washing_Machine_Progress changed
then
    var progress = (Washing_Machine_Progress.state as Number).intValue
    
    // Update custom app with progress bar
    Custom_Text.sendCommand("Washing")
    Custom_Icon.sendCommand("washing-machine")
    Custom_Progress.sendCommand(progress)
    Custom_ProgressColor.sendCommand("0,255,0")  // Green progress bar
    
    if (progress == 100) {
        // Play sound when done
        getActions("mqtt.awtrixlight", "mqtt:awtrix-clock:myBroker:myAwtrix").playSound("complete")
    }
end

These rules demonstrate:

  • Using indicators to show battery status
  • Creating custom notifications with icons and colors
  • Playing RTTTL melodies and sound files
  • Displaying progress bars

AWTRIX NG ​

Clocks that run the AWTRIX NG firmware, the successor of AWTRIX 3, are supported with their own thing types. AWTRIX NG changed the MQTT topics and the payloads of AWTRIX 3, so the things, channels and rule actions differ from the ones above. Where the two differ, the AWTRIX NG things follow AWTRIX NG. Notes on the changes of the firmware are in the migration guide of AWTRIX NG.

AWTRIX NG Things ​

Thing TypeDescription
awtrix-ng-clock (Bridge)An AWTRIX NG clock. It is a bridge for the apps, and a child of the MQTT broker bridge (broker).
awtrix-ng-appAn app that openHAB pushes to the clock: text, icon, charts, progress bar, effects and drawings.

AWTRIX NG Discovery ​

The clock is discovered from the retained <prefix>/state/device message that it publishes. Enable MQTT in the web interface of the clock, point it to the broker of the MQTT bridge in openHAB, and the clock shows up in the inbox. The default prefix of AWTRIX NG is the MAC address of the clock (12 lowercase hexadecimal digits), which is used as the basetopic.

A prefix with several levels (home/clock1) is not discovered, because the discovery only looks at the first topic level. Add such a clock manually and enter the prefix as basetopic.

Apps that are shown on the clock but unknown to openHAB are offered in the inbox of the bridge. The built-in apps of the clock (Time, Date, Temperature, Humidity and Battery) are only offered when discoverDefaultApps is enabled, and the Notification app is never offered.

Adopting a discovered app replaces it. AWTRIX NG offers no way to read what another system has pushed to an app. When you accept a discovered app, the binding pushes an app with the same name that is empty at first, and your channels fill it from then on. Whatever the other system had pushed under that name is gone. Accept an app only when openHAB is meant to take it over.

AWTRIX NG Thing Configuration ​

Bridge Configuration (awtrix-ng-clock) ​

ParameterDescriptionDefaultRequired
basetopicMQTT prefix of the clock, as shown in its MQTT settings. By default this is its 12 character MAC address.-Yes
appLockTimeoutSeconds until an app that was locked with the select button (see useButtons) releases the clock again.10No
discoverDefaultAppsAlso offer the built-in apps of the clock in the inbox. Their look is only controlled by the clock settings.falseNo

App Configuration (awtrix-ng-app) ​

ParameterDescriptionDefaultRequired
appnameName of the app on the clock: 1 to 32 letters, digits, - or _.-Yes
useButtonsLet the buttons of the clock lock the app and trigger the button channels of it.falseNo

With useButtons enabled, pressing the select button locks the app on the display. While the app is locked, the automatic app rotation and the button navigation of the clock are switched off, and the third indicator shows red. The indicator starts to fade in and out for the last seconds before the lock ends. The left and right buttons, and the select button, trigger the button channels of the clock and of the locked app while the lock lasts. Each press renews the lock for appLockTimeout seconds. When the lock ends, the binding restores the rotation and navigation settings and the third indicator as the clock reported them before the lock. If the clock is offline when the lock ends, this happens when it is back online. That state is also kept on the broker (<prefix>/openhab/applock), so that an openHAB restart during a lock does not leave the clock stuck. A lock on the broker that this openHAB did not create is taken for one that was left behind and is ended. A clock that is offline cannot be set back, so the lock is ended when a clock thing with the same broker and base topic starts again. If the thing is removed or moved to another broker or base topic while the clock is offline during a lock, the clock keeps the lock settings. In that case, set them back on the clock and clear the retained <prefix>/openhab/applock message, for example with mosquitto_pub -r -n -t <prefix>/openhab/applock. Do not let two openHAB instances use the same clock with useButtons, as they would end each other's locks.

How AWTRIX NG Apps Are Kept ​

AWTRIX NG does not keep pushed apps over a reboot, and the commands of the binding are not retained on the broker. Each app handler therefore pushes its app again whenever the clock sends its capabilities, which it does every time it connects. The state of an app, which openHAB needs after a restart, is kept as a retained message on <prefix>/openhab/apps/<appname>. The clock ignores this topic. The topic is cleared when the app thing is removed.

AWTRIX NG Channels ​

The option lists of the channels transition-effect and overlay of the clock, and effect, overlay and font of the apps, are filled from what the clock reports as its capabilities.

Durations are in milliseconds, as in the API of AWTRIX NG. A command without a unit is taken as milliseconds, a quantity such as 7.5 s is converted.

Bridge Channels (awtrix-ng-clock) ​

ChannelTypeR/WDescription
alert-volumeNumber:DimensionlessRWAlert Volume: Share of the master volume for notifications and alerts
appStringRWActive App: App currently shown on the screen. A command switches to the app with that name.
app-durationNumber:TimeRWApp Duration: Display time per app and default duration of a notification
app-volumeNumber:DimensionlessRWApp Volume: Share of the master volume for the sounds of scripts
auto-brightnessSwitchRWAutomatic Brightness: Let the clock set the brightness automatically based on its light sensor
auto-transitionSwitchRWAutomatic App Rotation: Rotate through the apps automatically
battery-colorColorRWBattery Color: Text color of the battery app
battery-levelNumber:DimensionlessRBattery Level: Battery level in percent
battery-voltageNumber:ElectricPotentialRBattery Voltage: Battery voltage calculated from the battery pin
block-navigationSwitchRWBlock Button Navigation: Disable app switching, display toggle and menu with the buttons. Button events are still reported.
brightnessNumber:DimensionlessRWDisplay Brightness: Screen brightness in percent. Setting it switches the automatic brightness off.
button-leftTriggerRButton Left: Left button pressed or released
button-rightTriggerRButton Right: Right button pressed or released
button-selectTriggerRButton Select: Select button pressed or released
calendar-body-colorColorRWCalendar Body Color: Background of the calendar box
calendar-header-colorColorRWCalendar Header Color: Top bar of the calendar box
calendar-text-colorColorRWCalendar Text Color: Day number of the calendar box
date-colorColorRWDate Color: Text color of the date
date-month-namesSwitchRWDate Month Names: Use three letter month names instead of numbers
date-orderStringRWDate Order: Order of day, month and year
date-separatorStringRWDate Separator: Character between the parts of the date
date-show-weekdaySwitchRWDate Weekday: Prepend the weekday to the date
date-year-modeStringRWDate Year: How the year is shown
displaySwitchRWDisplay Power: Switches the display ON or OFF
errorTriggerRCommand Error: Triggered with the JSON reported by the clock when it rejected a command
fpsNumberRFrame Rate: Actual display refresh rate in frames per second
free-heapNumber:DataAmountRFree Memory: Free heap memory of the clock
humidityNumber:DimensionlessRHumidity: Relative humidity
humidity-colorColorRWHumidity Color: Text color of the humidity app
indicator-1ColorRWIndicator 1: Color of the indicator dot. ON uses green, OFF or black switches the indicator off.
indicator-2ColorRWIndicator 2: Color of the indicator dot. ON uses green, OFF or black switches the indicator off.
indicator-3ColorRWIndicator 3: Color of the indicator dot. ON uses green, OFF or black switches the indicator off.
ip-addressStringRIP Address: Network address of the clock
light-levelNumber:DimensionlessRLight Level: Ambient light as a relative percentage (not lux)
low-batterySwitchRLow Battery: Low battery warning of the clock
moodlightColorRWMood Light: Fills the display with a color. ON uses white, OFF or black switches the mood light off. The clock does not report its state.
overlayStringRWWeather Overlay: Weather effect over the whole display. An empty command clears it. The clock does not report its state.
pressureNumber:PressureRPressure: Air pressure
rssiNumber:PowerRWiFi Signal: RSSI value of the WiFi signal
rtttlStringWPlay RTTTL: Plays a melody in RTTTL notation, e.g. "two:d=4,o=5,b=200:c,e"
screenImageRScreen Mirror: Image of the screen of the clock. It is refreshed when the app changes, or on a REFRESH command.
soundStringWPlay Sound: Plays the stored sound with the given name
temperatureNumber:TemperatureRTemperature: Temperature measured by the clock
temperature-colorColorRWTemperature Color: Text color of the temperature app
text-colorColorRWText Color: Default text color
time-24hSwitchRW24 Hour Clock: 24 hour format, otherwise 12 hour
time-colorColorRWClock Color: Text color of the clock
time-leading-zeroSwitchRWLeading Zero: Show the hour with two digits
time-modeNumberRWClock Style: Layout of the clock app
time-separatorStringRWClock Separator: Behavior of the colon of the clock
time-show-ampmSwitchRWShow AM/PM: Show AM or PM, needs the 12 hour format and hidden when seconds are shown
time-show-secondsSwitchRWShow Seconds: Show the seconds in the clock
transition-directionStringRWTransition Direction: Reverses directional transitions
transition-durationNumber:TimeRWTransition Duration: Length of the animation between apps, 0 for instant
transition-effectStringRWTransition Effect: Animation between apps
uppercaseSwitchRWUppercase: Show pushed apps and notifications in capitals
uptimeNumber:TimeRUptime: Time since the last start of the clock
use-celsiusSwitchRWUse Celsius: Show the temperature in Celsius, otherwise in Fahrenheit
volumeNumber:DimensionlessRWMaster Volume: Master volume, 0 silences everything
weekday-bar-active-colorColorRWWeekday Bar Active Color: Color of the current day if it is a workday
weekday-bar-inactive-colorColorRWWeekday Bar Inactive Color: Color of the other workdays
weekday-bar-showSwitchRWWeekday Bar: Show the weekday bar of the clock app
weekday-bar-start-on-mondaySwitchRWWeek Starts on Monday: The weekday bar starts on Monday, otherwise on Sunday

The clock does not report the state of moodlight and overlay, so these two channels keep what was last sent. The settings channels are written to <prefix>/cmd/settings and are read back from <prefix>/state/settings.

App Channels (awtrix-ng-app) ​

ChannelTypeR/WDescription
activeSwitchRActive: The app is shown on the clock right now
background-colorColorRWBackground Color: Color of the background
bar-chartStringRWBar Chart: Comma separated values of a bar chart, at most the newest 16
button-leftTriggerRButton Left: Left button pressed or released while the app is locked for button control
button-rightTriggerRButton Right: Right button pressed or released while the app is locked for button control
button-selectTriggerRButton Select: Select button pressed or released while the app is locked for button control
chart-autoscaleSwitchRWChart Autoscale: Scale the chart to its values instead of a fixed range
chart-colorColorRWChart Color: Color of the chart, the text color if not set
drawStringRWDraw Commands: JSON array of draw commands, e.g. [["pixel",1,2,"#FF0000"]]
durationNumber:TimeRWDuration: How long the app is shown, 0 for the default of the clock
effectStringRWBackground Effect: Animated background of the app
effect-speedNumberRWEffect Speed: Speed of the effect, from 0.1 to 10
enabledSwitchRWEnabled: Switches the app in the rotation of the clock on or off
fontStringRWFont: Font of the text
iconStringRWIcon: ID of an icon, or an image as a data URL (data:image/gif;base64,... or data:image/jpeg;base64,...)
icon-gapNumberRWIcon Gap: Space between the icon and the text, in pixels
icon-modeStringRWIcon Mode: Whether the icon stays or moves with the text
icon-offset-xNumberRWIcon Offset: Moves the icon left or right, in pixels
iconsStringRWExtra Icons: JSON array of at most 4 extra icons, e.g. [{"icon":"1234","x":0,"y":0}]
lifetimeNumber:TimeRWLifetime: How long the app lives without an update, 0 for forever
lifetime-expiryStringRWLifetime Expiry: Whether an expired app is removed or only marked
line-chartStringRWLine Chart: Comma separated values of a line chart, at most the newest 16
overlayStringRWWeather Overlay: Weather effect over the app
paletteStringRWPalette: Name of a built-in palette, or colors separated by commas (#RRGGBB,#RRGGBB)
palette-blendSwitchRWPalette Blend: Smooth instead of hard transitions between the colors of the palette
palette-spanNumberRWPalette Span: Pixels after which the palette repeats, 0 to stretch it over the text
palette-speedNumberRWPalette Speed: Speed of the palette animation, 0 for none
progressNumber:DimensionlessRWProgress: Progress bar in percent, -1 switches it off
progress-colorColorRWProgress Color: Color of the filled part of the progress bar
progress-track-colorColorRWProgress Track Color: Color of the empty part of the progress bar
repeatNumberRWRepeat: Number of scroll cycles, 0 for off
resetSwitchRWReset: Sets the app back to its defaults
scroll-directionStringRWScroll Direction: Direction the text travels
scroll-entryStringRWScroll Entry: Where the text starts, inline or offscreen
scroll-gapNumberRWScroll Gap: Gap between the repetitions of a looping text, in pixels
scroll-holdNumber:TimeRWScroll Hold: Pause before and between the movements of the text
scroll-modeStringRWScroll Mode: How the text moves
scroll-speedNumber:DimensionlessRWScroll Speed: Scroll speed in percent of the base speed
scroll-when-fitsStringRWScroll When Fits: Whether text that fits the display still moves
textStringRWText: Text of the app. Parts between <font color="#RRGGBB"> and </font> are colored, text outside of the tags is white.
text-alignStringRWText Alignment: Where text that fits the display sits
text-blinkNumber:TimeRWText Blink: Blink period of the text, 0 for off
text-caseStringRWText Case: Upper or lower case of the text. inherit follows the uppercase setting of the clock.
text-colorColorRWText Color: Color of the text. Setting it switches the text palette off.
text-fadeNumber:TimeRWText Fade: Period of a smooth fade in and out of the text, 0 for off
text-in-frontSwitchRWText In Front: Draw the text on top of charts and drawings
text-offset-xNumberRWText Offset: Moves the text left or right, in pixels
text-paletteSwitchRWText Palette: Color the text from the palette of the app. Setting a text color switches it off.

The text channel supports color tags, see Text Color Tags.

Setting text-color switches text-palette off, and text-palette makes the text use the palette of the app.

The channels bar-chart and line-chart show the newest 16 values of the comma separated list.

AWTRIX NG Text Color Tags ​

The text channel colors parts of the text with font tags:

html
<font color="#RRGGBB">colored text</font>

The color is #RRGGBB, or the short form #RGB. Text outside of the tags is white. The binding sends the colored parts to AWTRIX NG as a list of fragments.

dsl
items.Custom_Text.sendCommand("Hello <font color=\"#FF0000\">World</font> in <font color=\"#00FF00\">Color</font>")

AWTRIX NG Full Example ​

Things ​

dsl
Bridge mqtt:broker:myBroker [ host="mosquitto.local" ]

Bridge mqtt:awtrix-ng-clock:myBroker:myClock "Living Room Clock" (mqtt:broker:myBroker) [ basetopic="aabbccddeeff" ] {
    Thing awtrix-ng-app washing "Washing Machine" [ appname="washing" ]
    Thing awtrix-ng-app doorbell "Doorbell" [ appname="doorbell", useButtons=true ]
}

Items ​

dsl
Number:Dimensionless Clock_Brightness "Brightness [%d %%]" { channel="mqtt:awtrix-ng-clock:myBroker:myClock:brightness" }
Switch Clock_Display "Display" { channel="mqtt:awtrix-ng-clock:myBroker:myClock:display" }
Color Clock_Indicator1 "Indicator 1" { channel="mqtt:awtrix-ng-clock:myBroker:myClock:indicator-1" }
String Clock_App "Active App [%s]" { channel="mqtt:awtrix-ng-clock:myBroker:myClock:app" }
Image Clock_Screen "Screen" { channel="mqtt:awtrix-ng-clock:myBroker:myClock:screen" }

String Washing_Text "Text" { channel="mqtt:awtrix-ng-app:myBroker:myClock:washing:text" }
String Washing_Icon "Icon" { channel="mqtt:awtrix-ng-app:myBroker:myClock:washing:icon" }
Color Washing_Color "Color" { channel="mqtt:awtrix-ng-app:myBroker:myClock:washing:text-color" }
Number:Dimensionless Washing_Progress "Progress [%d %%]" { channel="mqtt:awtrix-ng-app:myBroker:myClock:washing:progress" }
Number:Time Washing_Duration "Duration" { channel="mqtt:awtrix-ng-app:myBroker:myClock:washing:duration" }

AWTRIX NG Rule Actions ​

The bridge offers actions in the scope mqtt.awtrixlight.

Rules DSL:

rules
val awtrix = getActions("mqtt.awtrixlight", "mqtt:awtrix-ng-clock:myBroker:myClock")

JS Scripting:

javascript
var awtrix = actions.thingActions("mqtt.awtrixlight", "mqtt:awtrix-ng-clock:myBroker:myClock");
ActionDescription
activateIndicator(indicator, color)Switches indicator 1 to 3 on in a color (#RRGGBB).
deactivateIndicator(indicator)Switches the indicator off.
blinkIndicator(indicator, color, blinkMs)Blinks the indicator.
fadeIndicator(indicator, color, fadeMs)Fades the indicator.
setMoodlight(color, brightness)Fills the display with a color. The brightness (0 to 255) may be null for the current brightness.
clearMoodlight()Switches the mood light off.
reboot()Reboots the clock.
sleep(seconds)Sends the clock to deep sleep for a number of seconds.
sleepMs(durationMs)Sends the clock to deep sleep for a number of milliseconds.
playSound(name)Plays a sound that is stored on the clock.
playRtttl(rtttl)Plays a melody in RTTTL notation.
playTrack(track)Plays a track of the DFPlayer of the clock.
stopSound(group)Stops the sounds of a group (alert, app, radio), or all sounds when empty.
nextApp(), previousApp()Switches to the next or previous app.
switchApp(name, fast)Switches to an app. fast skips the transition and may be null.
setAppOrder(order, disabled)Sets the order of the apps, and the complete list of apps that are switched off.
setAppEnabled(name, enabled)Switches one app on or off in the rotation.
showNotification(text, icon)Shows a notification with a text. The icon may be null.
showCustomNotification(params)Shows a notification with the keys of the AWTRIX NG payload.
dismissNotification()Dismisses the notification that is shown.
dismissNamedNotification(name)Dismisses the notification that was shown with the name.

Every argument has to be given, as the actions have no shorter forms. Pass null for those that may be null.

Actions of AWTRIX 3 Rules ​

Rules written for an AWTRIX 3 clock keep working after the clock was switched to AWTRIX NG, as the actions of the AWTRIX 3 clock have their counterparts:

  • blinkIndicator, fadeIndicator and activateIndicator also take the color as an [r, g, b] array.
  • sleep(seconds) takes seconds as on AWTRIX 3. AWTRIX NG counts in milliseconds, which sleepMs(durationMs) takes.
  • upgrade() does nothing but log a warning, AWTRIX NG is updated over HTTP only.
  • showCustomNotification(appParams, hold, wakeUp, stack, rtttl, sound, loopSound) takes the keys of an AWTRIX 3 notification and translates them to AWTRIX NG as described in its migration guide: keys are renamed, colors given as arrays become #RRGGBB, duration and lifetime become milliseconds, and the sound arguments become the sound of the notification. The keys topText, pos, barBC, clients, save and draw have no equivalent. They are left out, and a warning is logged. A key that is neither an AWTRIX 3 nor an AWTRIX NG key rejects the notification, as with the other form of the action.

Notifications ​

showCustomNotification takes a map with the keys of the AWTRIX NG notification payload, for example text, textColor, durationMs, hold, stack, wakeup, sound and name. Colors are #RRGGBB strings. AWTRIX NG rejects a whole payload that contains a key it does not know, so the binding checks the keys first. A notification with an unknown key, or with a value that does not fit its key, is not sent and the reason is logged. A name is limited to 1 to 32 letters, digits, - and _, because the clock needs it for the topic of dismissNamedNotification.

rules
val params = newHashMap(
    'text' -> 'Doorbell',
    'icon' -> 'bell',
    'textColor' -> '#00FFFF',
    'durationMs' -> 8000,
    'wakeup' -> true,
    'sound' -> newHashMap('file' -> 'ding'),
    'name' -> 'door'
)
awtrix.showCustomNotification(params)

Examples ​

rules
rule "Low battery indicator"
when
    Item Clock_Battery changed
then
    val awtrix = getActions("mqtt.awtrixlight", "mqtt:awtrix-ng-clock:myBroker:myClock")
    if ((Clock_Battery.state as Number).intValue <= 20) {
        awtrix.blinkIndicator(1, "#FF0000", 500)
        awtrix.showNotification("Low Battery!", "battery-alert")
    } else {
        awtrix.deactivateIndicator(1)
    }
end

rule "Door bell"
when
    Item Doorbell_Button changed to ON
then
    val awtrix = getActions("mqtt.awtrixlight", "mqtt:awtrix-ng-clock:myBroker:myClock")
    awtrix.playRtttl("doorbell:d=4,o=6,b=100:8e,8g,8e,8c")
    awtrix.showNotification("Doorbell", "bell-ring")
end

Switching from AWTRIX 3 to AWTRIX NG ​

A clock that is flashed with AWTRIX NG and keeps its MQTT prefix does not have to be set up again. The awtrix-clock thing notices the NG firmware and changes itself to an awtrix-ng-clock, and its awtrix-app things follow it to awtrix-ng-app. The thing keeps its UID, label, location and the configuration that both firmware types share (basetopic, appLockTimeout, discoverDefaultApps, and appname and useButtons of the apps). lowBatteryThreshold is gone, low-battery is reported by the clock. The change only goes this way. To use a clock with AWTRIX 3 again, delete the AWTRIX NG things and add the AWTRIX 3 things through discovery.

The clock is taken as AWTRIX NG when it sends its device state on <prefix>/state/device with a changing uptimeSeconds. AWTRIX NG sends it every statsInterval (10 seconds by default), so the change takes up to that long after the clock runs AWTRIX NG. The broker keeps the last device state of a clock, which could be left over from a clock that was flashed back to AWTRIX 3 or is switched off. That is why the first device state after connecting to the broker is not enough, the uptime in a later one has to differ. A change is logged at INFO level.

The channels of the thing are replaced by those of the new thing type. Links of channels with the same ID stay, but AWTRIX NG changed what some of them mean (see the tables below), so check the items of the changed channels. A link to a channel that the new thing type does not have stays on its item, but it has no effect any more. Link the item to the new channel and remove the old link.

AWTRIX NG only accepts app names of 1 to 32 letters, digits, - and _. An app with another name shows a configuration error after the change.

The AWTRIX 3 things keep the state of their apps as retained messages on <prefix>/custom/<appname>. AWTRIX NG ignores them, but they stay on the broker. They can be removed with an empty retained message, for example mosquitto_pub -r -n -t awtrix/custom/washing.

Notes on the changes of the firmware are in the migration guide of AWTRIX NG. Where the two differ, the AWTRIX NG things follow AWTRIX NG.

Bridge Channels After the Change ​

Awtrix 3AWTRIX NG
luxlight-level, a percentage and not lux.
indicator-1..3The same names, but a Color channel instead of a Switch.
screenThe same name, an Image channel that follows the size of the panel.
-New: voltage, memory, frame rate, IP address, uptime, volumes, rotation, clock and date format, colors, mood light, overlay, error.

App Channels After the Change ​

Awtrix 3AWTRIX NG
activeenabled switches the app in the rotation. active only reports that the app is shown.
autoscalechart-autoscale
backgroundbackground-color
bar, linebar-chart, line-chart
blink-text, fade-texttext-blink, text-fade
centertext-align
colortext-color, and chart-color for charts
duration, lifetimeThe same names, in milliseconds instead of seconds
effect-blendpalette-blend
effect-speedThe same name, from 0.1 to 10 instead of a percentage
effect-palettepalette
lifetime-modelifetime-expiry
overlayThe same name, an empty command clears the overlay instead of Clear
progress-backgroundprogress-track-color
push-iconicon-mode
rainbow, gradient-colorpalette together with text-palette
text-caseThe same name, with the words inherit, upper and asTyped
text-offsettext-offset-x
top-textRemoved, AWTRIX NG has no equivalent

New channels are the scroll settings, the icon settings (icons, icon-mode, offsets), font, repeat, palette-*, text-in-front, draw and the button triggers.