Ok…
Since sonoff is publishing correctly the messages to your Mosquitto MQTT Broker, you need to focus on the Mosquitto to openHAB connection and item configuration.
Troubleshoot first the main connection between MQTT and OH2.
You will need to use the openHAB console for this.
To enter into the console, from an ssh shell (prompt: pi@openHABianPi:~$
) in your rPi type:
sudo ssh openhab@localhost -p 8101
Enter the password: habopen
Set log levels:
log:set TRACE org.openhab.binding.mqtt
log:set TRACE org.openhab.io.transport.mqtt
restart the MQTT Binding:
bundle:restart org.openhab.binding.mqtt
Check logs for connection messages of the following kind:
==> openhab.log <==
2017-02-12 22:53:15.437 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STOPPING - org.openhab.binding.mqtt
2017-02-12 22:53:15.439 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent UNREGISTERING - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=201, service.id=343, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 22:53:15.441 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent UNREGISTERING - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=202, service.id=341, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 22:53:15.444 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent UNREGISTERING - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=203, service.id=342, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 22:53:15.445 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been stopped.
2017-02-12 22:53:15.445 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STOPPED - org.openhab.binding.mqtt
2017-02-12 22:53:15.446 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTING - org.openhab.binding.mqtt
2017-02-12 22:53:15.447 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2017-02-12 22:53:15.447 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTED - org.openhab.binding.mqtt
2017-02-12 22:53:15.454 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/*, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=205, service.id=345, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 22:53:15.457 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=206, service.id=346, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 22:53:15.458 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=204, service.id=348, service.bundleid=195, service.scope=bundle} - org.openhab.binding.mqtt