- Platform information:
- Hardware: Intel NUC i3 16Gb RAM 500Gb SSD
- OS: Ubuntu 20.04LTS
- Java Runtime Environment: Zulu JRE11
- openHAB version:3.1.0
Issue of the topic:
I’m building a React UI which uses the REST API event streams in a CQRS manner in that the UI only ever reflects the state of the system. Commands sent from the UI only result in changes to the UI after openHAB emits an event relating to the completion of the requested command.
I receive most of the needed information from
const eventUrl="https://xxx.xxx.xxx/rest/events/states";
But in order to ensure that elements of my home system which go offline are properly displayed in the UI I am also subscribing to the status stream at
const statusUrl = 'https://xxx.xxx.xxx/rest/events?topic=smarthome/things/status'
This stream is fine for startup but once the current status of the home items has been established I would like to use a “statuschanged” stream so that I am only having to interpret a small number of events e.g. when lights get switched off at the wall or sensors are unplugged.
I have tried the following url variations to achieve what I want but with no success.
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topic=smarthome/things/*/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topic=smarthome/things/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topic=openhab/things/*/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topic=open/things/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topics=smarthome/things/*/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topics=smarthome/things/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topics=openhab/things/*/statuschanged'
const changedUrl = 'https://xxx.xxx.xxx/rest/events?topics=open/things/statuschanged'
I all cases the stream I receive seems to contain all events for state and status rather than a filtered stream.
I am clearly missing something in the url syntax.
Can anyone point me in the right direction please?
Many thanks in advance
regards
Ian Carson