openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

[deconz] fails to translate percentage type for light #8260

Closed nougad closed 1 year ago

nougad commented 4 years ago

Expected Behavior

deCONZ does not fail when light is on

Current Behavior

bridge constantly fails and goes offline:

==> /volumeUSB1/usbshare/openHAB/userdata/logs/openhab.log <==
2020-08-05 01:30:39.551 [TRACE] [z.internal.handler.LightThingHandler] - deconz:extendedcolorlight:homeserver:office-desk received LightMessage{hascolor=null, ctmax=null, ctmin=null, type=null, state=null, e='changed', r='lights', t='event', id='2', manufacturername='', modelid='', name='', swversion='', ep='', uniqueid='f0:d1:b8:00:00:10:c1:7b-01'}
2020-08-05 01:30:39.557 [TRACE] [z.internal.handler.LightThingHandler] - deconz:extendedcolorlight:homeserver:office-desk received LightMessage{hascolor=null, ctmax=null, ctmin=null, type=null, state=LightState{reachable=true, on=true, bri=2, alert='null', colormode='ct', effect='none', hue=5376, sat=162, ct=153, xy=[0.2836, 0.2714], transitiontime=null}, e='changed', r='lights', t='event', id='2', manufacturername='', modelid='', name='', swversion='', ep='', uniqueid='f0:d1:b8:00:00:10:c1:7b-01'}
2020-08-05 01:30:39.558 [DEBUG] [nternal.netutils.WebSocketConnection] - Connecting to: ws://10.219.1.181:8088

==> /volumeUSB1/usbshare/openHAB/userdata/logs/events.log <==
2020-08-05 01:30:39.559 [hingStatusInfoChangedEvent] - 'deconz:deconz:homeserver' changed from OFFLINE (COMMUNICATION_ERROR): Disconnected to OFFLINE (COMMUNICATION_ERROR): 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:57) ~[?:?]
    at org.eclipse.smarthome.core.library.types.PercentType.<init>(PercentType.java:52) ~[?:?]
    at org.eclipse.smarthome.core.library.types.DecimalType.as(DecimalType.java:152) ~[?:?]
    at org.eclipse.smarthome.core.internal.items.ItemStateConverterImpl.convertToAcceptedState(ItemStateConverterImpl.java:64) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.sendUpdate(ProfileCallbackImpl.java:134) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onStateUpdateFromHandler(SystemDefaultProfile.java:53) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.CommunicationManager.lambda$9(CommunicationManager.java:467) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.CommunicationManager.lambda$11(CommunicationManager.java:487) ~[?:?]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_252]
    at org.eclipse.smarthome.core.thing.internal.CommunicationManager.handleCallFromHandler(CommunicationManager.java:483) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.CommunicationManager.stateUpdated(CommunicationManager.java:465) ~[?:?]
    at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl$1.stateUpdated(ThingManagerImpl.java:168) ~[?:?]
    at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:245) ~[?:?]
    at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:264) ~[?:?]
    at org.openhab.binding.deconz.internal.handler.LightThingHandler.valueUpdated(LightThingHandler.java:348) ~[?:?]
    at org.openhab.binding.deconz.internal.handler.LightThingHandler.handleCommand(LightThingHandler.java:151) ~[?:?]
    at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]
    at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_252]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_252]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_252]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_252]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

Possible Solution

Steps to Reproduce (for Bugs)

Turn on light

Your Environment

J-N-K commented 4 years ago

That‘s really surprising. There is a range check before the value is posted. I‘ll add some logging. Is this only happening for this light?

nougad commented 4 years ago

Hard to say because deconz spams the log file with dozens of messages per second. I have multiple sensors and buttons but I don't see any exceptions as long as the lights stay off. So I assume it's probably (mostly) a lights problem.

J-N-K commented 4 years ago

Please try if https://janessa.me/esh/org.openhab.binding.deconz-2.5.8-SNAPSHOT.jar, set the binding to DEBUG and show the DEBUG message just before the exception (val = '{}', scaledValue = '{}').

nougad commented 4 years ago

I added the jar to the addons/ folder but getting an exception on load:

2020-08-23 17:19:38.022 [ERROR] [org.openhab.binding.deconz          ] - bundle org.openhab.binding.deconz:2.5.8.202008221611 (303)[org.openhab.binding.deconz.internal.DeconzHandlerFactory(370)] :  Error during instantiation of the implementation object
java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_252]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_252]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_252]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_252]
    at org.apache.felix.scr.impl.inject.ComponentConstructor.newInstance(ComponentConstructor.java:309) ~[bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:277) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:900) [bundleFile:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [org.eclipse.osgi-3.12.100.jar:?]
    at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_252]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:508) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624) [org.eclipse.osgi-3.12.100.jar:?]
    at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:86) [bundleFile:?]
    at org.apache.felix.scr.impl.inject.BindParameters.getServiceObject(BindParameters.java:47) [bundleFile:?]
    at org.apache.felix.scr.impl.inject.methods.BindMethod.getServiceObject(BindMethod.java:664) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2308) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1805) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1788) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:435) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:325) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:294) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) [bundleFile:?]
    at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) [bundleFile:?]
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) [org.eclipse.osgi-3.12.100.jar:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) [bundleFile:?]
    at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) [bundleFile:?]
    at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) [bundleFile:?]
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) [bundleFile:?]
    at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) [bundleFile:?]
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) [bundleFile:?]
    at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [bundleFile:?]
    at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [bundleFile:?]
    at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [bundleFile:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [osgi.core-6.0.0.jar:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [osgi.core-6.0.0.jar:?]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [osgi.core-6.0.0.jar:?]
    at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [osgi.core-6.0.0.jar:?]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.container.Module.start(Module.java:467) [org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) [org.eclipse.osgi-3.12.100.jar:?]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Is it required to update openhab to 2.5.8 first? I'm currently running on 2.5.7.

But even without your jar I noticed the binding is not crashing anymore. I'm wondering if something changed with the update of deconz to 2.05.80?

J-N-K commented 4 years ago

Maybe. That exception looks strange. No idea why that happens.

nougad commented 3 years ago

Sorry, I could not get the jar running. But with openHab 2.5.9 and deConz 2.05.82 I was able to get more details:

==> /openHAB/userdata/logs/events.log <==
2020-10-09 05:32:45.666 [ome.event.ItemCommandEvent] - Item 'OfficeLightstrip_Color' received command ON
2020-10-09 05:32:45.670 [nt.ItemStatePredictedEvent] - OfficeLightstrip_Color predicted to become ON

==> /openHAB/userdata/logs/openhab.log <==
2020-10-09 05:32:45.674 [TRACE] [z.internal.handler.LightThingHandler] - Sending {"on":true} to light 10 via http://10.219.1.181:80/api/FBF2236491/lights/10/state

==> /openHAB/userdata/logs/events.log <==
2020-10-09 05:32:45.676 [vent.ItemStateChangedEvent] - OfficeLightstrip_Color changed from 0,0,0 to 0,0,100

==> /openHAB/userdata/logs/openhab.log <==
2020-10-09 05:32:45.677 [TRACE] [z.internal.handler.LightThingHandler] - Result code=200, body=[{"success":{"/lights/10/state/on":true}}]
2020-10-09 05:32:45.679 [TRACE] [nternal.netutils.WebSocketConnection] - Raw data received by websocket: {"e":"changed","id":"10","r":"lights","state":{"alert":null,"bri":78,"colormode":"hs","ct":370,"effect":"none","hue":5376,"on":true,"reachable":true,"sat":162,"xy":[0.4102,0.3867]},"t":"event","uniqueid":"7c:b0:3e:aa:00:a2:ed:68-03"}
2020-10-09 05:32:45.680 [TRACE] [z.internal.handler.LightThingHandler] - deconz:extendedcolorlight:homeserver:office-lightstrip received LightMessage{hascolor=null, ctmax=null, ctmin=null, type=null, state=LightState{reachable=true, on=true, bri=78, alert='null', colormode='hs', effect='none', hue=5376, sat=162, ct=370, xy=[0.4102, 0.3867], transitiontime=null}, e='changed', r='lights', t='event', id='10', manufacturername='', modelid='', name='', swversion='', ep='', uniqueid='7c:b0:3e:aa:00:a2:ed:68-03'}
2020-10-09 05:32:45.682 [DEBUG] [z.internal.handler.LightThingHandler] - val = '162', scaledValue = '64'
2020-10-09 05:32:45.683 [DEBUG] [z.internal.handler.LightThingHandler] - val = '78', scaledValue = '31'

==> /openHAB/userdata/logs/events.log <==
2020-10-09 05:32:45.687 [vent.ItemStateChangedEvent] - OfficeLightstrip_Color changed from 0,0,100 to 29.53170061799039,64,31
2020-10-09 05:32:45.689 [hingStatusInfoChangedEvent] - 'deconz:deconz:homeserver' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Value must be between 0 and 100

I'm not sure if it's the same bug or just similar. Unfortunately I don't get a stacktrace anymore

J-N-K commented 3 years ago

This can't be explained. I wrote a test with exactly your message and the test suceeds. Do you use manual configuration (things.conf) or managed (via Paper UI)? If textual: please show your configuration. If managed: please delete the thing and re-add it.

nougad commented 3 years ago

I configure it via config files. For that specific light the config is:

Bridge deconz:deconz:homeserver [ host="10.X.X.X", httpPort="80", apikey="FBFXXXX" ] {
  extendedcolorlight office-lightstrip "Office Lightstrip" @ "Office" [ id="10" ]
}
Group OfficeLightstrip "Büro Lightstrip" <colorwheel> (Office, gLight, gOfficeLights) ["Lighting"] {alexa="Endpoint.LIGHT"}
Color OfficeLightstrip_Color
  ( OfficeLightstrip, gOfficeLights_Color, gLightColor )
  { channel="deconz:extendedcolorlight:homeserver:office-lightstrip:color", alexa="Lighting" }
Dimmer OfficeLightstrip_ColorTemperature
  ( OfficeLightstrip, gLightTemperatureAndColor )
  { channel="deconz:extendedcolorlight:homeserver:office-lightstrip:color_temperature", alexa="ColorTemperature" [ binding="hue:white" ] }
J-N-K commented 3 years ago

Dimmer is not the correct item-type for the color-temperature. It's Number. So the reason is that The color temperature of 2702 can't be used to update it. cf. https://www.openhab.org/addons/bindings/deconz/

nougad commented 3 years ago

Thank you! that did the trick :)

I used the same light before with the HUE binding and there the color temperature is defined as Dimmer: https://www.openhab.org/addons/bindings/hue/

I'm wondering why this inconsistency? Isn't that super confusing and error-prone?

J-N-K commented 3 years ago

I think using Number and Setting the color temperature in K is much more intuitive than some abitrary 0-100% value.

cweitkamp commented 3 years ago

I have to chime in here. And I have to reopen this issue. We have a default system channel type color-temperature which uses item type Dimmer. And this should be the default item type for color temperature channels. But I agree with you that setting a color temperature in K is possible too and we maybe should add a way for users to do so (e.g. an additional channel type or a Profile for doing the math).

FTR: I just migrate a color temperature light from hue to deCONZ and got the same error as mentioned above - my item type for hue lights was Dimmer:

2021-01-17 17:33:07.292 [ERROR] [ore.common.registry.AbstractRegistry] - Cannot inform the listener "org.openhab.core.thing.internal.ChannelLinkNotifier@f83386" about the "ADDED" event: Value must be between 0 and 100
java.lang.IllegalArgumentException: Value must be between 0 and 100
    at org.openhab.core.library.types.PercentType.validateValue(PercentType.java:57) ~[bundleFile:?]
    at org.openhab.core.library.types.PercentType.<init>(PercentType.java:52) ~[bundleFile:?]
    at org.openhab.core.library.types.DecimalType.as(DecimalType.java:152) ~[bundleFile:?]
    at org.openhab.core.internal.items.ItemStateConverterImpl.convertToAcceptedState(ItemStateConverterImpl.java:64) ~[bundleFile:?]
    at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.sendUpdate(ProfileCallbackImpl.java:121) ~[?:?]
    at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onStateUpdateFromHandler(SystemDefaultProfile.java:53) ~[?:?]
    at org.openhab.core.thing.internal.CommunicationManager.lambda$11(CommunicationManager.java:518) ~[?:?]
    at org.openhab.core.thing.internal.CommunicationManager.lambda$13(CommunicationManager.java:538) ~[?:?]
    at java.lang.Iterable.forEach(Unknown Source) ~[?:?]
    at org.openhab.core.thing.internal.CommunicationManager.handleCallFromHandler(CommunicationManager.java:534) ~[?:?]
    at org.openhab.core.thing.internal.CommunicationManager.stateUpdated(CommunicationManager.java:516) ~[?:?]
    at org.openhab.core.thing.internal.ThingManagerImpl$1.stateUpdated(ThingManagerImpl.java:175) ~[?:?]
    at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:231) ~[?:?]
    at org.openhab.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:250) ~[?:?]
    at org.openhab.binding.deconz.internal.handler.LightThingHandler.valueUpdated(LightThingHandler.java:401) ~[?:?]
    at org.openhab.binding.deconz.internal.handler.LightThingHandler.handleCommand(LightThingHandler.java:128) ~[?:?]
    at org.openhab.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:177) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.lambda$3(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.call(ChannelLinkNotifier.java:96) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:1) ~[?:?]
    at org.openhab.core.common.registry.AbstractRegistry.notifyListeners(AbstractRegistry.java:367) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractRegistry.notifyListenersAboutAddedElement(AbstractRegistry.java:400) [bundleFile:?]
    at org.openhab.core.thing.link.ItemChannelLinkRegistry.notifyListenersAboutAddedElement(ItemChannelLinkRegistry.java:138) [bundleFile:?]
    at org.openhab.core.thing.link.ItemChannelLinkRegistry.notifyListenersAboutAddedElement(ItemChannelLinkRegistry.java:1) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:175) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:1) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:60) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:79) [bundleFile:?]
    at org.openhab.core.common.registry.AbstractProvider.notifyListenersAboutAddedElement(AbstractProvider.java:83) [bundleFile:?]
    at org.openhab.core.model.thing.internal.GenericItemChannelLinkProvider.createItemChannelLink(GenericItemChannelLinkProvider.java:106) [bundleFile:?]
    at org.openhab.core.model.thing.internal.GenericItemChannelLinkProvider.processBindingConfiguration(GenericItemChannelLinkProvider.java:76) [bundleFile:?]
    at org.openhab.core.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:372) [bundleFile:?]
    at org.openhab.core.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:341) [bundleFile:?]
    at org.openhab.core.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:212) [bundleFile:?]
    at org.openhab.core.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:407) [bundleFile:?]
    at org.openhab.core.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) [bundleFile:?]
    at org.openhab.core.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:128) [bundleFile:?]
    at org.openhab.core.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:249) [bundleFile:?]
    at org.openhab.core.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:312) [bundleFile:?]
    at org.openhab.core.service.WatchQueueReader.run(WatchQueueReader.java:239) [bundleFile:?]
    at java.lang.Thread.run(Unknown Source) [?:?]

And later:

2021-01-17 17:41:01.523 [WARN ] [nternal.netutils.WebSocketConnection] - Websocket$1610618994130-1 encountered an error while processing the message {"e":"changed","id":"4","r":"lights","state":{"alert":null,"bri":254,"colormode":"ct","ct":153,"on":true,"reachable":true},"t":"event","uniqueid":"XXXX"}: Value must be between 0 and 100
J-N-K commented 3 years ago

A dimmer is plain wrong. On/off make no sense on color temperature. And For two lights with different ct range setting the same ct is impossible with 0-100%.

cweitkamp commented 3 years ago

I agree with you. It technically and physically is not correct. But in the terms of openHAB a Dimmer supports adjusting the color temperature from cold (0%, lowest Kelvin) to warm (100%, highest Kelvin).

Philips Hue and deCONZ both provide a ctmin and ctmax property for each bulb via their REST interface. These values can be used to apply the correct calculation:

{
    "colorcapabilities": 16,
    "ctmax": 370,
    "ctmin": 153,
    "hascolor": true,
    "lastannounced": null,
    "lastseen": "2021-01-17T19:07Z",
    "manufacturername": "MLI",
    "modelid": "ZBT-ColorTemperature",
    "name": "...",
    "state": {
        "alert": "none",
        "bri": 254,
        "colormode": "ct",
        "ct": 153,
        "on": false,
        "reachable": true
    },
    "swversion": "2.0",
    "type": "Color temperature light",
    "uniqueid": "XXXX"
}
cweitkamp commented 3 years ago

from cold (0%, lowest Kelvin) to warm (100%, highest Kelvin)

Correctly: from cold (0%, highest Kelvin) to warm (100%, lowest Kelvin)

J-N-K commented 3 years ago

Looking at your other PR, hue is not using the system-channel ATM. Which binding is using the system-channel? Probably none. In that case, the system-channel should be changed.

MHerbst commented 3 years ago

As far as I know, the Shelly binding uses also dimmer for the color temperature.

J-N-K commented 3 years ago

The question is: does it use the system-channel-type. I strongly oppose to implementing wrong behavior just because it‘s written somewhere. If no one uses the system-channelType, there is no reason to break a working implementation just to use a definition that we all agree is wrong.

cweitkamp commented 3 years ago

GitHub search only yields one hit: tpsmartlink. I will do a more detailed RegEx search tomorrow, when having my dev-env handy.

cweitkamp commented 3 years ago

~/openhab-master/git/openhab-addons/bundles$ find . -name "*.xml" | xargs egrep -i '(colortemperature|color.temperature)' | grep "typeId"

./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/ceiling.xml:         <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/stripe.xml:          <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/desklamp.xml:            <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/wonder.xml:          <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/ceiling4.xml:            <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/ct_bulb.xml:         <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.yeelight/src/main/resources/OH-INF/thing/ceiling1.xml:            <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.nanoleaf/src/main/resources/OH-INF/thing/lightpanels.xml:         <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.nanoleaf/src/main/resources/OH-INF/thing/lightpanels.xml:         <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs"/>
./org.openhab.binding.epsonprojector/src/main/resources/OH-INF/thing/thing-types.xml:           <channel id="colortemperature" typeId="colortemperature"/>
./org.openhab.binding.epsonprojector/src/main/resources/OH-INF/thing/thing-types.xml:           <channel id="colortemperature" typeId="colortemperature"/>
./org.openhab.binding.hue/src/main/resources/OH-INF/thing/Group.xml:            <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.hue/src/main/resources/OH-INF/thing/ExtendedColorLight.xml:           <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.hue/src/main/resources/OH-INF/thing/ColorTemperatureLight.xml:            <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.hue/target/classes/OH-INF/thing/Group.xml:            <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.hue/target/classes/OH-INF/thing/ExtendedColorLight.xml:           <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.hue/target/classes/OH-INF/thing/ColorTemperatureLight.xml:            <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.deconz/src/main/resources/OH-INF/thing/group-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.deconz/target/classes/OH-INF/thing/group-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.deconz/target/classes/OH-INF/thing/light-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.deconz/target/classes/OH-INF/thing/light-thing-types.xml:         <channel typeId="ct" id="color_temperature"/>
./org.openhab.binding.mihome/src/main/resources/OH-INF/thing/gateway.xml:           <channel id="colorTemperature" typeId="colorTemperature"/>
./org.openhab.binding.dmx/src/main/resources/OH-INF/thing/tunablewhite-thing.xml:           <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.tradfri/src/main/resources/OH-INF/thing/thing-types.xml:          <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.tradfri/src/main/resources/OH-INF/thing/thing-types.xml:          <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.sonyprojector/src/main/resources/OH-INF/thing/ethernet.xml:           <channel id="colortemperature" typeId="colortemperature"/>
./org.openhab.binding.sonyprojector/src/main/resources/OH-INF/thing/serialoverip.xml:           <channel id="colortemperature" typeId="colortemperature"/>
./org.openhab.binding.sonyprojector/src/main/resources/OH-INF/thing/serial.xml:         <channel id="colortemperature" typeId="colortemperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs1"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs1"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml:            <channel id="colorTemperature" typeId="system.color-temperature"/>
./org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml:            <channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
./org.openhab.binding.smartthings/src/main/resources/OH-INF/thing/thing-types.xml:          <channel id="colorTemperature" typeId="colorTemperature-channel">
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types-M6503C.xml:            <channel id="color-temperature" typeId="color-temperature"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types.xml:           <channel id="color-temperature" typeId="color-temperature"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types.xml:           <channel id="color-temperature2" typeId="color-temperature2"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types-SAC34134216.xml:           <channel id="color-temperature2" typeId="color-temperature2"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types-SAC34134216.xml:           <channel id="color-temperature2" typeId="color-temperature2"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types-SAC34134216.xml:           <channel id="color-temperature2" typeId="color-temperature2"/>
./org.openhab.binding.lgtvserial/src/main/resources/OH-INF/thing/thing-types-SAC34134216.xml:           <channel id="color-temperature2" typeId="color-temperature2"/>
./org.openhab.binding.feican/src/main/resources/OH-INF/thing/thing-types.xml:           <channel id="color_temperature" typeId="color_temperature"/>
./org.openhab.binding.samsungtv/src/main/resources/OH-INF/thing/thing-types.xml:            <channel id="colorTemperature" typeId="colortemperature"/>

Looks like every binding implements the color temperature channel in the above described openHAB style. Some of them provide an additional channel for colorTemperatureAbs values which adds the feature to set the color temperature in Kelvin.

J-N-K commented 3 years ago

But only tplinksmarthome uses the system channel. Anyway. It's wrong. If you feel deconz needs fixing, you can of course do that. Please remove me from the CODEOWNERS in that case. I do not support breaking correct implementations because of wrong modeling.

cweitkamp commented 3 years ago

I think we are heading into the wrong direction. I am neither claiming to change the existing channel nor the implementation. I am asking for adding a way to retrieve the same functionality like we are having in other bindings - which may be a new channel or a Profile for conversion or something completely different. I am asking for streamlining capabilities to make bindings more even. Sry, if my earlier posts did not sound like that.

And yes, we can discuss changing system default channel type or adding a new one to support Kelvin temperature settings. I like to add this feature to Hue binding.

Currently it is not possible for me to switch my color temperature bulbs from Hue, TRADFRI, tplinksmarthome or others vendors to deCONZ without a hassle. I have to touch the modelling of my house which which does not have to be.

kaikreuzer commented 3 years ago

The system channel type for color temperature isn't much used, since it was introduced after most bindings where already developed and we never really enforced the usage of system channel types afterwards. I don't understand why anybody would claim it is wrong, though. The dimmer allows controlling the "heat" in the light and a Dimmer item is meant for features that have a continues range with values that one typically like to INCREASE or DECREASE as well. It's just the same as the brightness channel, where you also don't ask for setting it to lumen (or actually what you'd like is lux), nor is is much desirable to set the volume to dB, since 0-100% is much more practical. And especially: Using a percent range brings a much better abstraction and that's what Items aim for. You can rely on the fact that the values 0-100% are always valid, independent of the manufacturer or model, while kelvin values depend on the supported range.

I don't mind adding a separate system channel type for absolute color temperature in K", if the bulbs really support this. From my experiences with HSB values I only know that colors can widely differ, even if expected to be identical. Hopefully this is better for color temperature.

J-N-K commented 3 years ago

10% is not the same for two different lights. And that does not depend on different implementations (like the HSB issue) but on different ranges in value. That‘s why I think it’s wrong. Value X should be the same (if lights were perfect) for each light. That’s true for a color temperature in K, but not for a color temperature in %. 0% could be 2000K for one light or 2200K (or even 3000K) for another light, but 2000K should be the same for every device.

kaikreuzer commented 3 years ago

10% is not the same for two different lights.

Please read above. 10% brightness isn't the same for different lights either, yet it perfectly makes sense and nobody claims it's wrong.

cweitkamp commented 3 years ago

I removed the "invalid" label for now and added the "enhancement" label. Maybe some volunteer will add the "normal" color temperature channel to the deCONZ binding in the future.

I for myself found the solution in adding a new channel to the Hue binding (see https://github.com/openhab/openhab-addons/pull/9939) which allows to control the color temperature in Kelvin. This in advance solves another problem for me and lets me put two color temperature bulbs of two different vendors in a Group to set an equal color temperature value for both of them - and yes, I now was forced to remodel my home, but that will not happen again. I hope others will benefit from my above solution too.