Getting plain XMPP working with OpenHAB2

Perhaps I am a bit thick, but I have been reading the documentation for the xmppclient binding (which seems a bit sparse, at least to me) and I cannot seem to get it working.

I have put the following into conf/things/default.things:

Bridge xmppclient:xmppBridge:xmpp "XMPP Client" [ username="openhab", domain="example.com", password="mypassword" ] {
    Channels:
        Trigger String : xmpp_command
}

Do I need to set up anything else (channels, actions, etc.?)

I made the following rule:

rule "send_XMPP_on_front_door_open"
when
    Item mysensors_door_7830485_tripped changed from CLOSED to OPEN
then
    actions.publishXMPP("notification_address@example.com","Front door opened.")
end

I am looking at the logs in the console, and it looks like the rule did fire, but then it gives this error:

10:39:08.574 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'send_XMPP_on_front_door_open': An error occurred during the script execution: index=0, size=0

I tried to get more logs out of xmppclient by doing the following:

log:set DEBUG org.openhab.binding.xmppclient

but that did not seem to help.

Perhaps I need to enable more logging from the rule engine?

I have searched and searched, even read the sources and asked in IRC, all to no avail, and I’m starting to get frustrated. :frowning: So I figure it’s time to wave the white flag (temporarily) and ask for help, in the hopes that some kind soul might be able to point me in some productive direction… :smiley:

I had to restart the openhab2.service (while working on something else) and as soon as I could get into the console, I did another log:tail and caught the following:

14:09:38.449 [WARN ] [org.jivesoftware.smack.XMPPConnection] - Connection closed with error
java.lang.IllegalStateException: TLS required by server but not allowed by connection configuration
	at org.jivesoftware.smack.tcp.XMPPTCPConnection.startTLSReceived(XMPPTCPConnection.java:561) [202:org.openhab.action.xmpp:1.13.0]
	at org.jivesoftware.smack.tcp.PacketReader.parseFeatures(PacketReader.java:363) [202:org.openhab.action.xmpp:1.13.0]
	at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:229) [202:org.openhab.action.xmpp:1.13.0]
	at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47) [202:org.openhab.action.xmpp:1.13.0]
	at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81) [202:org.openhab.action.xmpp:1.13.0]
14:09:39.170 [ERROR] [nhab.action.xmpp.internal.XMPPConnect] - Could not establish connection to XMPP server 'example.com:5222': No non-anonymous SASL authentication mechanism available

So, I am looking into that now…

No, it looks like it only has an Action for publishing and a trigger Channel for receiving messages. You don’t need to create any other Channels or Items to use this Binding, just Rules.

You are missing the import of the actions, like demonstrated in the example in the docs.

val actions = getActions("xmpp","xmppclient:xmppBridge:xmpp")
1 Like

Thank you so much @rlkoshak for taking the time to reply!

You know, at some point I was looking at that, and was going to add that in, but didn’t…

I have a tendency to just skip over things I don’t understand, lol, but right now I am feeling quite foolish!

OK, so after correcting that, and actuating the sensor again, the rule fires but now when it does I get:

14:34:27.263 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'send_XMPP_on_front_door_open': 'publishXMPP' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'; line 6, column 5, length 60

Furthermore, in between those messages, I also received (in log:tail, in console):

14:39:39.126 [WARN ] [.jivesoftware.smackx.ping.PingManager] - ServerPingTask: XMPPConnection was not authenticated

So I think we have made progress, but looks like I need to solve the auth issue…

It might be the case that it is failing to create the Thing because of the auth issue so I suspect this error will go away when you get that working.

Searching internet for “OpenHAB TLS” lead me to this post which gave me the idea to look into conf/services/ where I found xmpp.cfg, and then the relevant bit:

# The Security mode used for the XMPP connection. Can be either 'required'
# or 'disabled'. Defaults to 'disabled', which means that TLS will not be used.
# Warning: If you change this to non-disabled, then you must make sure that your
# TLS server certificate can be validated, otherwhise the connection will fail.
securitymode=disabled

# The TLS Pin used to verify the XMPP service's certificate. Set this in case openhab's
# default SSLContext is unable to verfiy it (e.g. because the XMPP service uses a self-signed
# certificate). The PIN value is bascially the hash of the certificate in hex.
# You have to set 'xmpp:securitymode' to 'required' to enable TLS for XMPP connections.
# For information on how to generate the PIN visit https://github.com/Flowdalic/java-pinning
#tlspin=CERTSHA256:(bunch of numbers and letters)

Which all sounds vaguely familiar for some reason.

Anyway, I’ll get working on it, and then post back (hopefully) a solution. Thanks again @rlkoshak, some times all it needs is a fresh pair of eyes! :smiley:

You should be able to set that config value in PaperUI. But if not, you can enable it by editing that cfg file, no problem. Getting a valid certificate is far beyond my experience.

1 Like

I have never had PaperUI even show up for the xmppclient binding, I have made all my configuration changes either in the .things file, or recently in this xmpp.cfg file. I had just assumed it wasn’t supported. Or maybe this is another data point towards a solution?

I changed securitymode=required in xmpp.cfg and made sure my certificates were renewed using certbot (I run my own XMPP server (Prosody); on the same machine in fact). Anyway, upon restarting service I was still getting:

15:47:11.536 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'send_XMPP_on_front_door_open': 'publishXMPP' is not a member of 'org.eclipse.smarthome.core.thing.binding.ThingActions'; line 6, column 5, length 60

I also saw some other java errors, so I decided just to reboot the whole machine just to be sure, but when it came back up, I am still getting the same error. :confused:

Currently researching that error…

Again, I greatly appreciate your efforts, Rich! :smiley:

@rlkoshak,

Yeah man… I dunno…

I been searching and reading about that error, double and triple checking configs, etc. but I’m still coming up empty handed. :frowning:

The thought had crossed my mind to lodge an issue in openhab-plugins repository, but I’m not so sure I’m not just simply doing something incorrect with my setup.

I have read a few threads where I was able to gather that people had this working, so I dunno…

I got it working, finally.

Something that @miningpenguin said to me in IRC got me thinking:

18:34 @miningpenguin I haven't used xmpp so I'm not sure if it would want to have the 'xmmp action' binding too
18:35 TRS-80 miningpenguin: that's what I'm referring to, the xmpp action (same thing)
18:36 @miningpenguin there action and there's xmppclient

I had been following these xmppclient instructions when what I had installed was the XMPP Action (from PaperUI -> Add-ons -> Actions -> XMPP Action (action-xmpp - 1.13.0)).

Anyway, so when I started doing those instructions (mainly sendXMPP instead of publishXMPP) it started working right away. :confused:

So, I feel a little dumb :frowning: but at least it’s working now which makes me very happy :smiley:! This is very important functionality for us!

I guess part of my confusion stemmed from installing latest OpenHAB2 from stable recently, and expecting that the addons would be coming from openhab2-addons but I guess that’s not correct and there are still quite a few showing as version 1.13 (even on a brand new installation)!

Another (actually, perhaps the main) thing adding to my confusion, when you click on the little square arrow link icon in upper right of XMPP Action from PaperUI, it takes you to the xmppclient page! No wonder I was mixing them up!

So, one final question I guess… How to install XMPPClient? Because I would really like to send messages to my OpenHAB instance, as well as receiving notifications from it, and it looks to me like only XMPPClient does that…

There are quite a few 1.x bindings that do not yet have 2.x versions yet, including some very important ones like HTTP. There are also many users who refused to upgrade to the 2.x version for various reasons.

If you have “Show legacy 1.x …” Disabled, than you won’t see any 1.x binding in the list of there is a 2.x version. But I’m not sure that’s true for Actions though. Slowly, all of the Actions are being replaced with bindings and eventually that category will likely go away.

That is worth filling an issue, probably on the openhab-uis repo.

Install the xmpp binding instead of the action. You will find it in the binding tab in paper UI.

I was just starting to fill out an issue on this, and went to my PaperUI to double check, and now that link points to XMPP Action page like it is supposed to. I swear I’m not crazy! lol I’m pretty sure that’s not the behavior I experienced yesterday…

One would think that, and I did, but I have looked again and again and it’s simply not there. I only have the XMPP under Actions, no Binding. Perhaps that is worth filing an issue?

Last night I was messing around with addons.cfg and looking at the repos and differences in packages between v1 and v2 because I couldn’t figure out how to install XMPPClient, but maybe all of that was over thinking it.

What version of OH are you running. It’s possible (likely even) that it’s only available in a recent snapshot.

dpkg-query -l openhab2 shows 2.4.0-1

I installed recently from scratch using stable branch of OpenHAB Debian repo. Worth noting perhaps is that this particular box is still on Jessie, beacuse reasons.

Should I move to testing?

See post right above this one.