Dimmable lighting over mqtt throwes exception

hey,

I want to control a hue lamp with zigbee2mqtt over Openhab and homekit.
After checking everything works fine with mqtt.fx I created a new generic mqtt thing and a channel.

The state topic gives ja json like this:

{
“state” : “ON”,
“linkquality” : 55,
“last_seen” : “2019-05-23T20:10:38+02:00”,
“brightness” : 5
}

by sending the percent value with “brightness_percent” zigbee2mqtt manages the conversion (0-255) on its own.

For the HomeKit part I added the “Lighting” tag to the Item via habmin.

So far so good.

When I try to conrtol the lamp with homekit the lamp and the percentage value in homekit jumps around like this
(event.log)

2019-05-23 20:36:33.746 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:33.751 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 38
2019-05-23 20:36:33.760 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:33.826 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 38
2019-05-23 20:36:33.830 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 16.0784313725490193291989271529018878936767578125 to 100
2019-05-23 20:36:33.834 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 38
2019-05-23 20:36:34.009 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:34.011 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 50
2019-05-23 20:36:34.053 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:34.056 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 38 to 100
2019-05-23 20:36:34.057 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 50
2019-05-23 20:36:34.060 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 50
2019-05-23 20:36:34.160 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 50 to 38.03921568627450966459946357645094394683837890625
2019-05-23 20:36:34.271 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:34.275 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 54
2019-05-23 20:36:34.305 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:34.309 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 54
2019-05-23 20:36:34.312 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 38.03921568627450966459946357645094394683837890625 to 100
2019-05-23 20:36:34.315 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 54
2019-05-23 20:36:34.389 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:34.394 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 55
2019-05-23 20:36:34.403 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:34.413 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 54 to 100
2019-05-23 20:36:34.416 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 55
2019-05-23 20:36:34.422 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 49.80392156862745167700268211774528026580810546875
2019-05-23 20:36:34.424 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 49.80392156862745167700268211774528026580810546875 to 55
2019-05-23 20:36:34.509 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 55 to 49.80392156862745167700268211774528026580810546875
2019-05-23 20:36:35.157 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 49.80392156862745167700268211774528026580810546875 to 54.11764705882352899379839072935283184051513671875
2019-05-23 20:36:35.279 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:35.283 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 54
2019-05-23 20:36:35.286 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:35.294 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 54.11764705882352899379839072935283184051513671875 to 100
2019-05-23 20:36:35.309 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 54
2019-05-23 20:36:35.324 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 54
2019-05-23 20:36:35.420 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 54 to 54.90196078431372228578766225837171077728271484375
2019-05-23 20:36:35.608 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command ON
2019-05-23 20:36:35.614 [ome.event.ItemCommandEvent] - Item ‘Hue_white_HueWhite’ received command 54
2019-05-23 20:36:35.617 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become ON
2019-05-23 20:36:35.659 [nt.ItemStatePredictedEvent] - Hue_white_HueWhite predicted to become 54
2019-05-23 20:36:35.669 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 54.90196078431372228578766225837171077728271484375 to 100
2019-05-23 20:36:35.677 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 100 to 54
2019-05-23 20:36:35.680 [vent.ItemStateChangedEvent] - Hue_white_HueWhite changed from 54 to 54.11764705882352899379839072935283184051513671875

openhab.log

2019-05-23 20:39:24.143 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler@c712fe’: null
java.lang.NumberFormatException: null
at java.math.BigDecimal.(BigDecimal.java:494) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:383) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:806) ~[?:?]
at org.eclipse.smarthome.core.library.types.DecimalType.(DecimalType.java:57) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.library.types.PercentType.(PercentType.java:47) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.library.types.PercentType.valueOf(PercentType.java:63) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.binding.mqtt.generic.internal.values.PercentageValue.update(PercentageValue.java:87) ~[?:?]
at org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState.publishValue(ChannelState.java:302) ~[?:?]
at org.eclipse.smarthome.binding.mqtt.generic.internal.handler.AbstractMQTTThingHandler.handleCommand(AbstractMQTTThingHandler.java:119) ~[?:?]
at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at com.sun.proxy.$Proxy146.handleCommand(Unknown Source) [201:org.eclipse.smarthome.binding.mqtt.generic:0.10.0.oh240]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
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) [?:?]

With a slider object in a sitemap I have no problems except the crazy decimal numers that makes it almost impossible to slide.

Edit: This was just because I forget to format the String

Slider item=Hue_white_HueWhite label=“Hue [%.0f ]” icon=“lightbulb”

Can someone see any mistakes on my configuration?

That’s the normal result of the autoupdate feature, which is enabled by default.
It listens for commands to an Item, just like a binding, and makes a guess at the likely effect on the Items state, and issues an update.
Example
command ON → prediction 100 for a dimmer type
command 35 → prediction 35 for a dimmer type

You don’t usually need autoupdate’s “help” if you are getting timely status updates from your device, that set the Item’s state instead. It can be disabled on individual Items.

@rossko57 Thanks for your response :slight_smile:

To disable the autoupdate feature actually solved the problem with the jumping light brightness!

But I still have this errer message in my log.

2019-05-24 13:36:05.463 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler@e54558’: null
java.lang.NumberFormatException: null
at java.math.BigDecimal.(BigDecimal.java:494) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:383) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:806) ~[?:?]
at org.eclipse.smarthome.core.library.types.DecimalType.(DecimalType.java:57) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.library.types.PercentType.(PercentType.java:47) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.library.types.PercentType.valueOf(PercentType.java:63) ~[102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.binding.mqtt.generic.internal.values.PercentageValue.update(PercentageValue.java:87) ~[?:?]
at org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState.publishValue(ChannelState.java:302) ~[?:?]
at org.eclipse.smarthome.binding.mqtt.generic.internal.handler.AbstractMQTTThingHandler.handleCommand(AbstractMQTTThingHandler.java:119) ~[?:?]
at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at com.sun.proxy.$Proxy146.handleCommand(Unknown Source) [201:org.eclipse.smarthome.binding.mqtt.generic:0.10.0.oh240]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
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) [?:?]

Maybe its because homekit is sending ON commands everytime I change the brightness?