[SOLVED] Please help me configuring Sonoff Basic with MQTT (Mosquitto) and openHAB [Solved]

i have started running openhab2 on a raspberry PI
installed mosquito and and MQTT MQTTlens i am trying to get my sonoof basic working with a switch in hab panel can see the relay switching in lens when i pust the button but wont switch from panel have installed the latest tasmota firmware on it

is there a step by step guide for beginners that i can have a look at ? the documentation gets a bit confusing at times

only warnings i get from log are

2018-12-10 16:01:29.096 [thome.event.ExtensionEvent] - Extension ‘persistence-mqtt’ has been installed.

2018-12-10 16:01:41.653 [thome.event.ExtensionEvent] - Extension ‘action-mqtt’ has been uninstalled.

2018-12-10 16:01:49.198 [thome.event.ExtensionEvent] - Extension ‘action-mqtt’ has been installed.

2018-12-10 16:05:52.416 [thome.event.ExtensionEvent] - Extension ‘misc-mqttbroker’ has been installed.

2018-12-10 16:19:11.561 [thome.event.ExtensionEvent] - Extension ‘misc-mqttbroker’ has been uninstalled.

2018-12-11 13:44:32.969 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-12-11 13:44:32.976 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘broker’

2018-12-11 13:44:33.647 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:broker

2018-12-11 13:44:33.652 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:topic

2018-12-11 13:44:33.655 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:message

any help would be appreciated

Please read the following and povide some more Information.
On First sight, it seems that you have installed Mosquitto and openHAB’s internal MQTT Broker…
So running two Brokers on the same machine, why ?

Did you installed MQTTBinding, not MQTT persistence binding?

i have both the MQTTBinding MQTT persistence and MQTT actions installed from paperUI and am sure i installed mosquito from SSH
looks like i may need to redo the image and start again as got a bit lost when following various guides and all show different ways of doing this

Uninstall everything but the mqtt binding and the broker. Post your items and mqtt,cfg file so it can be checked.

i have installed the broker from putty is that going to be ok ?
MQTT

broker.url=tcp://localhost:1883

Item

Switch Bedroom_Light "Bedroom Room Light" (LR,gLight) { mqtt=">[broker:cmnd/sonoff1-7547/POWER:command:*:default], <[broker:stat/sonoff1-7547/POWER:state:default]" } Number Bedroom_Light_RSSI "Bedroom Room Light: RSSI [%d %%]" (gRSSI) { mqtt="<[broker:tele/sonoff1-7547/STATE:state:JSONPATH($.Wifi.RSSI)]" }

and dose this one need to go as well ?

JSONPath Transformatio?

That part is ok.

Is this the only part of the file that’s been changed? You may need to add more for authentication like below.

# Optional. User id to authenticate with the broker.
broker.user=add a user name here and in tasmota 

# Optional. Password to authenticate with the broker.
broker.pwd=XXXXXXX

You can also try changing the localhost to the IP address if your OH server, e.g. //10.0.1.3:8080 or whatever your address is.

Switch Bedroom_Light "Bedroom Room Light" (LR,gLight) { mqtt=">[broker:cmnd/sonoff1-7547/POWER:command:*:default], <[broker:stat/sonoff1-7547/POWER:state:default]" } 
Number Bedroom_Light_RSSI "Bedroom Room Light: RSSI [%d %%]" (gRSSI) { mqtt="<[broker:tele/sonoff1-7547/STATE:state:JSONPATH($.Wifi.RSSI)]" } 

The item file looks good.

Make sure you’ve installed the transformation service via PaperUI and yes you’ll need this.

With the changes above what do you see in the logs, any relevant error messages?

changes made

broker.url=tcp://192.168.1.144:1883 broker.user=stu broker.pwd=stu 2018-12-11 16:15:20.807 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-12-11 16:15:20.811 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘broker’

2018-12-11 16:15:20.863 [ERROR] [org.apache.felix.configadmin ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=316, bundle=214/mvn:org.openhab.action/org.openhab.action.mqtt/1.12.0]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.12.0

Did you uninstall the mqtt action binding? If not, please do so as you do not need the action binding.

You will also need to create a sitemap file and add your mqtt items, then use BasicUI to control the light.

Example:

home.sitemap

sitemap home label="Your-SmartHouse"
{
Frame label="Bedroom Light"
	{
		Switch item=Bedroom_Light
		Text item=Bedroom_Light_RSSI label="RSSI [%d]" 
	}
}

everything but JSONPath Transformation uninstalled

can see the switch switching in MQTTlens

site map changes to as above but no action on sonoff when used and no data about signal

018-12-11 16:52:05.559 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command OFF

2018-12-11 16:52:05.575 [vent.ItemStateChangedEvent] - Bedroom_Light changed from ON to OFF

2018-12-11 16:52:06.348 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command ON

2018-12-11 16:52:06.360 [vent.ItemStateChangedEvent] - Bedroom_Light changed from OFF to ON

2018-12-11 16:52:07.093 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command OFF

2018-12-11 16:52:07.116 [vent.ItemStateChangedEvent] - Bedroom_Light changed from ON to OFF

2018-12-11 16:52:07.786 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command ON

2018-12-11 16:52:07.799 [vent.ItemStateChangedEvent] - Bedroom_Light changed from OFF to ON

You need the mqtt binding, found in PaperUI under Add-ons > Bindings > MQTT

Have you added the authentication info, user id and password you added to the mqtt.cfg, to the sonoff?

re-installed but still not working would like to thank you for your help so far

2018-12-11 17:03:29.330 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-12-11 17:03:29.339 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘broker’

==> /var/log/openhab2/events.log <==

2018-12-11 17:03:29.623 [thome.event.ExtensionEvent] - Extension ‘binding-mqtt1’ has been installed.

==> /var/log/openhab2/openhab.log <==

2018-12-11 17:03:59.633 [WARN ] [sitemap.internal.SitemapProviderImpl] - Filename Home.sitemap does not match the name home of the sitemap - please fix this as you might see unexpected behavior otherwise.

==> /var/log/openhab2/events.log <==

2018-12-11 17:04:01.043 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command OFF

2018-12-11 17:04:01.083 [vent.ItemStateChangedEvent] - Bedroom_Light changed from ON to OFF

2018-12-11 17:04:01.675 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command ON

2018-12-11 17:04:01.700 [vent.ItemStateChangedEvent] - Bedroom_Light changed from OFF to ON

2018-12-11 17:04:02.629 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command OFF

2018-12-11 17:04:02.645 [vent.ItemStateChangedEvent] - Bedroom_Light changed from ON to OFF

2018-12-11 17:04:03.135 [ome.event.ItemCommandEvent] - Item ‘Bedroom_Light’ received command ON

2018-12-11 17:04:03.153 [vent.ItemStateChangedEvent] - Bedroom_Light changed from OFF to ON

Need to change the file name to match the site map name. In your case change Home.sitemap to home.sitemap.

If it’s still not working, check the config on the sonoff and make sure you’ve added the auth info to match what’s in the mqtt.cfg

Example of tasmota sonoff MQTT config

For Host enter the IP of your OH server, 192.168.1.144

Port should be the default 1883.

You can leave the Client as is for now.

User is where you’ll inter the user name to match the mqtt.cfg, stu in your case

Password enter what you have in the mqtt.cfg, looks like stu again

Topic will be sonoff1-7547

You can leave full topic as is for now.

Will have a check in the morning as had to go to work but lens was still seeing messages after i had changed configuration in sonoff will post screen shots tomorrow thanks

Got it thanks was the topic name simple mistake lol i read it from MQTTlens and used that
Thanks you for all the help :slight_smile:

Glad you have it working.:+1:

Please mark as solved by clicking the square box (lower right corner) on the post that provided the solution and edit the title to start with [Solved].

Thanks