How to subscribe an mqtt state and show it on the sitemap


I use openHAB 2.5.12-1 and want to know how I can subscribe mqtt states and show this state on the sitemap. What is clear is that I have to use an .items file and inside the sitemap I will import this item.

Why I want to know this is simple: I have many different devices that provide information via MQTT. I would like to display this information.

What already works is that I transfer this information via the corresponding broker, which I have also integrated in openHAB. I can subscribe to the topic(s) accordingly via MQTT.fx. Since I will soon be switching from the MQTT 1 binding to the MQTT 2 binding, it would be useful for me if I had the solutions for both. (Somehow I run out of time, otherwise I would have done it long ago…).

For me, the broker is called MQTTBroker. The mqtt-eventbus uses statePublishTopic=/messages/states/${item} or stateSubscribeTopic=/messages/states/${item}. Therefore, I have been guided by the fact that I publish to /messages/states from my external devices (as example self-built robots).

Thanks in advance

See MQTT 2.5 Event Bus