Service for listening item updates

Hi,

I’m currently developing my own tablet/mobile UI for controlling my house. I was wondering if there is already functionality to listen to item state changes from a socket or similar, I would rather not poll the rest APIs every second.

Basically I would like to listen to events.log over network connection, primarily to be able to update the UI accordingly.
Despite being a rather quick thing to do, I would not want to write my own socket server to do this if there is a ready made solution available.

Thanks!

MQTT Event Bus

I think the web UIs use Websockets or something along those lines to get updates. But MQTT would be the more typical use and open your UI to working with other home automation products like NodeRed.

thanks, that might actually be the proper way.
I was thinking about netcat and tailing the events log to it :slight_smile:

I’m doing something very similar.

Ok, while tcpserver and tailing logs works just fine, but I think I just bumped into a more proper, but openhab specific way of getting this done.

So here is to anyone who might be poking around same ideas:

With the rest api, there is the Server Sent Events endpoint, which posts neat json objects out on bus events.
There is also a very handy java client library for that: Jersey Media Sse

Edit: After a bit of experimentation, at least on Raspberry Pi 2 the SSE broadcast is sluggish, may take up to 20s before it broadcasts changes, while tapping to the events.log is immediate