Help setting up mqtt 2.4

Hi, i’m trying to setup OH to receive temperature & humidity data from some esp8266+dht22 sensors that publish with homeassistant autodiscovery format.
For what i’ve understand this format is supported.

i’ve installed the mqtt 2.4 bindings and i have create a .things file:

mqtt:broker:myBroker [ host="192.168.1.xxx",secure=false, username="<myUser>", password="<myPassword>" ]

but i’m getting this from the log:

019-02-05 13:43:22.795 [ERROR] [g.discovery.AbstractDiscoveryService] - An error occurred while calling the discovery listener org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.
java.lang.NullPointerException: null
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.thingRemoved(DiscoveryServiceRegistryImpl.java:278) ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.thingRemoved(AbstractDiscoveryService.java:300) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:164) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [248:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2019-02-05 13:43:22.905 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'mqtt:homeassistant:myBroker:config' to inbox.

and any other things are not discovered. what i’m doing wrong?

thanx in advance

If you’ve copied the thing configuration exactly as you’ve typed it - then it appears you’re missing a space before “secure”. I’ve found the thing configuration to be very particular about those spaces.

Past that I’ll leave it to someone else because if your information (ip, user, password) is correct then I don’t know what the issue is.

I’ve added the space before “secure”, but I still have that error in the log:

2019-02-05 19:02:23.695 [ERROR] [g.discovery.AbstractDiscoveryService] - An error occurred while calling the discovery listener org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.
java.lang.NullPointerException: null
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.thingRemoved(DiscoveryServiceRegistryImpl.java:278) ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.thingRemoved(AbstractDiscoveryService.java:300) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:164) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [248:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [244:org.eclipse.paho.client.mqttv3:1.2.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

don’t know if it’s related to those errors… but I wasn’t able to configure Mqtt broker via paper ui… I’ve manually create the .things file, and I can’t find any Mqtt.cfg under /service/…

Using the MQTTv2 binding no mqtt.cfg is needed!
Please state what you have setup: which broker (embedded, mosquitto or…), your posted line from a thing file is missing the starting “Bridge” (this line would create the connection to the broker.

I did some step forward… now my problem is how to configure the HomeAssistant MQTT component…
actually I have a sensor that send the following messages:

for configuration:
topic1:

homeassistant/sensor/camera2_temp/config

message1:

{"device_class":"temperature","name":"camera2_temp","state_topic":"homeassistant/sensor/camera2/state","unit_of_measurement":"°C","value_template":"{{ value_json.temperature }}"}

topic2:

homeassistant/sensor/camera2_hum/config

message2:

{"device_class":"humidity","name":"camera2_hum","state_topic":"homeassistant/sensor/camera2/state","unit_of_measurement":"%","value_template":"{{ value_json.humidity }}"}

for the state:
topic:

homeassistant/sensor/camera2/state

message:

 {"time":"21:37:30","temperature":"18.90","humidity":"59.00"}

I tryed to setup the object id as camera2 but OH don’t recognize it and the status of the component (thing) is offline…

In PaperUI, add a thing, MQTT, add manually, generic thing
Name it, Change the ID to something human (I recommend the name without spaces)

Add your channels… Done

doesn’t work… I’ve added 2 channels, 1 for temperature and 1 for humidity with same datas (except the id and label)

but still no data…
my items:

Number   SensoreCameretta_Temperatura   "temperatura"   {channel="mqtt:topic:07afdf83:temperatura"}
Number   SensoreCameretta_Umidita       "umidita"       {channel="mqtt:topic:07afdf83:umidita"}

my sitemaps

Frame label="Sensori"{

Text item=SensoreCameretta_Temperatura

Text item=SensoreCameretta_Umidita

    }

i log file I get:

2019-02-06 13:46:40.348 [WARN ] [eneric.internal.generic.ChannelState] - Incoming payload '{"time":"13:46:40","temperature":"19.00","humidity":"57.20"}' not supported by type 'NumberValue'

problem solved! I have had to install JSONPATH and set a trasformation in the channel like JSONPATH:$.temperature and JSONPATH:$.humidity

i post again because today after a reboot I get that error again:

2019-02-07 19:26:33.345 [ERROR] [g.discovery.AbstractDiscoveryService] - An error occurred while calling the discovery listener org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.
java.lang.NullPointerException: null
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.thingRemoved(DiscoveryServiceRegistryImpl.java:278) ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.thingRemoved(AbstractDiscoveryService.java:300) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:164) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [260:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [256:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [256:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [256:org.eclipse.paho.client.mqttv3:1.2.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

the error seems related to HomeAssistant MQTT also if I have setup the sensors as generic mqtt. After the reboot a new device has been discovered (HomeAssistant MQTT Component)
searching on google I discovered this https://github.com/eclipse/smarthome/issues/6830 … maybe there’s a bug in the HA Mqtt component?