[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:
Holger Friedrich
2023-04-21 23:55:36 +02:00
committed by GitHub
parent cf3c3f1025
commit 428ccbe075
6 changed files with 57 additions and 31 deletions

View File

@@ -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

View File

@@ -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);