Skip to content

XMPPClient Binding ​

The XMPPClient binding provides support for sending and receiving XMPP (Jabber) messages.

Supported Things ​

  • xmppBridge — XMPP (Jabber) client bridge that can send and receive messages. You can add publish trigger channels to it.

Thing Configuration ​

Sample configurations:

dsl
Bridge xmppclient:xmppBridge:xmpp "XMPP Client" [ username="openhab", domain="example.com", password="********" ] {
    Channels:
        Trigger String : xmpp_command [ separator="##" ]
}
dsl
Bridge xmppclient:xmppBridge:xmpp "XMPP Client" [ host="xmpp.example.com", port=7222, username="openhab", domain="example.com", password="********" ] {
    Channels:
        Trigger String : xmpp_command [ separator="##" ]
}

xmppBridge parameters:

NameLabelDescriptionRequiredDefault value
usernameUsernameThe XMPP username (left part of JID)true-
domainDomainThe XMPP domain name (right part of JID)true-
passwordPasswordThe XMPP user passwordtrue-
hostServer Hostname/IPThe IP address or hostname of the XMPP serverfalseas "domain" parameter
portXMPP Server PortPort for the XMPP serverfalse5222
securityModeSecurity ModeSets the TLS security mode: required, ifpossible or disabledfalserequired

Channels ​

You can add publishTrigger channels to the bridge to react to incoming messages.

publishTrigger parameters:

NameLabelDescriptionRequired
payloadPayload conditionAn optional condition on the valuefalse
separatorSeparator characterThe trigger payload usually contains only the received text. If you define a separator character (e.g., #), the sender UID and received text will both be included in the payload. For example: pavel@example.com#My Message Textfalse

Example Rules ​

Send message:

rules
rule "Leak detected"
when
    Item Xi_Leak changed
then
    if(Xi_Leak.state == ON) {
        val actions = getActions("xmppclient","xmppclient:xmppBridge:xmpp")
        actions.publishXMPP("pavel@example.com","Warning! Leak detected!")
    }
end

Receive and process message:

rules
rule "Turn off all lights without separator"
when
    Channel "xmppclient:xmppBridge:xmpp:xmpp_command" triggered
then
    var actionName = receivedEvent
    if(actionName.toLowerCase() == "turn off lights") {
        Group_Light_Home_All.sendCommand(OFF)
    }
end

rule "Turn off all lights with separator and reply"
when
    Channel "xmppclient:xmppBridge:xmpp:xmpp_command" triggered
then
    var actionName = receivedEvent.split("##")
    if(actionName.get(1).toLowerCase() == "turn off lights") {
        Group_Light_Home_All.sendCommand(OFF)

        val actions = getActions("xmppclient","xmppclient:xmppBridge:xmpp")
        actions.publishXMPP(actionName.get(0),"All lights were turned off")
    }
end