mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[wled] Fix: FX and Palettes channel StateDescriptionProvider handling (#17277)
* [wled] Fix: FX and Palettes channel StateDescriptionProvider handling Fixes #17276 Signed-off-by: Stefan Triller <github@stefantriller.de> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
469a386353
commit
83cedd65ab
@ -33,6 +33,7 @@ import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.ThingStatusInfo;
|
||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||
import org.openhab.core.thing.binding.builder.ThingBuilder;
|
||||
import org.openhab.core.types.Command;
|
||||
@ -254,10 +255,7 @@ public class WLedSegmentHandler extends BaseThingHandler {
|
||||
WledApi localAPI = localBridgeHandler.api;
|
||||
if (localAPI != null) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
localBridgeHandler.stateDescriptionProvider
|
||||
.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_FX), localAPI.getUpdatedFxList());
|
||||
localBridgeHandler.stateDescriptionProvider.setStateOptions(
|
||||
new ChannelUID(getThing().getUID(), CHANNEL_PALETTES), localAPI.getUpdatedPaletteList());
|
||||
updateStateDescriptionProviders();
|
||||
if (!localBridgeHandler.hasWhite) {
|
||||
logger.debug("WLED is not setup to use RGBW, so removing un-needed white channels");
|
||||
removeWhiteChannels();
|
||||
@ -267,4 +265,31 @@ public class WLedSegmentHandler extends BaseThingHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStateDescriptionProviders() {
|
||||
Bridge bridge = getBridge();
|
||||
if (bridge != null) {
|
||||
WLedBridgeHandler localBridgeHandler = (WLedBridgeHandler) bridge.getHandler();
|
||||
if (localBridgeHandler != null) {
|
||||
WledApi localAPI = localBridgeHandler.api;
|
||||
if (localAPI != null) {
|
||||
localBridgeHandler.stateDescriptionProvider.setStateOptions(
|
||||
new ChannelUID(getThing().getUID(), CHANNEL_FX), localAPI.getUpdatedFxList());
|
||||
localBridgeHandler.stateDescriptionProvider.setStateOptions(
|
||||
new ChannelUID(getThing().getUID(), CHANNEL_PALETTES), localAPI.getUpdatedPaletteList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) {
|
||||
super.bridgeStatusChanged(bridgeStatusInfo);
|
||||
|
||||
if (ThingStatus.ONLINE.equals(bridgeStatusInfo.getStatus())) {
|
||||
// if the handler has been started before the WLED controller is available, we have to fill the providers
|
||||
// again once the bridge goes ONLINE
|
||||
updateStateDescriptionProviders();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user