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

See here:

1 Like

So you mean to capture the MQTT message in a string item and then run a rule to extract the values?

I would be interested in what folder and file the paperui stores the settings.

in the userdata folder:
/srv/openhab2-userdata/jsondb (for openHABian)
OR
/var/lib/openhab2/jsondb

1 Like

@matzR I’m using the following to “bridge” between my phone sending Owntracks data via MQTT and the new GPSTracker binding:

val String gpsLoggerUrl = 'http://127.0.0.1:8080/gpstracker/owntracks'
val String json = (Mobile_Owntracks.state as StringType).toString
sendHttpPostRequest(gpsLoggerUrl, "application/json", json)

The Mobile_Owntracks item is bound to my phone’s MQTT topic using the 2.4 binding.

yes there they are, thank you very much:grinning:

Did you found a solution?

No,
This is solvable with a JS transform

I’ve got the same error as this. I tried defining the actions above the rule and in the rule with the same result. I have my broker defined in a file and works fine receiving messages.

Bridge mqtt:broker:synology [ host="192.168.0.12",secure=false ]
{
    Thing mqtt:topic:alarm {
    Channels:
	    Type string : alarmstaterequest "Alarm State" [stateTopic="home/alarm/set", allowedStates="DISARM,ARM_HOME,ARM_AWAY"] 
    }
}

And this is my current rule:

import java.util.concurrent.locks.ReentrantLock

val ReentrantLock lock  = new ReentrantLock()
val actions = getActions("mqtt", "mqtt:broker:synology")

rule "Alarm Panel Action Received"
when
    Item alarmpanelRequest changed
then	
	lock.lock()
    try {
	
		switch(alarmpanelRequest.state.toString) {
			case "DISARM": {
				OhAlarmState.postUpdate("disarmed")
				actions.publishMQTT("home/alarm","disarmed")
				sendPushoverMessage(pushoverBuilder("Disarm").withTitle("Alarm Panel").withSound("falling"))
			}
			case "ARM_HOME": {
				OhAlarmState.postUpdate("home")				
				sendPushoverMessage(pushoverBuilder("Arm").withTitle("Alarm Panel").withSound("falling"))
				actions.publishMQTT("home/alarm","armed_home")
			}
			case "ARM_AWAY": {
				OhAlarmState.postUpdate("armed")
				actions.publishMQTT("home/alarm","armed_away")
				sendPushoverMessage(pushoverBuilder("Arm").withTitle("Alarm Panel").withSound("falling"))
			}
		}		
		
    } catch(Exception e) {
		logError("Error", "Alarm Panel Action Received: " + e.getMessage)
	} finally{
        lock.unlock()
    }
    
end

The actions.publishMQTT failes with
[ERROR] [eclipse.smarthome.model.script.Error] - Alarm Panel Action Received: Instance is not an MQTTActions class.

It works for this guy:

Why are you using a lock?