diff --git a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedConfiguration.java b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedConfiguration.java
index 04d8d7b85..2721dc5df 100644
--- a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedConfiguration.java
+++ b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedConfiguration.java
@@ -25,4 +25,6 @@ public class WLedConfiguration {
public int pollTime;
public int segmentIndex;
public int saturationThreshold;
+ public boolean sortEffects = false;
+ public boolean sortPalettes = false;
}
diff --git a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java
index 7088441bc..9a77d7fdd 100644
--- a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java
+++ b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedHandler.java
@@ -305,6 +305,7 @@ public class WLedHandler extends BaseThingHandler {
future.cancel(true);
pollingFuture = null;
}
+ api = null; // re-initialize api after configuration change
}
@Override
diff --git a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/api/WledApiV084.java b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/api/WledApiV084.java
index 2053928e6..4d3245af4 100644
--- a/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/api/WledApiV084.java
+++ b/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/api/WledApiV084.java
@@ -17,6 +17,7 @@ import static org.openhab.binding.wled.internal.WLedBindingConstants.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -230,6 +231,9 @@ public class WledApiV084 implements WledApi {
for (String value : state.jsonResponse.effects) {
fxOptions.add(new StateOption(Integer.toString(counter++), value));
}
+ if (handler.config.sortEffects) {
+ fxOptions.sort(Comparator.comparing(o -> o.getValue().equals("0") ? "" : o.getLabel()));
+ }
handler.stateDescriptionProvider.setStateOptions(new ChannelUID(handler.getThing().getUID(), CHANNEL_FX),
fxOptions);
}
@@ -240,6 +244,9 @@ public class WledApiV084 implements WledApi {
for (String value : state.jsonResponse.palettes) {
palleteOptions.add(new StateOption(Integer.toString(counter++), value));
}
+ if (handler.config.sortPalettes) {
+ palleteOptions.sort(Comparator.comparing(o -> o.getValue().equals("0") ? "" : o.getLabel()));
+ }
handler.stateDescriptionProvider.setStateOptions(new ChannelUID(handler.getThing().getUID(), CHANNEL_PALETTES),
palleteOptions);
}
diff --git a/bundles/org.openhab.binding.wled/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.wled/src/main/resources/OH-INF/thing/thing-types.xml
index 1d565066f..e97550b41 100644
--- a/bundles/org.openhab.binding.wled/src/main/resources/OH-INF/thing/thing-types.xml
+++ b/bundles/org.openhab.binding.wled/src/main/resources/OH-INF/thing/thing-types.xml
@@ -57,6 +57,18 @@
0
+
+
+ If set, will sort the state options of the effects channel alphabetically while keeping the first
+ option (Solid) at the top.
+ false
+
+
+
+ If set, will sort the state options of the palettes channel alphabetically while keeping the first
+ option (Default) at the top.
+ false
+