[mqtt.generic] Fix default configuration and docs for color_mode (#12163)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
@@ -16,6 +16,7 @@ import java.math.BigDecimal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.mqtt.generic.mapping.ColorMode;
|
||||
|
||||
/**
|
||||
* A user can add custom channels to an MQTT Thing.
|
||||
@@ -56,5 +57,5 @@ public class ChannelConfig {
|
||||
public @Nullable String stop;
|
||||
|
||||
public int onBrightness = 10;
|
||||
public String colorMode = "";
|
||||
public String colorMode = ColorMode.HSB.toString();
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class GenericMQTTThingHandler extends AbstractMQTTThingHandler implements
|
||||
stateDescProvider.setDescription(channel.getUID(), description);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn("Channel configuration error", e);
|
||||
logger.warn("Configuration error for channel '{}'", channel.getUID(), e);
|
||||
configErrors.add(channel.getUID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,13 @@ public class ValueFactory {
|
||||
value = new ColorValue(ColorMode.RGB, config.on, config.off, config.onBrightness);
|
||||
break;
|
||||
case MqttBindingConstants.COLOR:
|
||||
value = new ColorValue(ColorMode.valueOf(config.colorMode), config.on, config.off, config.onBrightness);
|
||||
ColorMode colorMode;
|
||||
try {
|
||||
colorMode = ColorMode.valueOf(config.colorMode);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
throw new IllegalArgumentException("Invalid color mode: " + config.colorMode, exception);
|
||||
}
|
||||
value = new ColorValue(colorMode, config.on, config.off, config.onBrightness);
|
||||
break;
|
||||
case MqttBindingConstants.SWITCH:
|
||||
value = new OnOffValue(config.on, config.off);
|
||||
|
||||
Reference in New Issue
Block a user