Cannot make the simplest MQTT message appear

OH1 running on Pi3; ESP8266 sending a fixed message.

I have stripped the config to a bare minimum to get this working, but no luck.

The MQTT message is a simple “123”. I can read this on the broker device using “mosquitto_sub”.
I can read the same message on an android MQTT reader, so I assume that the MQTT side is working fine.

My item config:

Number Outside_temperature "label [%d]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }

My sitemap:

sitemap Arosfa label="Main Menu"
        Frame label="ESP1 board" {
                Text item=Outside_temperature

What I see in the browser is “label” and just a " - "; no actual value.

I’m lost!!

Try "label [%s]"?

Yup, already tried [%s], also [%d] and various [%…f] formats.
If I use no format argument at all [ ] it does show an error.

It may be that the message being published to the broker has space characters padding it before or after the allowed digits (and possible decimal point). If so, the MQTT binding will fail to convert it to a number, until you either:

  1. Correct the publisher code so that only digits and optional decimal point appear in the message, or
  2. You add a transform in place of default that trims the spaces off of the message, or
  3. Least appealing: you change the item from Number to String (and use [%s] in the label) so no conversion is needed in handling the input.

I’ve tried handling the message as a raw string with:

String Outside_temperature "label [%s]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }

…but no change, still seeing only " - ".

Reading the message payload both with mosquitto_sub and with an Android client, and there appear to be no added spaces.
I have checked the payload generator, and it simply does Client.Publish (topic, “123”)…

Further experiments, but still not seeing the MQTT payload on screen.

I’ve tried defining multiple items with every combination of String/Text/Number, and every choice of %s, %d, %.1f, and others… No results.

Have found this line in the log:

[DEBUG] [i.internal.GenericItemProvider] - Couldn't find ItemFactory for item 'Outside_temperature2' of type 'Text'

What is the “ItemFactory”?

Outside_temperature2 looks like the wrong item name?

This is the item config line:

Text Outside_temperature2 "label2 [%.1f]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }

Try String Outside_temperature2 ...

Text is the sitemap widget to use, for displaying a String item

Still no luck!


String Outside_temperature "label[%.1f]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }
Text Outside_temperature2 "label2 [%.1f]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }
Number Outside_temperature3 "label3 [%.1f]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }

The Sitemap:

sitemap Arosfa label="Main Menu"
        Frame label="ESP1 board" {
                Text item=Outside_temperature
                Text item=Outside_temperature2
                Text item=Outside_temperature3

Continues to complain about ItemFactory shortly after launch, but only for the ‘Text’ item:~

2016-11-05 23:04:19.584 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.items’
2016-11-05 23:04:19.671 [DEBUG] [i.internal.GenericItemProvider] - Processing binding configs for items from model 'default.items’
2016-11-05 23:04:19.682 [DEBUG] [i.internal.GenericItemProvider] - Couldn’t find ItemFactory for item ‘Outside_temperature2’ of type 'Text’
2016-11-05 23:04:19.685 [DEBUG] [i.internal.GenericItemProvider] - Read items from model 'default.items’
2016-11-05 23:04:19.691 [DEBUG] [i.internal.GenericItemProvider] - Couldn’t find ItemFactory for item ‘Outside_temperature2’ of type 'Text’
2016-11-05 23:04:19.980 [DEBUG] [.m.i.MyOpenHABServiceActivator] - MyOpenHAB service has been started.

Could your add your mqtt binding config please from the .cfg file?

This is still incorrect – Text is a sitemap widget, but in your .items file, you have to use item types, like String. Replace the above line in your items file with:

String Outside_temperature2 "label2 [%.s]" { mqtt="<[mosquitto:sensors/test/temperature:state:default]" }

Setting up as a String item has indeed removed the ‘ItemFactory’ error, but now…

The MQTT payload on screen now gives “Err”.

1tech: mqtt binding from openhab.cfg has just the one non-optional line defined:

I am not familiar with OH1 but in OH2 you need another line in the config file to define openHAB as a client. The syntax will be different, but mine is defined as follows:


Hope this helps…