Binding to make [additional] REST operations visible within OpenHAB?

I have the possibility to integrate SMS messages into OpenHAB2 through my VOIP provider (voip.ms). When a text comes in to my VOIP number, they (the provider) can be set up to issue an HTTP GET to a URL of my choosing like

http: //mysite.com/sms.php?to={TO}&from={FROM}&message={MESSAGE}&id={ID}&date={TIMESTAMP}

I’d like to set up OH2 to have actions happen on certain texts, so, some basic string pattern matching and some kind of connection between an HTTP server and OH2. Is there an existing binding which could be configured for this? I saw the http binding but it seems geared towards consuming external REST resources.

Not a binding but OH does provide a REST API as part of the core. I don’t think they changed it in OH 2 so what you see on the OH 1 REST documentation should work. However, authentication will be a challenge.

You might need to use something like IFTTT or a reverse proxy to avoid having to either give your credentials to your VOIP Provider (i.e. embedded in the URL) or completely disabling authentication/https on your OH instance.

I don’t think OH’s built-in API is flexible enough. Typical use case: owner leaves the house without setting the alarm. Presence detection sees that they have left and sends a text “I see you’ve left. Did you want to set the alarm?” Text back “yes” and it does.

You can easily register a servlet that can take via HTTP whatever you like.
This is e.g. already done by the hue emulation, which exposes a Philips hue compatible REST API to allow Amazon Echo and other external devices to talk to openHAB through HTTP requests.

I think that is very doable in OH rules and OH’s built in API.

But that isn’t what you originally asked.

Ignoring the Item binding config it would look something like this:

Items:

String SMS_Outgoing
String SMS_Incoming
Switch Present
Switch Alarm

Rules:

var DateTime leftMessageTime

rule "Left"
when
    Item Present changed to OFF
then
    if(Alarm.state == OFF) {
        SMS_Outgoing.sendCommand("I see you left. Did you want to set the alarm?")
        leftMessageTime = now
    }
end

rule "Received SMS"
when
    Item SMS_Incoming received update
then
    if(SMS_Incoming.state.toString.contains("Yes")){
        if(leftMessageTime.isAfter(now.minusMinutes(2)) {
            Alarm.sendCommand(ON)
        }
    }
end

It gets more complicated when you can have more and more of these sorts of interchanges but not drastically so.

This is independent from how the SMS messages are sent or received. But if you change SMS_Incoming through OH 1’s API it works just fine.

Thanks! I’m just getting started with OH2 and haven’t progressed to writing rules etc. Just figuring out how things will connect and whether they will connect. Ideally, without having to learn any Java, but we’ll see.