[SOLVED] MQTT items need to be readded

Hello !

I am running OH2
Version: 2.5.0-SNAPSHOT (#1675)
Hardware is RPI3 with openhabian

Now, I have recently experienced issues with MQTT Devices getting
HANDLER_INITIALIZING_ERROR

Syslog says this
" message=“Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:comfortzone’: hexString contains illegal character for hexToBytes: 97”] Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:comfortzone’: hexString contains illegal character for hexToBytes: 97

If I remove the thing and then re-add it, it all works fine for a while (weeks)

Is it possible to script this item removal / re-add if the problem I have is a bug?

Cheers
Gudmund

This is not the full log line. please show the full log line.

Hi!

I add below a few lines :slight_smile:

The work around is to remove the thing in PaperUI and immediately re-add it.

Sep 1 13:26:03 openhab openhab2 ‘mqtt:homie300:4ee3104e:temp_sensors’ changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101 to UNINITIALIZED
Sep 1 13:26:03 openhab openhab2 ‘mqtt:homie300:4ee3104e:comfortzone’ changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 97 to UNINITIALIZED
Sep 1 13:26:03 openhab openhab2 ‘mqtt:homie300:4ee3104e:energy_counters’ changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101 to UNINITIALIZED
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@1337d22’: hexString contains illegal character for hexToBytes: 101”] An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@1337d22’: hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:temp_sensors’ updated: UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:temp_sensors’ changed from INITIALIZING to UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:temp_sensors’: hexString contains illegal character for hexToBytes: 101”] Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:temp_sensors’: hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@85e572’: hexString contains illegal character for hexToBytes: 101”] An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@85e572’: hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:energy_counters’ updated: UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:energy_counters’: hexString contains illegal character for hexToBytes: 101”] Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:energy_counters’: hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:energy_counters’ changed from INITIALIZING to UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 101
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@bb9bc0’: hexString contains illegal character for hexToBytes: 97”] An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.mqtt.homie.internal.handler.HomieThingHandler@bb9bc0’: hexString contains illegal character for hexToBytes: 97
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.unhex(HexUtils.java:139)
Sep 1 13:27:33 openhab.lan #011at org.eclipse.smarthome.core.util.HexUtils.hexToByte(HexUtils.java:123)
Sep 1 13:27:33 openhab.lan " message=“Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:comfortzone’: hexString contains illegal character for hexToBytes: 97”] Exception occurred while initializing handler of thing ‘mqtt:homie300:4ee3104e:comfortzone’: hexString contains illegal character for hexToBytes: 97
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:comfortzone’ updated: UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 97
Sep 1 13:27:33 openhab openhab2 ‘mqtt:homie300:4ee3104e:comfortzone’ changed from INITIALIZING to UNINITIALIZED (HANDLER_INITIALIZING_ERROR): hexString contains illegal character for hexToBytes: 97

Ok. It seem that hexToBytes expects upper case letters while lower case letters are supplied. Can you verify that? A tool like MQTT Inspector ok iOS (surely there is an equivalent on Android) might help.

Hi
Thank you for trying to help me !

Do you mean that I should test and give all MQTT topics /values upper case letters only?
Or is is certain parts only ?

Only the Hex values exposed during the Homie presentation. Characters 97 and 101 are a and e respectively.

@David_Graeff, you are familiar with this, can you enlighten us, please?

Hi
Just so I do not missunderstand you now, but I have no hex values in my MQTT topics or values.
Of course the plain ascii could be converted internally in the binding somewhere to hex?

I‘ll look into that the next days

This may be a lead ?
From PaperUI. Note that this device is still Online, but the Channels looks weird?

That looks good. I think your pronlem might be related to the latest changes regarding encoding of special characters. Can you show the same view for the device that has problems?

Hi, no special characters should be in these channels.
“mqtt:homie:714b1d70:power_5Ffan#powerpercent” is defined as “mqtt:homie:714b1d70:power_fan#powerpercent”

Not 100% sure, but I Think that this “5F” is quite new. Maybe in the latest snapshot. Not sure.

At this Point, all devices works…

_ is a special character. There was a note during upgrade that old chanel definitions might fail.

Ah !
Then I will remove these underscores and see if situation improves.
Thank you :slight_smile:

Gudmund

This seems related

So far as we could tell there, underscores _ should be allowed in thing IDs.

Are all underscores alike, though?

They are. I think documentation needs to be adapted here. We have the situation that the homie binding maps MQTT topics to channel names. We had to find a way to make this possible for all special characters and the way is to escape all characters except A-Za-z0-9. This is done by converting the character to the equivalent hexadecimal string and prepend that with the allowed special character _.

So the topic command_topic is parsed, the _ is found, this is converted to _5F and the corresponding channel name is then command_5Ftopic. So the problem arises if you define a channel name with an underscore (sample_channel) and the homie binding (this is only happening for homie!) tries to convert that back to a topic. It sees the _ and expects the next to characters to be the hexadecimal ASCII code of the escaped character. Of course ch is not a valid hexadecimal value and the exception occurs.

1 Like

I, I can confirm that removing underscores was a salvation here.
Not only that the exeptions dissapeared, new Items now automatically shows up in the inbox.
Previously I had to manually search…

Thanks alot :slight_smile:

Gudmund

Uff. I thought the new core methods are doing a base48 encoding for the entire string without special marker characters. That’s bad news.