[CLOSED] MQTT binding version 2.4 (Pre-release !)

Thanks!

There’s another thing I’m struggling with: I understand with the postUpdate option I can determine if a state update should be interpreted as a command or just a state.
But on the outbound side - is there any way to also publish state updates of items, not just commands?
At the moment I use a rule like this as a workaround:

rule "MQTT Post State Updtes"
  when
    Member of gSomeGroup changed
  then
    triggeringItem.sendCommand(triggeringItem.state.toString)
end

Im experiencing the same issue as @911rgt and @bern77. After a while (already after 4 hours last night) it stopped working and I started receiving:

2018-12-26 04:41:33.746 [WARN ] [home.binding.mqtt.action.MQTTActions] - MQTT publish to openHAB/topic failed!

After restarting OpenHAB it starts working again for a few hours.

I’m giving up - I’ll revert back to the mqtt1 Binding for the time being.
For a small installation the 2.4 Binding might be working fine, but in my case I’m just amassing workarounds and still the functionality is not as stable as that of the mqtt1 Binding.
I really appreciate the migration to the openhab2 architecture, but I’m afraid for me the binding is not yet usable.

This action part is apparently not working stable. It has nothing to do with the mqtt binding by the way. This is how all actions in the future are going to be called.

So please open bug reports if that is not working stable enough otherwise openHAB will be really broken when other actions are auto migrated at some point.

Does the new MQTT binding support Persistence?

with the previous version I did something like this:

mqtt-persistence:

broker=solace
# The MQTT topic to which the persistence messages should be sent.
topic=moosecabin/homeautomation/persistence
# A string representing the persistence message content.
message=%1$s, %3$s

mqtt.persist

Strategies {
        everyHour : "5 * * * * ?"
        default = everyChange
}
Items {
        // persist all items every hour and on every change
        * : strategy = everyChange, everyHour, every5Minutes
}

No, this only works with the MQTTv1 Binding

MQTT persistence is, in fact, an independent addon :wink:

1 Like

I also used the event bus heavily. People use OpenHab for different use-cases; I use it as a device/mqtt bridge for integration into another (homegrown) system. Event bus was awesome and allowed easy integration. The new binding is much much less friendly to this kind of use-case, particularly in terms of work required.

It would be really nice to see something like event bus come back, where I don’t have to do so much [error-prone] work to devices to MQTT. I know I can still use the v1 binding, but the need to use that points to a missing use-case.

I’ve encountered an issue with the binding and rules.
When I want to publish a message to my configured broker I get the following error in the log:

21:55:16.630 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'myRule': Instance is not an MQTTActions class.

My rule is the following:

rule "myRule"
when
    Item myItem received command
then

    val actions=getActions("mqtt","mqtt:broker:myBroker")
    switch(receivedCommand){
        case 0: {
            actions.publishMQTT("Topic/Payload/Status1","TRUE")
            createTimer(now.plusMillis(500))[actions.publishMQTT("Topic/Payload/Status1","FALSE")]
        }
        case 1: {
            actions.publishMQTT("Topic/Payload/Status2","TRUE")
            createTimer(now.plusMillis(500))[actions.publishMQTT("Topic/Payload/Status2","FALSE")]
        }
    }
end

However, when I add the same broker twice in PaperUI, this time with a different name and ID (ID is autogenerated now) It works and messages are beeing published via the rule, even without making use of this ‘dummy’ broker. When I remove the ‘dummy’ broker again, it stops working.

In addition, message published directly via Items do work all the time.

Move the val actions=... to the top of the rules file
The timer lambda needs a global variable

val actions=getActions("mqtt","mqtt:broker:myBroker")

rule "myRule"
when
    Item myItem received command
then
    switch(receivedCommand){
        case 0: {
            actions.publishMQTT("Topic/Payload/Status1","TRUE")
            createTimer(now.plusMillis(500))[actions.publishMQTT("Topic/Payload/Status1","FALSE")]
        }
        case 1: {
            actions.publishMQTT("Topic/Payload/Status2","TRUE")
            createTimer(now.plusMillis(500))[actions.publishMQTT("Topic/Payload/Status2","FALSE")]
        }
    }
end

That seems to have done the trick.
Strange thing is that with a dummy broker, it does work ??

Yep, strange

Another problem I’ve encountered is the following:

Via PaperUI I have configured a channel as a contact.
The payload of the message is either TRUE or FALSE (string value).
In the options of the channel the ‘On/Open value’ is set to TRUE, the ‘Off/Closed value’ to FALSE.
When the message is received by OpenHAB, the log outputs the following:

23:17:35.842 [WARN ] [generic.internal.generic.ChannelState] - Command 'FALSE' not supported by type 'OpenCloseValue': No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.FALSE

What could be the issue here?

I had the same problem, upgrading to the latest openhab release solved it.

Which release are you on?

2.4

same here…

 openhab> bundle:list | grep MQTT
225 x Active   x  80 x 1.2.0                  x Paho MQTT Client
226 x Active   x  80 x 0.10.0.oh240           x Eclipse SmartHome MQTT Binding
227 x Active   x  80 x 0.10.0.oh240           x Eclipse SmartHome MQTT Thing Binding
228 x Active   x  80 x 0.10.0.oh240           x Eclipse SmartHome MQTT Transport Bundle
openhab> bundle:list -s| grep openhab
180 x Active   x  90 x 2.4.0                  x org.openhab.core
181 x Active   x  80 x 2.4.0                  x org.openhab.core.karaf
183 x Resolved x  80 x 2.4.0                  x org.openhab.io.sound
184 x Active   x  80 x 2.4.0                  x org.openhab.ui.dashboard
194 x Resolved x  75 x 2.4.0                  x org.openhab.ui.basicui
195 x Active   x  80 x 2.4.0                  x org.openhab.ui.habpanel
196 x Active   x  80 x 2.4.0                  x org.openhab.ui.homebuilder
197 x Resolved x  75 x 2.4.0                  x org.openhab.ui.paperui
207 x Active   x  80 x 1.13.0                 x org.openhab.binding.wol
208 x Active   x  80 x 2.4.0                  x org.openhab.core.compat1x
209 x Active   x  80 x 2.4.0                  x org.openhab.binding.network
210 x Active   x  80 x 2.4.0                  x org.openhab.binding.lgwebos
211 x Active   x  80 x 2.4.0                  x org.openhab.binding.exec
212 x Active   x  80 x 2.4.0                  x org.openhab.binding.chromecast

Try deleting and re-added the thing

Problem remains when creating a new Thing.
Strange thing though: when changing from UNDEF to OPEN it works, but after that… nothing. It remains open forever.