Sonoff Th16 Easyesp mqtt openhab2

looks good

now from the openHAB console, check the State of the 2 items:

smarthome:items list Temperature_Vaerksted
smarthome:items list Humidity_Vaerksted

What is the output?

State=NULL means that the items haven’t received any updates with values from their binding
You need to focus now on your items configuration… something is not working there…
Strange… from the configs that I have seen so far, it should have worked…

Manually publish a value to the MQTT topic that your item is bound to:
With item definition:

Number Temperature_Vaerksted "Temperatur værksted [%s %%]" <temperature> { mqtt="<[mybroker:/Sonoffth1/Temp_Vaerksted/Temperature:state:default]" }

Push a message to MQTT:

mosquitto_pub -u openhab -P habopen -t /Sonoffth1/Temp_Vaerksted/Temperature -m 99

and check again the status of the item (if it became 99) smarthome:items list Temperature_Vaerksted

here is a screndump from mqqtfx

when i use

mosquitto_pub -u openhab -P habopen -t /Sonoffth1/Temp_Vaerksted/Temperature -m 99

it stil stat=NULL

argggg :slight_smile:

Question: Have you installed the Add-on: MQTT Action?

If yes: Uninstall it, restart OH2 and check again

yes i have and now uninstalled and oh2 reboot but still state=NULL

if i publish this /Sonoffth1/Temp_Vaerksted/Temperature 96.00 from mqttfx

i get this /Sonoffth1/Temp_Vaerksted/Temperature 96.00 (null)

and the sonoff is publish this /Sonoffth1/Temp_Vaerksted/Temperature 10.40

but still state=NULL

Change the following in your /etc/openhab2/services/mqtt.cfg

mybroker.url=tcp://127.0.0.1:1883
mybroker.clientId=OH2

I replicated your setup in one of my test systems and all work fine…

item:

Number Temperature_Test "Temperature Test [%s %%]" <temperature> {mqtt="<[mybroker:/Sonoffth1/Temp_Test/Temperature:state:default]"}

sitemap:

sitemap mqtt label="MQTT Test" {
	Frame {
		Text item=Temperature_Test label="Test temperature [%s °C]" icon="temperature"
	}
}

mqtt.cfg:

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

All work fine and when I send:

mosquitto_pub -u openhab -P habopen -t /Sonoffth1/Temp_Test/Temperature -m 95

I get:

==> openhab.log <==
2017-02-13 00:12:58.389 [TRACE] [t.mqtt.internal.MqttBrokerConnection] - Received message on topic '/Sonoffth1/Temp_Test/Temperature' : 95

==> events.log <==
2017-02-13 00:12:58.438 [ItemStateChangedEvent     ] - Temperature_Test changed from NULL to 95

Try also:
delete the file /var/lib/openhab2/config/org/openhab/mqtt.config and restart OH2

1 Like

Happy happy me it is working you are my herro tanks again :slight_smile: :wink: :slight_smile: :slight_smile:

:slight_smile: :+1:
what was wrong? (maybe stale configs stored in the /var/lib/openhab2/config/org/openhab/mqtt.config file?)

1 Like

I deletet the mqqt.config file and it is working :smiley::smiley::smiley::+1::+1::+1:

1 Like

Yeah… unfortunately this happens sometimes…
This is because when you edit /etc/openhab2/services/mqtt.cfg file you may put some settings there that are kept in openHAB (and stored in /var/lib/openhab2/config/org/openhab/mqtt.config)
When you change the mqtt.cfg file and create new settings, the old ones are not removed from mqtt.config and this can cause problems…

Anyway… good luck with your next steps in developing your openHAB 2 environment :slight_smile:
I think that you know some more about MQTT now, so you could also help others when they get stuck (this is how the community grows :ballot_box_with_check:

1 Like

I think this is a major bug. :open_mouth:
Is this documented already?

4 Likes