[SOLVED] "java.lang.NumberFormatException" with profile=follow by number Items

Hello everyone,

I started working with openHAB a couple of days ago and in the moment I am trying to establish a MQTT connection to a Beckhoff PLC (TC3).

I have no problems on the PLC side, but openHab drives me crazy so far :smiley:
I basically want to forward all openHAB items to the Beckhoff PLC.For that I created a broker, a connection and some channels.

Bridge mqtt:broker:Tc3 "TC3_Broker" [ host="", port=1883, secure=false, clientID="openHAB2", username="Marcel", password="XXXXX"]
  // My OBI switches with Tasmota
  Thing topic Connection "TC3" {

     Type string : MyMessage "Tc3_Message" [ stateTopic="openHab/MyMessage", commandTopic="openHab/MyMessage", retained=true, postCommand=true ]

     Type string : OfficePrinterStatusStatus [ commandTopic="openHab/Office/Printer/StatusStatus", retained=true, postCommand=true ]
     Type number : OfficePrinterInkBlackLevel [ commandTopic="openHab/Office/Printer/InkBlackLevel", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageTotalCount [ commandTopic="openHab/Office/Printer/UsageTotalCount", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageBlackMarker [ commandTopic="openHab/Office/Printer/UsageBlackMarker", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageColorMarker [ commandTopic="openHab/Office/Printer/UsageColorMarker", retained=true, postCommand=true ]
     Type number : OfficePrinterInkColorLevel [ commandTopic="openHab/Office/Printer/InkColorLevel", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageTotalColorCount [ commandTopic="openHab/Office/Printer/UsageTotalColorCount", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageTotalMonochromeCount [ commandTopic="openHab/Office/Printer/UsageTotalMonochromeCount", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageJamEvents [ commandTopic="openHab/Office/Printer/UsageJamEvents", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageMispickEvents [ commandTopic="openHab/Office/Printer/UsageMispickEvents", retained=true, postCommand=true ]
     Type number : OfficePrinterUsageSubsciptionCount [ commandTopic="openHab/Office/Printer/UsageSubsciptionCount", retained=true, postCommand=true ]
  //Marcel Handy  
     Type switch : MarcelHandyOnline [ commandTopic="openHab/Network/MarcelHandy/Online", retained=true, postCommand=true, on="true", off="false" ]
     Type number : MarcelHandyLatency [ commandTopic="openHab/Network/MarcelHandy/Latency", retained=true , postCommand=true ]

The actual channels from the things look like these:

Switch        MarcelHandyOnline     "Online"      {channel="network:pingdevice:192_168_0_26:online", channel="mqtt:topic:Tc3:Connection:MarcelHandyOnline" [profile="follow"]}
Number:Time   MarcelHandyLatency    "Latency"     {channel="network:pingdevice:192_168_0_26:latency", channel="mqtt:topic:Tc3:Connection:MarcelHandyLatency"}

With the profile: follow by the Switch item I am able to forward the information via MQTT as excpected. But if I add the profile to the number item I will get an exception:

2020-02-09 13:46:11.183 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@f46152': null
java.lang.NumberFormatException: null
	at java.math.BigDecimal.<init>(BigDecimal.java:497) ~[?:1.8.0_232]
	at java.math.BigDecimal.<init>(BigDecimal.java:383) ~[?:1.8.0_232]
	at java.math.BigDecimal.<init>(BigDecimal.java:809) ~[?:1.8.0_232]
	at org.openhab.binding.mqtt.generic.values.NumberValue.update(NumberValue.java:106) ~[?:?]
	at org.openhab.binding.mqtt.generic.ChannelState.publishValue(ChannelState.java:333) ~[?:?]
	at org.openhab.binding.mqtt.generic.AbstractMQTTThingHandler.handleCommand(AbstractMQTTThingHandler.java:128) ~[?:?]
	at sun.reflect.GeneratedMethodAccessor215.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
	at com.sun.proxy.$Proxy54119.handleCommand(Unknown Source) [?:?]
	at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]
	at org.eclipse.smarthome.core.thing.internal.profiles.SystemFollowProfile.onStateUpdateFromItem(SystemFollowProfile.java:60) [bundleFile:?]
	at sun.reflect.GeneratedMethodAccessor212.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_232]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_232]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]

So alle number items want get published at all. I could go with the work arround and create rules for every item, but that is not the right way and would take to much time.

I appreciate all your help.


@MarcelPayne: Is that really your password that’s posted in the config above? If so you may want to xxxxx it out. :wink:

Thanks, I fixed and changed it :slight_smile:

But any idea about the problem?

Does other item types work as expected? I remember that a while I was trying to get Beckhoff working with OH problem was caused by extra character appended by PLC at the end of every string - it was a ‘\0’.

You might also take a look on native ADS binding here: [co7io] Industrial integrations with Beckhoff ADS/Siemens S7

Yes, the switch item in my example does work. But I will have a look to your link as well. Thanks

Did you try without using UoM?


Number   MarcelHandyLatency    "Latency"     {channel="network:pingdevice:192_168_0_26:latency", channel="mqtt:topic:Tc3:Connection:MarcelHandyLatency" [profile="follow"]}

That helped, thank you. Do you know why?

@splatch: I like your ADS project. If zou need a tester, send me a PN.

I assume you are referring to H102’s suggestion to not use UoM. It probably helped because when using UoM, the unit is part of the state. So for example, a Number:Time isn’t 25, it’s .025 s.

So the MQTT binding gets .025 s which cannot be parsed into a plain old Number so it throws an error. Unfortunately, the MQTT binding doesn’t support UoM. I think there is an issue open to add that but am not sure if it is still open.

1 Like