MQTT persistence worked in 2.0.0 snapshot but not 2.1.0 release

(bri) #1

Hi I haven’t updated in a long time, but I was running one of the 2.0.0 snapshot builds. Since then I have upgraded to 2.1.0 release (not nightly) and my states have stopped publishing to mqtt. Here is my config:


$cat mqtt.cfg 
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.

# Optional. User id to authenticate with the broker.

# Optional. Password to authenticate with the broker.

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>
$cat mqtt-persistence.cfg 
# Name of the broker as defined in mqtt.cfg

# The MQTT topic to which the persistence messages should be sent.

# A string representing the persistence message content.


$cat mqtt.persist 
Strategies {
        default = everyChange
Items {
        // persist all items every hour and on every change
        * : strategy = everyChange

I am just trying to publish everything to that ohab topic.

Any help is greatly appreciated


(bri) #2

I can switch back to the 2.0.0 snapshot and it works with those same files. Am I missing something I should configure in the 2.1.0 release? Any suggestions greatly appreciated. I just want to send mqtt messages on any state change. Is there some other way?

(Angelos) #3

If you are interested to publish all item states from openHAB2 to the MQTT Broker, you could use the MQTT-EventBus solution:

  • Setup your broker connection with the $OPENHAB_CONF/services/mqtt.cfg
    ($OPENHAB_CONF = /opt/openhab/conf in your case)
  • Define within $OPENHAB_CONF/services/mqtt-eventbus.cfg your publishing settings
    (and optionally, your subscribing):

This will send the state of every $item to a separate topic. Keep in mind that this is a massive link. It will “connect” the entire Event Bus of openHAB2 to the Broker.

For persistence, I recommend using a 2-tier solution as @rlkoshak wrote here: Good Tutorial On Persistence (RRD4J and JDBC-MYSQL)?.

  • mapdb for everyChange & restoreOnStartup (set as the default persistence service)
  • Influxdb for everyChange to be used with Grafana
  • Optionally, a 3rd tier with MySQL would be nice also but heavy :slight_smile:

MQTT persistence doesn’t really store historical data. It’s only used for publishing states of selected items to the broker.
It has the advantage of fine tuning the mqtt.persist to define a strategy of what to “persist” (put the items for which you want to publish the state in a group, then persist the group members)

MQTT Setup - File not found
(bri) #4

Thank you so much @Dim ! I will try this after the holiday weekend. That looks like it would do exactly what I want. I currently use openhab as a zwave gateway/bridge so I don’t have really any other state changes other than the zwave stuff which I track all that.

Thanks Again