openhab / openhab-addons

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

[MQTT] xyY colormode causes error #10653

Closed MadsOBH closed 1 year ago

MadsOBH commented 3 years ago

Expected Behavior

I expect colorpicker to be converted to xyY color

Current Behavior

Mqtt binding crash

When using: Thing: Type color : color_thing "Color xyY" [stateTopic="zigbee2mqtt/Hus_1sal_bad_lys_lidlpaereRGB_1", commandTopic="zigbee2mqtt/Hus_1sal_bad_lys_lidlpaereRGB_1/set", colorMode="xyY" ]

Item: Color color_item "Color xyY" (gH1bll1) {channel="mqtt:topic:mosquitto:zigbee2mqtt:color_thing"}

I have tried colorMode="xyY" as per documentation, doesn't work from openhab log: 2021-05-06 19:43:14.954 [WARN ] [rnal.handler.GenericMQTTThingHandler] - Channel configuration error java.lang.IllegalArgumentException: No enum constant org.openhab.binding.mqtt.generic.mapping.ColorMode. at java.lang.Enum.valueOf(Enum.java:240) ~[?:?] at org.openhab.binding.mqtt.generic.mapping.ColorMode.valueOf(ColorMode.java:1) ~[bundleFile:?] at org.openhab.binding.mqtt.generic.values.ValueFactory.createValueState(ValueFactory.java:63) ~[bundleFile:?] at org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler.initialize(GenericMQTTThingHandler.java:164) [bundleFile:?] at jdk.internal.reflect.GeneratedMethodAccessor54.invoke(Unknown Source) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?] at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?]

I have tried colorMode="XYY" doesn't work from openhab log: 2021-05-06 18:42:58.177 [WARN ] [rnal.handler.GenericMQTTThingHandler] - Channel configuration error java.lang.IllegalArgumentException: No enum constant org.openhab.binding.mqtt.generic.mapping.ColorMode. at java.lang.Enum.valueOf(Enum.java:240) ~[?:?] at org.openhab.binding.mqtt.generic.mapping.ColorMode.valueOf(ColorMode.java:1) ~[bundleFile:?] at org.openhab.binding.mqtt.generic.values.ValueFactory.createValueState(ValueFactory.java:63) ~[bundleFile:?] at org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler.initialize(GenericMQTTThingHandler.java:164) [bundleFile:?] at jdk.internal.reflect.GeneratedMethodAccessor54.invoke(Unknown Source) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?] at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?] at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?]7

I have tried colorMode="RGB" this works but is not the right thing for my config

Steps to Reproduce (for Bugs)

  1. Configure thing in things file. colorMode="xyY"
  2. Stop and start openhab
  3. Check log file, see error
  4. RE-Configure thing in things file. colorMode="XYY"
  5. Stop and start openhab
  6. Check log file, see error
  7. RE-Configure thing in things file. colorMode="RGB"
  8. Check log file, see everything is okay
  9. RE-Configure thing in things file. colorMode="xyY"
  10. Check log file, see error is appearing again

Context

Im trying to use openhab colorpicker with zigbee2mqtt and a HG06106A Lidl Livarno Lux GU10 spot RGB (light)

Your Environment

Openhabian 3.0.2 - Release build Raspberry Pi 4, 4gb, sdd

Rossko57 commented 3 years ago

This should have been implemented in https://github.com/openhab/openhab-addons/pull/8312 for 2.5.x I wonder if some part did not get in to OH3

MadsOBH commented 3 years ago

Yes could be something like that

Another thing regrading colorMode, is the naming and the use of upper/lower case in the readme.md is wrong, should i open another issue for this? image

MadsOBH commented 3 years ago

I think i have found the cause.

In my long zigbee2mqtt things file i had some old color things using Type colorRGB, these things was working perfectly. i also had two wrongly configured Type color thing with no colorMode selected, these were also working perfectly. with the above mentioned thing i had no error messages in openhab log.

My problems first started trying to use colorMode="XYY" but its not a problem with the XYY.

Maybe there's is a way to insure this doesn't happen to anyone else, perhaps sending a error when using Type color without colorMode selction or using the now deprecated colorRGB

I'm still testing, but after changing all color things to Type color and using colorMode, i haven't seen the error Thanks Mads

jimtng commented 2 years ago

12163 allows for default color_mode as HSB when it's not specified. It will also issue a more descriptive WARN log specifically pointing out the invalid color_mode value. Furthermore, it changed the doc to use the uppercase color mode to avoid future mistakes, although it doesn't stress that it must be uppercase.

@MadsOBH are you satisfied with the solution and can this issue be closed?

lolodomo commented 1 year ago

Closing as no feedback after .one year.

12163 was also merged.