Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

[Tradfri] Bug in color space conversion #4349

Closed
hreichert opened this issue Sep 26, 2017 · 2 comments
Closed

[Tradfri] Bug in color space conversion #4349

hreichert opened this issue Sep 26, 2017 · 2 comments

Comments

@hreichert
Copy link
Contributor

As reported in the OpenHAB community:
https://community.openhab.org/t/ikea-tradfri-gateway/26135/126

when I change the color in the IKEA Trådfri iOS App to the darkest blue, I get the following error:

==> /var/log/openhab2/openhab.log <==
2017-09-26 19:17:37.493 [ERROR] [alifornium.core.network.CoapEndpoint] - Exception in protocol stage thread: Value must be between 0 and 100
java.lang.IllegalArgumentException: Value must be between 0 and 100
	at org.eclipse.smarthome.core.library.types.PercentType.validateValue(PercentType.java:50) [98:org.eclipse.smarthome.core:0.9.0.201709260841]
	at org.eclipse.smarthome.core.library.types.PercentType.<init>(PercentType.java:35) [98:org.eclipse.smarthome.core:0.9.0.201709260841]
	at org.eclipse.smarthome.core.library.types.HSBType.fromRGB(HSBType.java:114) [98:org.eclipse.smarthome.core:0.9.0.201709260841]
	at org.eclipse.smarthome.binding.tradfri.internal.TradfriColor.constructHsbTypeFromRgbWithBrightnessPercent(TradfriColor.java:247) [186:org.eclipse.smarthome.binding.tradfri:0.9.0.201709260841]
	at org.eclipse.smarthome.binding.tradfri.internal.TradfriColor.fromCie(TradfriColor.java:133) [186:org.eclipse.smarthome.binding.tradfri:0.9.0.201709260841]
	at org.eclipse.smarthome.binding.tradfri.handler.TradfriLightHandler$LightData.getColor(TradfriLightHandler.java:423) [186:org.eclipse.smarthome.binding.tradfri:0.9.0.201709260841]
	at org.eclipse.smarthome.binding.tradfri.handler.TradfriLightHandler.onUpdate(TradfriLightHandler.java:140) [186:org.eclipse.smarthome.binding.tradfri:0.9.0.201709260841]
	at org.eclipse.smarthome.binding.tradfri.internal.TradfriCoapHandler.onLoad(TradfriCoapHandler.java:60) [186:org.eclipse.smarthome.binding.tradfri:0.9.0.201709260841]
	at org.eclipse.californium.core.CoapClient$ObserveMessageObserverImpl.deliver(CoapClient.java:1067) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.CoapClient$MessageObserverImpl.succeeded(CoapClient.java:995) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.CoapClient$MessageObserverImpl.onResponse(CoapClient.java:974) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.coap.Request.setResponse(Request.java:509) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.EndpointManager$ClientMessageDeliverer.deliverResponse(EndpointManager.java:267) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.CoapStack$StackTopAdapter.receiveResponse(CoapStack.java:193) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:98) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.ObserveLayer.receiveResponse(ObserveLayer.java:137) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:98) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.BlockwiseLayer.receiveResponse(BlockwiseLayer.java:321) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:98) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.ReliabilityLayer.receiveResponse(ReliabilityLayer.java:269) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:98) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.stack.CoapStack.receiveResponse(CoapStack.java:135) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.CoapEndpoint$InboxImpl.receiveMessage(CoapEndpoint.java:656) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.CoapEndpoint$InboxImpl.access$700(CoapEndpoint.java:562) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.CoapEndpoint$InboxImpl$1.run(CoapEndpoint.java:574) [175:californium-osgi:1.0.6]
	at org.eclipse.californium.core.network.CoapEndpoint$5.run(CoapEndpoint.java:721) [175:californium-osgi:1.0.6]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
@hreichert
Copy link
Contributor Author

Can reproduce it. Investigating.

@hreichert hreichert changed the title [Tradri] Bug in color space conversion [Tradfri] Bug in color space conversion Sep 26, 2017
hreichert added a commit to hreichert/smarthome that referenced this issue Sep 26, 2017
Always cap calculated RGB values to the range 0 to 255.

Fixes: eclipse-archived#4349

Signed-off-by: Holger Reichert <mail@h0lger.de>
@hreichert
Copy link
Contributor Author

Fixed.
In side-cases, the conversion from CIE-XY to RGB can output slightly negative numbers.
PR #4351 ensures that the RGB values are always in the range from 0 to 255.

hreichert added a commit to hreichert/smarthome that referenced this issue Oct 2, 2017
Ensure that calculated RGB values are not negative.

Fixes: eclipse-archived#4349

Signed-off-by: Holger Reichert <mail@h0lger.de>
@sjsf sjsf closed this as completed in #4351 Oct 4, 2017
sjsf pushed a commit that referenced this issue Oct 4, 2017
Ensure that calculated RGB values are not negative.

Fixes: #4349
Signed-off-by: Holger Reichert <mail@h0lger.de>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant