Skip to content

Commit 155a07b

Browse files
authored
[mqtt.awtrix3] Initial contribution (openhab#18242)
* Initial contribution Signed-off-by: Thomas Lauterbach <[email protected]>
1 parent d6ab538 commit 155a07b

File tree

23 files changed

+4277
-0
lines changed

23 files changed

+4277
-0
lines changed

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
/bundles/org.openhab.binding.monopriceaudio/ @mlobstein
244244
/bundles/org.openhab.binding.mpd/ @stefanroellin
245245
/bundles/org.openhab.binding.mqtt/ @ccutrer
246+
/bundles/org.openhab.binding.mqtt.awtrixlight/ @DrRSatzteil
246247
/bundles/org.openhab.binding.mqtt.espmilighthub/ @Skinah
247248
/bundles/org.openhab.binding.mqtt.fpp/ @computergeek1507
248249
/bundles/org.openhab.binding.mqtt.generic/ @ccutrer

bom/openhab-addons/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,11 @@
12011201
<artifactId>org.openhab.binding.mqtt</artifactId>
12021202
<version>${project.version}</version>
12031203
</dependency>
1204+
<dependency>
1205+
<groupId>org.openhab.addons.bundles</groupId>
1206+
<artifactId>org.openhab.binding.mqtt.awtrixlight</artifactId>
1207+
<version>${project.version}</version>
1208+
</dependency>
12041209
<dependency>
12051210
<groupId>org.openhab.addons.bundles</groupId>
12061211
<artifactId>org.openhab.binding.mqtt.espmilighthub</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-addons

bundles/org.openhab.binding.mqtt.awtrixlight/README.md

+556
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.openhab.addons.bundles</groupId>
9+
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
10+
<version>5.0.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>org.openhab.binding.mqtt.awtrixlight</artifactId>
14+
<name>openHAB Add-ons :: Bundles :: MQTT Awtrix 3</name>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.openhab.addons.bundles</groupId>
19+
<artifactId>org.openhab.binding.mqtt</artifactId>
20+
<version>${project.version}</version>
21+
<scope>provided</scope>
22+
</dependency>
23+
</dependencies>
24+
25+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<features name="org.openhab.binding.mqtt.awtrixlight-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
3+
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
4+
5+
<feature name="openhab-binding-mqtt-awtrixlight" description="MQTT Binding Awtrix Light" version="${project.version}">
6+
<feature>openhab-runtime-base</feature>
7+
<feature>openhab-transport-mqtt</feature>
8+
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version}</bundle>
9+
<bundle start-level="81">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.awtrixlight/${project.version}</bundle>
10+
</feature>
11+
12+
</features>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2010-2025 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.mqtt.awtrixlight.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* The {@link AppConfigOptions} Holds the config for the app settings.
19+
*
20+
* @author Thomas Lauterbach - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public class AppConfigOptions {
24+
public String appname = "";
25+
public boolean useButtons = false;
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/*
2+
* Copyright (c) 2010-2025 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
14+
package org.openhab.binding.mqtt.awtrixlight.internal;
15+
16+
import static org.openhab.binding.mqtt.MqttBindingConstants.BINDING_ID;
17+
18+
import java.util.Set;
19+
20+
import org.eclipse.jdt.annotation.NonNullByDefault;
21+
import org.openhab.core.thing.ThingTypeUID;
22+
23+
/**
24+
* The {@link AwtrixLightBindingConstants} class defines common constants, which are
25+
* used across the whole binding.
26+
*
27+
* @author Thomas Lauterbach - Initial contribution
28+
*/
29+
@NonNullByDefault
30+
public class AwtrixLightBindingConstants {
31+
32+
// List of all Thing Type UIDs
33+
public static final ThingTypeUID THING_TYPE_APP = new ThingTypeUID(BINDING_ID, "awtrix-app");
34+
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "awtrix-clock");
35+
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_APP, THING_TYPE_BRIDGE);
36+
37+
// Matrix Size
38+
public static final int SCREEN_HEIGHT = 8;
39+
public static final int SCREEN_WIDTH = 32;
40+
41+
// Clock Properties
42+
public static final String PROP_APPID = "appid";
43+
public static final String PROP_APPLOCKTIMEOUT = "appLockTimeout";
44+
public static final String PROP_APPNAME = "appname";
45+
public static final String PROP_APP_CONTROLLABLE = "useButtons";
46+
public static final String PROP_BASETOPIC = "basetopic";
47+
public static final String PROP_DISCOVERDEFAULT = "discoverDefaultApps";
48+
public static final String PROP_FIRMWARE = "firmware";
49+
public static final String PROP_UNIQUEID = "uniqueId";
50+
public static final String PROP_VENDOR = "vendor";
51+
52+
// Clock Topics
53+
public static final String TOPIC_BASE = "awtrix";
54+
public static final String TOPIC_BUTLEFT = "/stats/buttonLeft";
55+
public static final String TOPIC_BUTRIGHT = "/stats/buttonRight";
56+
public static final String TOPIC_BUTSELECT = "/stats/buttonSelect";
57+
public static final String TOPIC_INDICATOR1 = "/indicator1";
58+
public static final String TOPIC_INDICATOR2 = "/indicator2";
59+
public static final String TOPIC_INDICATOR3 = "/indicator3";
60+
public static final String TOPIC_NOTIFY = "/notify";
61+
public static final String TOPIC_POWER = "/power";
62+
public static final String TOPIC_REBOOT = "/reboot";
63+
public static final String TOPIC_RTTTL = "/rtttl";
64+
public static final String TOPIC_SCREEN = "/screen";
65+
public static final String TOPIC_SEND_SCREEN = "/sendscreen";
66+
public static final String TOPIC_SETTINGS = "/settings";
67+
public static final String TOPIC_SLEEP = "/sleep";
68+
public static final String TOPIC_SOUND = "/sound";
69+
public static final String TOPIC_STATS = "/stats";
70+
public static final String TOPIC_STATS_CURRENT_APP = "/stats/currentApp";
71+
public static final String TOPIC_SWITCH = "/switch";
72+
public static final String TOPIC_UPGRADE = "/doupdate";
73+
74+
// Stats fields
75+
public static final String FIELD_BRIDGE_APP = "app";
76+
public static final String FIELD_BRIDGE_BATTERY = "bat";
77+
public static final String FIELD_BRIDGE_BATTERY_RAW = "bat_raw";
78+
public static final String FIELD_BRIDGE_BRIGHTNESS = "bri";
79+
public static final String FIELD_BRIDGE_FIRMWARE = "version";
80+
public static final String FIELD_BRIDGE_HUMIDITY = "hum";
81+
public static final String FIELD_BRIDGE_INDICATOR1 = "indicator1";
82+
public static final String FIELD_BRIDGE_INDICATOR2 = "indicator2";
83+
public static final String FIELD_BRIDGE_INDICATOR3 = "indicator3";
84+
public static final String FIELD_BRIDGE_INDICATOR1_COLOR = "indicator1-color";
85+
public static final String FIELD_BRIDGE_INDICATOR2_COLOR = "indicator2-color";
86+
public static final String FIELD_BRIDGE_INDICATOR3_COLOR = "indicator3-color";
87+
public static final String FIELD_BRIDGE_LDR_RAW = "ldr_raw";
88+
public static final String FIELD_BRIDGE_LUX = "lux";
89+
public static final String FIELD_BRIDGE_MATRIX = "matrix";
90+
public static final String FIELD_BRIDGE_MESSAGES = "messages";
91+
public static final String FIELD_BRIDGE_RAM = "ram";
92+
public static final String FIELD_BRIDGE_TEMPERATURE = "temp";
93+
public static final String FIELD_BRIDGE_TYPE = "type";
94+
public static final String FIELD_BRIDGE_UID = "uid";
95+
public static final String FIELD_BRIDGE_UPTIME = "uptime";
96+
public static final String FIELD_BRIDGE_WIFI_SIGNAL = "wifi_signal";
97+
98+
// Settings fields
99+
public static final String FIELD_BRIDGE_SET_APP_TIME = "ATIME";
100+
public static final String FIELD_BRIDGE_SET_AUTO_BRIGHTNESS = "ABRI";
101+
public static final String FIELD_BRIDGE_SET_AUTO_TRANSITION = "ATRANS";
102+
public static final String FIELD_BRIDGE_SET_BLOCK_KEYS = "BLOCKN";
103+
public static final String FIELD_BRIDGE_SET_BRIGHTNESS = "BRI";
104+
public static final String FIELD_BRIDGE_SET_DISPLAY = "MATP";
105+
public static final String FIELD_BRIDGE_SET_MUTE = "SOUND";
106+
public static final String FIELD_BRIDGE_SET_SCROLL_SPEED = "SSPEED";
107+
public static final String FIELD_BRIDGE_SET_TEXT_COLOR = "TCOL";
108+
public static final String FIELD_BRIDGE_SET_TRANS_EFFECT = "TEFF";
109+
public static final String FIELD_BRIDGE_SET_TRANS_SPEED = "TSPEED";
110+
111+
// Apps
112+
public static final String BASE_APP_TOPIC = "/custom";
113+
public static final String[] DEFAULT_APPS = { "Time", "Date", "Temperature", "Humidity", "Battery" };
114+
115+
// Common Channels
116+
public static final String CHANNEL_BUTLEFT = "button-left";
117+
public static final String CHANNEL_BUTRIGHT = "button-right";
118+
public static final String CHANNEL_BUTSELECT = "button-select";
119+
120+
// Clock Channels
121+
public static final String CHANNEL_APP = "app";
122+
public static final String CHANNEL_AUTO_BRIGHTNESS = "auto-brightness";
123+
public static final String CHANNEL_BATTERY = "battery-level";
124+
public static final String CHANNEL_BRIGHTNESS = "brightness";
125+
public static final String CHANNEL_DISPLAY = "display";
126+
public static final String CHANNEL_HUMIDITY = "humidity";
127+
public static final String CHANNEL_INDICATOR1 = "indicator-1";
128+
public static final String CHANNEL_INDICATOR2 = "indicator-2";
129+
public static final String CHANNEL_INDICATOR3 = "indicator-3";
130+
public static final String CHANNEL_LOW_BATTERY = "low-battery";
131+
public static final String CHANNEL_LUX = "lux";
132+
public static final String CHANNEL_RSSI = "rssi";
133+
public static final String CHANNEL_RTTTL = "rtttl";
134+
public static final String CHANNEL_SCREEN = "screen";
135+
public static final String CHANNEL_SOUND = "sound";
136+
public static final String CHANNEL_TEMPERATURE = "temperature";
137+
138+
// App Channels
139+
public static final String CHANNEL_ACTIVE = "active";
140+
public static final String CHANNEL_AUTOSCALE = "autoscale";
141+
public static final String CHANNEL_BACKGROUND = "background";
142+
public static final String CHANNEL_BAR = "bar";
143+
public static final String CHANNEL_BLINK_TEXT = "blink-text";
144+
public static final String CHANNEL_CENTER = "center";
145+
public static final String CHANNEL_COLOR = "color";
146+
public static final String CHANNEL_DURATION = "duration";
147+
public static final String CHANNEL_EFFECT = "effect";
148+
public static final String CHANNEL_EFFECT_BLEND = "effect-blend";
149+
public static final String CHANNEL_EFFECT_PALETTE = "effect-palette";
150+
public static final String CHANNEL_EFFECT_SPEED = "effect-speed";
151+
public static final String CHANNEL_FADE_TEXT = "fade-text";
152+
public static final String CHANNEL_GRADIENT_COLOR = "gradient-color";
153+
public static final String CHANNEL_ICON = "icon";
154+
public static final String CHANNEL_LIFETIME = "lifetime";
155+
public static final String CHANNEL_LIFETIME_MODE = "lifetime-mode";
156+
public static final String CHANNEL_LINE = "line";
157+
public static final String CHANNEL_OVERLAY = "overlay";
158+
public static final String CHANNEL_PROGRESS = "progress";
159+
public static final String CHANNEL_PROGRESSC = "progress-color";
160+
public static final String CHANNEL_PROGRESSBC = "progress-background";
161+
public static final String CHANNEL_PUSH_ICON = "push-icon";
162+
public static final String CHANNEL_RAINBOW = "rainbow";
163+
public static final String CHANNEL_REPEAT = "repeat";
164+
public static final String CHANNEL_RESET = "reset";
165+
public static final String CHANNEL_SCROLLSPEED = "scroll-speed";
166+
public static final String CHANNEL_TEXT = "text";
167+
public static final String CHANNEL_TEXTCASE = "text-case";
168+
public static final String CHANNEL_TEXT_OFFSET = "text-offset";
169+
public static final String CHANNEL_TOP_TEXT = "top-text";
170+
171+
public static final String PUSH_ICON_OPTION_0 = "STATIC";
172+
public static final String PUSH_ICON_OPTION_1 = "PUSHOUT";
173+
public static final String PUSH_ICON_OPTION_2 = "PUSHOUTRETURN";
174+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2010-2025 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
14+
package org.openhab.binding.mqtt.awtrixlight.internal;
15+
16+
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.SUPPORTED_THING_TYPES;
17+
18+
import org.eclipse.jdt.annotation.NonNullByDefault;
19+
import org.eclipse.jdt.annotation.Nullable;
20+
import org.openhab.binding.mqtt.awtrixlight.internal.handler.AwtrixLightAppHandler;
21+
import org.openhab.binding.mqtt.awtrixlight.internal.handler.AwtrixLightBridgeHandler;
22+
import org.openhab.core.thing.Bridge;
23+
import org.openhab.core.thing.Thing;
24+
import org.openhab.core.thing.ThingRegistry;
25+
import org.openhab.core.thing.ThingTypeUID;
26+
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
27+
import org.openhab.core.thing.binding.ThingHandler;
28+
import org.openhab.core.thing.binding.ThingHandlerFactory;
29+
import org.osgi.service.component.annotations.Activate;
30+
import org.osgi.service.component.annotations.Component;
31+
import org.osgi.service.component.annotations.Reference;
32+
33+
/**
34+
* The {@link AwtrixLightHandlerFactory} is responsible for creating things and thing
35+
* handlers.
36+
*
37+
* @author Thomas Lauterbach - Initial contribution
38+
*/
39+
@Component(service = ThingHandlerFactory.class)
40+
@NonNullByDefault
41+
public class AwtrixLightHandlerFactory extends BaseThingHandlerFactory {
42+
43+
@Activate
44+
public AwtrixLightHandlerFactory(final @Reference ThingRegistry thingRegistry) {
45+
}
46+
47+
@Override
48+
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
49+
return SUPPORTED_THING_TYPES.contains(thingTypeUID);
50+
}
51+
52+
@Override
53+
protected @Nullable ThingHandler createHandler(Thing thing) {
54+
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
55+
if (AwtrixLightBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
56+
return new AwtrixLightBridgeHandler((Bridge) thing);
57+
} else if (AwtrixLightAppHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
58+
return new AwtrixLightAppHandler((Thing) thing);
59+
}
60+
61+
return null;
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2010-2025 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.mqtt.awtrixlight.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* The {@link BridgeConfigOptions} Holds the config for the bridge settings.
19+
*
20+
* @author Thomas Lauterbach - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public class BridgeConfigOptions {
24+
public String basetopic = "awtrix";
25+
public int appLockTimeout = 10;
26+
public boolean discoverDefaultApps = false;
27+
public int lowBatteryThreshold = 25;
28+
}

0 commit comments

Comments
 (0)