It’s not clear what you are after. You want to subscribe to events on Items on some external program? If so you need to subscribe to the SSE feed openHAB provides. You can find an example of that for Python discussed at Python Example of Subscribing to openHAB's SSE Feed
Note that SSE is one-way, meaning you can only subscribe not publish. If you also want to send events to OH Items you need to use the OH REST API which is thoroughly documented in the REST API Docs addon you can find to install in the UIs tab in PaperUI.
I’m programming a dashboard for myself with Angular and of course I want to display/query the current values of my different devices there.
Of course I could also query the rest service in an interval. But that is not so nice.
Tried it once with this. Chrome also shows me that the request is kept open. But somehow nothing ever gets through to me/client.
const eventSource = new EventSource("http://adress:8080/rest/events?topics=smarthome/items/RaspberryPi4_Sensors_CPUTemperature/statechanged");
eventSource.onmessage = function (eventPayload) {
var event = JSON.parse(eventPayload.data);
console.log(event);
};
It’s practically the same code, if you think of HTML without it. The same thing happens as with me. Connection is kept open but somehow I don’t get an answer.