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.
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:
Correct the publisher code so that only digits and optional decimal point appear in the message, or
You add a transform in place of default that trims the spaces off of the message, or
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.
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”)…
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.
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:
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: