[mqtt][tradfri][webthing] Adapt to ColorUtil changes in core (#14810)
* [mqtt][tradfri][webthing] Adapt to ColorUtil changes in core Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -41,6 +41,7 @@ import org.openhab.binding.mqtt.homeassistant.internal.HaID;
|
||||
import org.openhab.binding.mqtt.homeassistant.internal.HandlerConfiguration;
|
||||
import org.openhab.binding.mqtt.homeassistant.internal.config.dto.AbstractChannelConfiguration;
|
||||
import org.openhab.binding.mqtt.homeassistant.internal.handler.HomeAssistantThingHandler;
|
||||
import org.openhab.core.library.types.HSBType;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatusInfo;
|
||||
import org.openhab.core.thing.binding.ThingHandlerCallback;
|
||||
@@ -173,7 +174,12 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests
|
||||
@SuppressWarnings("null")
|
||||
protected static void assertState(AbstractComponent<@NonNull ? extends AbstractChannelConfiguration> component,
|
||||
String channelId, State state) {
|
||||
assertThat(component.getChannel(channelId).getState().getCache().getChannelState(), is(state));
|
||||
State actualState = component.getChannel(channelId).getState().getCache().getChannelState();
|
||||
if ((actualState instanceof HSBType actualHsb) && (state instanceof HSBType stateHsb)) {
|
||||
assertThat(actualHsb.closeTo(stateHsb, 0.01), is(true));
|
||||
} else {
|
||||
assertThat(actualState, is(state));
|
||||
}
|
||||
}
|
||||
|
||||
protected void spyOnChannelUpdates(AbstractComponent<@NonNull ? extends AbstractChannelConfiguration> component,
|
||||
@@ -254,7 +260,7 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests
|
||||
|
||||
/**
|
||||
* Send command to a thing's channel
|
||||
*
|
||||
*
|
||||
* @param component component
|
||||
* @param channelId channel
|
||||
* @param command command to send
|
||||
|
||||
@@ -137,7 +137,7 @@ public class DefaultSchemaLightTests extends AbstractComponentTests {
|
||||
|
||||
// Brightness commands should route to the correct topic, converted to RGB
|
||||
sendCommand(component, Light.COLOR_CHANNEL_ID, new PercentType(50));
|
||||
assertPublished("zigbee2mqtt/light/set/rgb", "127,127,127");
|
||||
assertPublished("zigbee2mqtt/light/set/rgb", "128,128,128");
|
||||
|
||||
// OnOff commands should route to the correct topic
|
||||
sendCommand(component, Light.COLOR_CHANNEL_ID, OnOffType.OFF);
|
||||
|
||||
Reference in New Issue
Block a user