Skip to content

Commit

Permalink
fixed first review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Lauterbach <[email protected]>
  • Loading branch information
Thomas Lauterbach committed Feb 12, 2025
1 parent 077f66f commit 97c00d6
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 348 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
/bundles/org.openhab.binding.monopriceaudio/ @mlobstein
/bundles/org.openhab.binding.mpd/ @stefanroellin
/bundles/org.openhab.binding.mqtt/ @ccutrer
/bundles/org.openhab.binding.mqtt.awtrixlight/ @DrRSatzteil
/bundles/org.openhab.binding.mqtt.espmilighthub/ @Skinah
/bundles/org.openhab.binding.mqtt.fpp/ @computergeek1507
/bundles/org.openhab.binding.mqtt.generic/ @ccutrer
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,11 @@
<artifactId>org.openhab.binding.mqtt.awtrixlight</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.mqtt.awtrixlight</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.mqtt.espmilighthub</artifactId>
Expand Down
203 changes: 108 additions & 95 deletions bundles/org.openhab.binding.mqtt.awtrixlight/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.mqtt.awtrixlight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>org.openhab.binding.mqtt.awtrixlight</artifactId>
<name>openHAB Add-ons :: Bundles :: MQTT Awtrix Light</name>
<name>openHAB Add-ons :: Bundles :: MQTT Awtrix 3</name>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (AwtrixLightBridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
AwtrixLightBridgeHandler bridgeHandler = new AwtrixLightBridgeHandler((Bridge) thing);
return bridgeHandler;
return new AwtrixLightBridgeHandler((Bridge) thing);
} else if (AwtrixLightAppHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
AwtrixLightAppHandler appHandler = new AwtrixLightAppHandler((Thing) thing);
return appHandler;
return new AwtrixLightAppHandler((Thing) thing);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void blinkIndicator(int indicatorId, int[] rgb, int blinkTimeInMs) {
}

public static void blinkIndicator(@Nullable ThingActions actions, int indicatorId, int[] rgb, int blinkTimeInMs) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).blinkIndicator(indicatorId, rgb, blinkTimeInMs);
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.blinkIndicator(indicatorId, rgb, blinkTimeInMs);
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -70,8 +70,8 @@ public void fadeIndicator(int indicatorId, int[] rgb, int fadeTimeInMs) {
}

public static void fadeIndicator(@Nullable ThingActions actions, int indicatorId, int[] rgb, int fadeTimeInMs) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).fadeIndicator(indicatorId, rgb, fadeTimeInMs);
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.fadeIndicator(indicatorId, rgb, fadeTimeInMs);
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -86,8 +86,8 @@ public void activateIndicator(int indicatorId, int[] rgb) {
}

public static void activateIndicator(@Nullable ThingActions actions, int indicatorId, int[] rgb) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).activateIndicator(indicatorId, rgb);
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.activateIndicator(indicatorId, rgb);
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -102,8 +102,8 @@ public void deactivateIndicator(int indicatorId) {
}

public static void deactivateIndicator(@Nullable ThingActions actions, int indicatorId) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).deactivateIndicator(indicatorId);
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.deactivateIndicator(indicatorId);
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -118,8 +118,8 @@ public void reboot() {
}

public static void reboot(@Nullable ThingActions actions) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).reboot();
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.reboot();
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -134,8 +134,8 @@ public void sleep(int seconds) {
}

public static void sleep(@Nullable ThingActions actions, int seconds) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).sleep(seconds);
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.sleep(seconds);
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -150,8 +150,8 @@ public void upgrade() {
}

public static void upgrade(@Nullable ThingActions actions) {
if (actions instanceof AwtrixActions) {
((AwtrixActions) actions).upgrade();
if (actions instanceof AwtrixActions awtrixActions) {
awtrixActions.upgrade();
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
}
Expand All @@ -166,9 +166,9 @@ public void playSound(String melody) {
}

public static void playSound(@Nullable ThingActions actions, @Nullable String melody) {
if (actions instanceof AwtrixActions) {
if (actions instanceof AwtrixActions awtrixActions) {
if (melody != null) {
((AwtrixActions) actions).playSound(melody);
awtrixActions.playSound(melody);
}
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
Expand All @@ -184,9 +184,9 @@ public void playRtttl(String rtttl) {
}

public static void playRtttl(@Nullable ThingActions actions, @Nullable String rtttl) {
if (actions instanceof AwtrixActions) {
if (actions instanceof AwtrixActions awtrixActions) {
if (rtttl != null) {
((AwtrixActions) actions).playRtttl(rtttl);
awtrixActions.playRtttl(rtttl);
}
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
Expand All @@ -206,9 +206,9 @@ public void showNotification(String message, String icon) {

public static void showNotification(@Nullable ThingActions actions, @Nullable String message,
@Nullable String icon) {
if (actions instanceof AwtrixActions) {
if (actions instanceof AwtrixActions awtrixActions) {
if (message != null && icon != null) {
((AwtrixActions) actions).showNotification(message, icon);
awtrixActions.showNotification(message, icon);
}
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
Expand All @@ -227,10 +227,9 @@ public void showCustomNotification(Map<String, Object> appParams, boolean hold,
public static void showCustomNotification(@Nullable ThingActions actions, @Nullable Map<String, Object> appParams,
boolean hold, boolean wakeUp, boolean stack, @Nullable String rtttl, @Nullable String sound,
boolean loopSound) {
if (actions instanceof AwtrixActions) {
if (actions instanceof AwtrixActions awtrixActions) {
if (appParams != null) {
((AwtrixActions) actions).showCustomNotification(appParams, hold, wakeUp, stack, rtttl, sound,
loopSound);
awtrixActions.showCustomNotification(appParams, hold, wakeUp, stack, rtttl, sound, loopSound);
}
} else {
throw new IllegalArgumentException("Instance is not an AwtrixActions class.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public void appDiscovered(String baseTopic, String appName) {

@Override
public void setThingHandler(ThingHandler handler) {
if (handler instanceof AwtrixLightBridgeHandler) {
this.bridgeHandler = (AwtrixLightBridgeHandler) handler;
((AwtrixLightBridgeHandler) handler).setAppDiscoveryCallback(this);
if (handler instanceof AwtrixLightBridgeHandler bridgeHandler) {
this.bridgeHandler = bridgeHandler;
bridgeHandler.setAppDiscoveryCallback(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd">

<config-description uri="thing-type:mqtt:awtrixclock">
<config-description uri="thing-type:mqtt:awtrix-clock">
<parameter name="basetopic" type="text" required="true">
<label>Base topic</label>
<description>Base topic as configured in the Awtrix Light device.</description>
Expand All @@ -28,7 +28,7 @@
</parameter>
</config-description>

<config-description uri="thing-type:mqtt:awtrixapp">
<config-description uri="thing-type:mqtt:awtrix-app">
<parameter name="appname" type="text" required="true">
<label>App name</label>
<description>Name of the app</description>
Expand Down
Loading

0 comments on commit 97c00d6

Please sign in to comment.