Incorrect character encoding in MQTT binding?

Accented characters sent by openHAB MQTT binding appear not to be incoded to utf8 as per MQTT 3.1.1 specification.
For example, calling:

sendCommand(myKodi_artist, "Accentué")

sendCommand(myKodi_artist, "Accentu\u00E9")
properly sets the myKodi_artist item
BUT sends a message on MQTT bus where the text is not encoded to utf8.
As a result, listener clients close connection as recommended in the MQTT 3.1.1 specification when a malformed message is received. And this is crashing all my HA system.

Can anyone confirm this point?

I have the same problem with Cyrillic letters.

I use the event bus mqtt bridge to connect openhab v1 with openhab v2
and openhab1 does not send the letters properly (Get <?> symbols). Also if I manually publish to a topic by external client, openahb2 is receiving it like ? symbols.

Probably an old bug.

I have the same problem. For me it affects text I want to send to the AmazonEchoControl (Beta: Openhab2 AmazonEchoControl Binding (controlling alexa from openhab2)) binding via MQTT. Text containing e.g. German umlauts is not received correctly by the MQTT binding.

I opened a bug in git at You might want to add your comments / experience there.

I think I see where this is going wrong, but if someone can provide a debug log to help confirm, that’d be great…

What kind of log do you need? I can help.

But there are just ? for each letter outside basic Latin character set. I suspected that it is the web GUI but it is not.

Just the usual openhab.log, with DEBUG enabled for the MQTT bits.

log:set DEBUG org.openhab.binding.mqtt
log:set DEBUG

there is nothing special logged even with there settings

2018-05-08 23:45:05.112 [vent.ItemStateChangedEvent] - Mreza_Athlon_probe changed from NULL to ON
2018-05-08 23:45:05.618 [vent.ItemStateChangedEvent] - Msg2 changed from NULL to ???????????????? 2 ????????????????
2018-05-08 23:45:05.891 [vent.ItemStateChangedEvent] - Location_Phone2_Mqtt_rabota changed from NULL to OFF
2018-05-08 23:45:06.518 [vent.ItemStateChangedEvent] - Location_Phone2_Mqtt_centar changed from NULL to OFF

Msg2 should become “Кирилица 2 Латиница”

2018-05-08 23:43:39.159 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to mk_MK, Location set to 41.997346199                                                                999996,21.4279956, Time zone set to Europe/Skopje
2018-05-08 23:43:40.090 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-05-08 23:43:41.134 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at
2018-05-08 23:43:41.147 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at
2018-05-08 23:43:48.526 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'items.items'
2018-05-08 23:43:54.719 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-05-08 23:43:56.282 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'default.sitemap'
2018-05-08 23:44:01.823 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-05-08 23:44:02.184 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app
2018-05-08 23:44:02.231 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-05-08 23:44:02.302 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2018-05-08 23:44:02.557 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-05-08 23:44:02.821 [DEBUG] [] - Starting MQTT Service...
2018-05-08 23:44:02.823 [DEBUG] [       ] - ServiceEvent REGISTERED - {,}={, Connection Service,,, service.bundleid=241, service.scope=bundle} -
2018-05-08 23:44:02.859 [DEBUG] [       ] - BundleEvent STARTING -
2018-05-08 23:44:02.897 [DEBUG] [       ] - BundleEvent STARTED -
2018-05-08 23:44:02.896 [DEBUG] [] - Setting last will: [class] Send 'OFF' to topic 'ohab/@' retained using qos mode 1
2018-05-08 23:44:02.898 [INFO ] [] - MQTT Service initialization completed.
2018-05-08 23:44:02.911 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'ohabssl'
2018-05-08 23:44:02.918 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Creating new client for 'ssl://'  using id 'glusec-openhab2' and file store '/var/lib/openhab2/tmp/ohabssl'
2018-05-08 23:44:03.188 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:broker
2018-05-08 23:44:03.191 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:topic
2018-05-08 23:44:03.193 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:message
2018-05-08 23:44:03.528 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTING - org.openhab.binding.mqtt
2018-05-08 23:44:03.550 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2018-05-08 23:44:03.649 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*,,, service                                                      .id=372, service.bundleid=275, service.scope=bundle} - org.openhab.binding.mqtt
2018-05-08 23:44:03.653 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={                                                                icbindingprovider,,, service.bundleid=275, service.scope=bundle} - org.openhab.binding.mqtt


This is from MQTT Spy app

Msg1 is exported like that from openhab1 to mqtt
I publish to Msg2 from MQTT Spy to force Cyrillic but again openhab2 does not display that properly.

Msg1 and Msg2 are <?> in openhab2

These jars implement a first attempt at a fix. If this does not resolve the issue, I’ll need to see your item/sitemap/rule definitions…

org.openhab.binding.mqtt jar jar

The binding does not work at all with OpenHab1.5 so upgraded to 1.8

I post to MQTT topic Cyrillic string. I see it ok in the OH1 console but the item state is not OK, web UI is also garbage (but not <?>).

Then OH1 post it to event-bus mqtt …correctly!

Then OH2 imports it badly but I did not upgrade the binding there…finding the way

There is still something to be fixed in the binding. I see it properly in the OpenHab1 console as the BAT has this at the top

@echo off
chcp 65001

Nothing special about my rules or items. I do not process the stings actually.

I publish Cyrillic text to mqtt topic multimedia/top_album_1 and I get wrong results

BUT I did another test, if I change item via REST API, it will get the Cyrrilic OK and the MQTT binding will post it correctly to the MQTT broker

String MusicTopAlbum1	  "[%s]"	<music_title> 	{ mqtt="<[ohabssl:multimedia/top_album_1:state:REGEX((.*))]" } 

I’ve just posted updated jars (same links as before). Tested in OH 2.1 and appear to be working.



It works when flow is

MQTT -> OpenHab item

but on exit to the eventbus MQTT topic

MQTT -> OpenHab item -> MQTT event bus ohab/out/state/EarthQuake_1_Text
it is with <?> … now

The exit was working before

I am testing on 1.83 OH