OH2 Dynamic Items and Sitemaps

I have been playing around a bit with Openhab2 and am still fairly new to it. I am currently working on my own sensors that feed data into openhab by using mqtt messages. I found some work that allows mqtt messages to be dynamically added to Things which I got working. Found here: MQTT Binding

I am a bit confused on to how to translate this to something useful on the sitemap. From what I can tell I still have to manually add to the sitemap to display that new Thing. I guess I am wondering if there is a way through paperui or through Rules/scripts that could dynamically display new Things that are added through PaperUI.

Just for reference my plan is to hook up new sensors (temperature, door switches, etc…) and just have them display on the sitemap without any involvement from me. Unfortunately I am more comfortable in the embedded world and could get around this by writing a python script to dynamically add items and entries into the .items file and .sitemap file, but I was hoping to do this the openhab way if at all possible.

I think that in the mean time things have improved a bit…(while I created the mqtt binding many possibilities were not supported yet by any gui)
Like you can enable channels in the gui, they have the right label etc.

If you set openhab in the automatic item creation mode, add soon as you enable the channel it will also make a item for you.

I think also the most basic (auto) sitemap will create an entry for each thing.

Anything more advanced you probably need at least to add items to a group and have a group entry in your sitemap

Thank you for the reply. Started looking into this more as I was only getting Things to be created without any channels. It seems I am getting an exception using the mqtt auto discovery.

2017-01-08 11:02:37.631 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker '99b232a0'
2017-01-08 11:02:47.631 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '99b232a0'
2017-01-08 11:02:52.991 [INFO ] [ome.binding.mqtt.handler.MqttHandler] - creating channel for topic 'RFGatewayInTemperature0' for thing mqtt:topic:RFGatewayInTemperature
2017-01-08 11:02:52.993 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
MqttException (0) - java.lang.NoSuchMethodError: org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder.withChannel(Lorg/eclipse/smarthome/core/thing/Channel;)Lorg/eclipse/smarthome/core/thing/binding/builder/GenericThingBuilder;
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:171)[192:org.eclipse.smarthome.io.transport.mqtt:0.8.0.201701032350]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.lang.NoSuchMethodError: org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder.withChannel(Lorg/eclipse/smarthome/core/thing/Channel;)Lorg/eclipse/smarthome/core/thing/binding/builder/GenericThingBuilder;
	at org.eclipse.smarthome.binding.mqtt.handler.MqttHandler.newChannelfromTopic(MqttHandler.java:425)
	at org.eclipse.smarthome.binding.mqtt.handler.MqttHandler.newChannelfromTopic(MqttHandler.java:393)
	at org.eclipse.smarthome.binding.mqtt.handler.MqttHandler.mqttStateReceived(MqttHandler.java:292)
	at org.eclipse.smarthome.binding.mqtt.internal.MqttMessageSubscriber.processMessage(MqttMessageSubscriber.java:139)
	at org.eclipse.smarthome.io.transport.mqtt.internal.MqttBrokerConnection.messageArrived(MqttBrokerConnection.java:614)[192:org.eclipse.smarthome.io.transport.mqtt:0.8.0.201701032350]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:336)[192:org.eclipse.smarthome.io.transport.mqtt:0.8.0.201701032350]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:148)[192:org.eclipse.smarthome.io.transport.mqtt:0.8.0.201701032350]
	... 1 more
2017-01-08 11:02:52.997 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to '99b232a0' was lost: MqttException : ReasonCode 0 : Cause : org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder.withChannel(Lorg/eclipse/smarthome/core/thing/Channel;)Lorg/eclipse/smarthome/core/thing/binding/builder/GenericThingBuilder;
2017-01-08 11:02:52.999 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker '99b232a0'
2017-01-08 11:03:02.999 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '99b232a0'

If you could just point me in the right direction I am sure I can stumble through and try to find out what is going on. Thanks!

I’ll need to check, from the error log it seems that a functions called which is not existent.
One of the causes for this could be that a channel or itemis created with a not supported name… (e.g. spaces in it)
Can that be the case? What topic names you are expecting?

I yesterday was looking into the binding again… was able to tackle one of the 2 major issues I had…

2nd one is not tackled yet (need to see if it is issue in my code, or issue of the OH/smarthome framework).
However, I have good hopes that I either will fix that, or can implement a workaround for it.

Thanks again for the reply, I haven’t had much time to look at this. But I am fairly certain its a version mismatch since I was running the latest openhab and just building this and placing it into the addons folder. I will play around with this some more and see if I can get it working with the latest version of Openhab.