MQTT Binding "forgetting values"

Hello Community,
yesterday I build my first of some NODEMCU SensorNodes, connected it to mosquitto and was enjoyed be looking at the values it send every minutes - works as designed.

I added an MQTT-Binding for the values, it looks good at all, but the values went back to “undefinded” after some seconds.

After some search I found, that keep-alive parameter and set ip to 300 seconds - seems to work, until I changed something on the Item file.

Isn’t there no way to keep MQTTvalues valid for some time?

Hi @Dennis_Wunsch,
The behavior you see is normal. It has nothing to do with the mqtt binding itself. When changing the items file all items go to default state e.g. uninitialised as openhab reloads.
I use the mqtt binding myself and never experienced that data became invalid after some time.
Br Marc

Thank you Marc :slight_smile:

I helped myselft with two items per mq-item and a rule to apply it to the second value - but this is…not good

jsut to confirm my binding:
Number mq_cur_temp “Temp [%s]” {mqtt="<[transportbroker:ESP8622/temperature:state:default]"}

can you explain the idea behind it, because I don’t understand what you are trying to do.

To feed it via a rule:
mq_cur_temp received update
cur_temp.state = mq_cur_temp.state

cur_temp will keep the value till the next update

You probably will want to look into persistance.

Hello Micael,
I installed mysql and rrd4j persistence setting in openhab, you mean I shall employ MQTT for persistency also?

The MQTT item binding posts updates to items with in bindings for state, but the binding is not responsible for keeping those states in place on those items. The states can later change if (1) you restart the openHAB server, (2) you change your item file(s), or some code posts an update. Possible code that could post an update are (3) the MQTT item binding itself, in case something publishes to the MQTT topic the item is listening to, (4) another binding that is bound to the same item, (5) rules, or (6) possibly the REST API.

(1) can be changed by using persistence. (2) can be changed by your no longer needing to edit your items file(s). (3) can be changed by suppressing the source of further MQTT publish messages. (4) and (5) can be changed by correcting your items file(s) and rules, and (6) can be fixed by correcting the external system that is using the REST API.

No he means that you should persist the item which is bound to the mqtt binding. You will need the restoreOnStartup strategy.