[Solved] MQTT - OpenHab2 communication issue

Toggling the switch, also the switch name on BASIC UI has changed from: “MQTTEST” to “Testing…”
Now it seems to work, but BASIC HUB does not recognize changes in real time. When publications are sent via devices, I do not see changes in the panel.

As test, I tried to connect a DHT22 via ESP8266 using the Homie framework. From the shell I can see the messages that are regularly received, but nothing can be seen from the panel.

/var/log/mosquitto/mosquitto.log

1543000990: New connection from 192.168.1.8 on port 1883.
1543000990: New client connected from 192.168.1.8 as Homie-termostato (c1, k15).
1543000990: Sending CONNACK to Homie-termostato (0)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m1, 'homie/termostato/$homie', ... (5 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 1)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m2, 'homie/termostato/$mac', ... (17 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 2)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m3, 'homie/termostato/$name', ... (10 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 3)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m4, 'homie/termostato/$localip', ... (11 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 4)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m5, 'homie/termostato/$stats/interval', ... (2 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 5)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m6, 'homie/termostato/$fw/name', ... (10 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 6)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m7, 'homie/termostato/$fw/version', ... (5 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 7)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m8, 'homie/termostato/$fw/checksum', ... (32 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 8)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m9, 'homie/termostato/$implementation', ... (7 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 9)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m10, 'homie/termostato/$implementation/config', ... (245 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 10)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m11, 'homie/termostato/$implementation/version', ... (5 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 11)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m12, 'homie/termostato/$implementation/ota/enabled', ... (5 bytes))
1543000990: Sending PUBACK to Homie-termostato (Mid: 12)
1543000990: Received PUBLISH from Homie-termostato (d0, q1, r1, m13, 'homie/termostato/temperature/$type', ... (11 bytes))

$OPENHAB_CONF/logs/openhab.log

2018-11-23 20:13:31.996 [WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line 'pid:org.openhab.mqtt'
2018-11-23 20:13:32.584 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to it_IT, Location set to null, Time zone set to Europe/Rome
2018-11-23 20:13:34.155 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.1.254:8080
2018-11-23 20:13:34.168 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.1.254:8443
2018-11-23 20:13:42.530 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.items'
2018-11-23 20:13:43.309 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'influxdb.persist'
2018-11-23 20:13:47.081 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-11-23 20:13:47.733 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'demo.sitemap'
2018-11-23 20:13:50.256 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-11-23 20:13:50.261 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'oh2broker'
2018-11-23 20:13:51.976 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-11-23 20:13:52.486 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app
2018-11-23 20:13:52.571 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-11-23 20:13:52.751 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2018-11-23 20:13:52.913 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-11-23 20:17:52.225 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text
2018-11-23 20:17:52.228 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperatura' for widget org.eclipse.smarthome.model.sitemap.Text
2018-11-23 20:17:52.231 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperatura' for widget org.eclipse.smarthome.model.sitemap.Text
2018-11-23 20:17:52.232 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Temperatura' for widget org.eclipse.smarthome.model.sitemap.Text

$OPENHAB_CONF/logs/events.log don’t recognine anything

$OPENHAB_CONF/sitemaps/demo.sitemap

sitemap demo label="TEST" {
    Frame label="MQTT" {
        Switch item=MQTT_Test icon="light"
        Text item=Temperatura
    }
}

$OPENHAB_CONF/items/test.items

Switch MQTT_Test "Testing..." { mqtt="<[oh2broker:testing/mqtt/topic:state:default], >[oh2broker:testing/mqtt/back-topic:command:*:default]" }
Text Temperatura "Temperatura in °C" { mqtt="<[oh2broker:homie/termostato/temperature/temperature:state:default]"}

This command on the shell:

mosquitto_sub -h localhost -t "homie/#" -v

give me this output:

homie/termostato/$homie 2.0.0
homie/termostato/$mac CC:50:E3:0C:CD:09
homie/termostato/$name Termostato
homie/termostato/$localip 192.168.1.8
homie/termostato/$stats/interval 60
homie/termostato/$stats/signal 84
homie/termostato/$stats/uptime 424
homie/termostato/$fw/name demo-dht22
homie/termostato/$fw/version 1.0.0
homie/termostato/$fw/checksum 222a0c5e624c4bbee4ea4d46d62ac841
homie/termostato/$implementation esp8266
homie/termostato/$implementation/config {"name":"Termostato","device_id":"termostato","device_stats_interval":60,"wifi":{"ssid":"InfostradaWiFi-002016"},"mqtt":{"host":"192.168.1.254","port":1883,"base_topic":"homie/","auth":false},"ota":{"enabled":false},"settings":{"percentage":55}}
homie/termostato/$implementation/version 2.0.0
homie/termostato/$implementation/ota/enabled false
homie/termostato/$online true
homie/termostato/temperature/$type temperature
homie/termostato/temperature/temperature 20.70
homie/termostato/temperature/json {"t":20.70,"unit":"c"}
homie/termostato/humidity/$type humidity
homie/termostato/humidity/humidity 75.80
homie/termostato/humidity/json {"h":20.70,"unit":"%"}
Number Temperatura "Temperatura [%.2f °C]" { mqtt="<[oh2broker:homie/termostato/temperature/temperature:state:default]"}

The Text is a sitemap element (not an Item type). To get temp readings, use a Number Item.

  1. Items | openHAB
  2. https://www.openhab.org/docs/configuration/sitemaps.html#sitemaps

what do you mean? If you send a MQTT message to topic testing/mqtt/topic with payload OFF it will turn off the switch in your BasicUI. It doesn’t?

That’s normal since this is the label of the Item with name MQTT_Test (Label is not the same as Name)

1 Like

Now works! Thank you so much for the support :partying_face:

1 Like