How to subscribe to events via the Openhab 3 rest api

Does anybody know if there has been any changes to how to subscribe to an event from openhab 2.x to openhab 3.x

This is how I used to do it, but it is not working on openhab 3:
http://openhab:8080/rest/events?topics=smarthome/items/AwayFromHome/statechanged

I am not sure if it will help you, but in OH3 the Rest Api is self documenting…

http://<ip-address>:8080/#!/developer/api-explorer

Did you read the OH3 documentation? There were many changes, dine breaking changes, as indicated by the major version change.

Some REST API paths now require authentication.

If it is not worth your time to read the documentation & show effort, it is not worth our limited volunteer time to assist you.

1 Like

Thanks for your feedback!

Yes, I have been looking at the documentation at http://:8080/#!/developer/api-explorer - without finding out how to do it.

What is expected in the field “topics”? When clicking on “Try it out” and “Execute”? I just get 400 and “Topic is empty or contains invalid characters”.

Also in the openhab 3.0 documentation I find:

# ThingStatusInfoChangedEvent - The status of a thing changed.
curl "http://{openHAB_IP}:8080/rest/events?topics=smarthome/things/{thingUID}/statuschanged"

# ChannelTriggeredEvent - A channel has been triggered.
curl "http://{openHAB_IP}:8080/rest/events?topics=smarthome/channels/{channelUID}/triggered"

I can’t find an example for an item and statechange, but from what I would expect from the two examples above, it should be equal to the syntax I have been using with openhab 2.x. Still I can’t get it to work…

Perhaps @Spaceman_Spiff has ideas. I know he uses the REST API successfully in HABApp

You have to use openhab instead of smarthome:
"http://{openHAB_IP}:8080/rest/events?topics=openhab/things

3 Likes

Thanks!!

Now it works like a dream again :slightly_smiling_face: