Sonoff Th16 Easyesp mqtt openhab2

Hi

i am using openhab2 and mosquitto on a raspberry pi3 and i will like some help to make the item for an Sonoff Th16
i have flash with easyesp and the setup is like this

name = Sonoffth1
protocol = openhab mqtt
locate controller = use ip address
controller ip = 192.168.0.242
Controller port = 1883
Controller user = openhab
Controller password = ***************

and i setup this

but i dont know how to make the item for temp and hum

my mqtt.cfg file is

mybroker.url=tcp://192.168.0.242:1883
mybroker.clientId=openhab
mybroker.user=openhab
mybroker.pwd=habopen
mybroker.qos=0
mybroker.retain=false
mybroker.async=true
mybroker.lwt=<last will definition>

Items:

http://docs.openhab.org/concepts/items.html

MQTT:

http://docs.openhab.org/addons/bindings/mqtt1/readme.html

Sonoff:

Hi

i have flash so it is now in espeasy but i have som problem whith the item line
i have try this, but it is not working

Number Temperature_Vaerksted "Temperatur vÌrksted [%.1f °C]" <temperature> { mqtt="<[mybroker:/openhab/Sonoffth1/Temperature:state:default]" }

I integrated a Sonoff with Sonoff-Tasmota.

It was very easy!

I think the example from that Wiki is very similar to what you need.

Tanks but i have tryed all this but jeg cant get my item line right and I cant see wher i go wrong

/openhab needs to be the name form tab “Config”, item “Name”
/Sonoffth1 needs to be the name from tab “Devices”, item “Name”
/Temperature needs to be the name from tab “Devices”, go to “Edit”, item “Value Name 1”

I try to change to this

Number Temperature_Vaerksted "Temperatur vÌrksted [%.1f °C]" <temperature> { mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]" }

but I still dont get the info from the sonoff

can i see the data from the sonoff in musquitto somehow i am new in mosquitto

Yes, use mosquitto client. Install with:

sudo apt-get install mosquitto-clients

Then the following will display all topics and data associated with them (ctrl z to end)

mosquitto_sub -h 192.168.1.78 -t '#' -v

leave out the ‘-h 192.168.1.78’ (the ip address of the broker) if it’s on the same Raspberry Pi.

To prove mosquitto is working open another terminal session and enter this and you should see ‘test/topic helloWorld’ in the other terminal window.

mosquitto_pub -t 'test/topic' -m 'helloWorld' -h 192.168.1.78

Hi

this is working fine

so what can I be do wrong in openhab ??
pls help

Repost your /etc/openhab2/services/mqtt.cfg to check it.
I saw that you reported it in the first post here and you haven’t defined the lwt. Try to remove this option and check the openHAB2 logs for MQTT messages:

mybroker.url=tcp://192.168.0.242:1883
mybroker.clientId=openhab
mybroker.user=openhab
mybroker.pwd=habopen
mybroker.qos=0
mybroker.retain=false
mybroker.async=true
mybroker.lwt=<last will definition>
Remove this line

mybroker.lwt=<last will definition>

Check the /var/log/openhab2/openhab.log for MQTT connection messages.

Your item definition looks ok:

Number Temperature_Vaerksted "Temperatur vÌrksted [%.1f °C]" <temperature> { mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]" }

here is mqtt.cfg

mybroker.url=tcp://192.168.0.242:1883
mybroker.clientId=raspberry
mybroker.user=openhab
mybroker.pwd=habopen
mybroker.qos=0
mybroker.retain=false
mybroker.async=true

Try the following:

Enter into the openHAB console

ssh openhab@localhost -p 8101

with password habopen

Increase the log level to the max for the MQTT binding:

log:set TRACE org.openhab.binding.mqtt
log:set TRACE org.openhab.io.transport.mqtt

Note: Keep this console open, since this will generate aloooot of logs. To turn them off, switch back to:

log:set DEFAULT org.openhab.binding.mqtt
log:set DEFAULT org.openhab.io.transport.mqtt

monitor the openHAB log for errors (from an ssh shell)

tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log

or from within the openHAB console (Ctrl+C to escape the tail):

log:tail

here is the log file from openhab.log

2017-02-12 21:23:05.773 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'default.items'
2017-02-12 21:23:05.820 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'Humidity_Vaerksted' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'mybroker:/Sonoffth1/Temp_Vaerksted/Humidity:state:default:state:default' is not a valid inbound configuration: Configuration requires 4 or 5 parameters separated by ':'
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:50)[199:org.openhab.core.compat1x:2.0.0.201612091712]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:312)[121:org.eclipse.smarthome.model.item:0.9.0.201612091054]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:284)[121:org.eclipse.smarthome.model.item:0.9.0.201612091054]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:167)[121:org.eclipse.smarthome.model.item:0.9.0.201612091054]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:347)[121:org.eclipse.smarthome.model.item:0.9.0.201612091054]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:207)[120:org.eclipse.smarthome.model.core:0.9.0.201612091054]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:120)[120:org.eclipse.smarthome.model.core:0.9.0.201612091054]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:270)[120:org.eclipse.smarthome.model.core:0.9.0.201612091054]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.access$1(FolderObserver.java:264)[120:org.eclipse.smarthome.model.core:0.9.0.201612091054]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver$WatchQueueReader.processWatchEvent(FolderObserver.java:145)[120:org.eclipse.smarthome.model.core:0.9.0.201612091054]
	at org.eclipse.smarthome.core.service.AbstractWatchQueueReader.run(AbstractWatchQueueReader.java:122)[96:org.eclipse.smarthome.core:0.9.0.201612091054]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]

i dont know what the openHAB console is :frowning:

Why two times the :state:default part?
Check again your item configuration

I work on the humidity jet so i haven seen this before now

so now it is

Number Temperature_Vaerksted "Temperatur vĂŚrksted [%s %%]" <temperature> { mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]" }
Number Humidity_Vaerksted "Humidity [%.1f %%]" <climate> { mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Humidity:state:default]" }

and the last log now

2017-02-12 21:33:18.379 [WARN ] [veClimateControlScheduleCommandClass] - NODE 7: Unsupported Command 8 for command class CLIMATE_CONTROL_SCHEDULE (0x46).
2017-02-12 21:33:53.517 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'default.items'
2017-02-12 21:33:53.600 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'default.items'
2017-02-12 21:34:45.197 [WARN ] [veClimateControlScheduleCommandClass] - NODE 8: Unsupported Command 8 for command class CLIMATE_CONTROL_SCHEDULE (0x46).
2017-02-12 21:35:34.599 [WARN ] [veClimateControlScheduleCommandClass] - NODE 9: Unsupported Command 8 for command class CLIMATE_CONTROL_SCHEDULE (0x46).
2017-02-12 21:35:35.453 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - NODE 9: Initialising Thing Node...
2017-02-12 21:35:35.482 [WARN ] [ding.zwave.handler.ZWaveThingHandler] - NODE 9: Initialising Thing Node...
2017-02-12 21:36:35.773 [WARN ] [veClimateControlScheduleCommandClass] - NODE 5: Unsupported Command 8 for command class CLIMATE_CONTROL_SCHEDULE (0x46).

These warnings are from Z-Wave related logs (they are fine, don’t worry :))
Check for MQTT related logs
Did you put your new items in your sitemap? Do they show now the Temp & Humidity values as they come in from the sonoff?

no ther is not temp & humidity on the sitemap from the sonoff my

sitemap code

Frame label="Thermostat" {
 Text item=Thermostat_Danfoss_Stue2 label="Thermostat Stue ved Dør [%s °C]" icon="temperature"
 Text item=Thermostat_Danfoss_Kokken label="Thermostat Køkken [%s °C]" icon="temperature" 
 Text item=Thermostat_Danfoss_Nicolai label="Thermostat Nicolai [%s °C]" icon="temperature" 
 Text item=Thermostat_Danfoss_Annebell label="Thermostat Annebell [%s °C]" icon="temperature" 
 Text item=Thermostat_Danfoss_Sovevaerelse label="Thermostat SovevÌrelse [%s °C]" icon="temperature" 
 Text item=Temprature_Multisensor_Sovevaerelse label="Temperatur SovevÌrelse [%s °C]" icon="temperature"
 Text item=Temperature_Vaerksted label="VÌrksted temperature [%s °C]" icon="temperature"
 Text item=Humidity_Vaerksted label="VĂŚrksted Humidity [%.1f %%]" icon="climate"

and pic from sitemap

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
1 Like

like this

2017-02-12 21:57:03.229 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STOPPING - org.openhab.binding.mqtt
2017-02-12 21:57:03.246 [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=253, service.id=417, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.280 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent UNREGISTERING - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=254, service.id=420, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.302 [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=255, service.id=418, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.333 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been stopped.
2017-02-12 21:57:03.335 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STOPPED - org.openhab.binding.mqtt
2017-02-12 21:57:03.340 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTING - org.openhab.binding.mqtt
2017-02-12 21:57:03.342 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2017-02-12 21:57:03.345 [DEBUG] [org.openhab.binding.mqtt            ] - BundleEvent STARTED - org.openhab.binding.mqtt
2017-02-12 21:57:03.404 [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=258, service.id=423, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.410 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2017-02-12 21:57:03.415 [TRACE] [ng.mqtt.internal.MqttEventBusBinding] - No mqtt-eventbus properties configured.
2017-02-12 21:57:03.433 [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=260, service.id=424, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.440 [DEBUG] [org.openhab.binding.mqtt            ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/*, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=259, service.id=425, service.bundleid=266, service.scope=bundle} - org.openhab.binding.mqtt
2017-02-12 21:57:03.458 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item Temperature_Vaerksted
2017-02-12 21:57:03.459 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'Temperature_Vaerksted' : 1 subscribers, 0 publishers
2017-02-12 21:57:03.460 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item Humidity_Vaerksted
2017-02-12 21:57:03.461 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'Humidity_Vaerksted' : 1 subscribers, 0 publishers
2017-02-12 21:57:03.462 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item Varme_Vaerksted
2017-02-12 21:57:03.463 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'Varme_Vaerksted' : 2 subscribers, 0 publishers