Skip to content

Commit aec431d

Browse files
authored
Add WebSocket topic filter docs (openhab#2465)
* Add WebSocket topic filter docs Refs openhab/openhab-core#4550. Signed-off-by: Florian Hotze <[email protected]> * Minor rewording Signed-off-by: Florian Hotze <[email protected]> --------- Signed-off-by: Florian Hotze <[email protected]>
1 parent fa609cb commit aec431d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

configuration/websocket.md

+38
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,43 @@ A new filter message always overrides the settings before.
119119
The default setting is no filter, i.e. all events from all sources.
120120
It is recommended to at least set a source filter for the client itself to prevent event reflection.
121121

122+
#### Filter by topic (`openhab/websocket/filter/topic`)
123+
124+
Topic filters can be used to include and/or exclude events of a specific topic from the event stream.
125+
They can be applied both inclusive and exclusive, and provide API compatibility with the existing topic filter functionality of the SSE event stream.
126+
127+
Topics usually start with `openhab` and are split into several segments separated by an `/`, e.g. `openhab/items/MyItem/command` to listen to commands to `MyItem`.
128+
You may use `*` as a wildcard for a topic segment.
129+
To exclude a topic, start it with a `!`.
130+
131+
When sending only exclude topics, all events except those excluded are sent.
132+
In other cases, only events of the selected topics are sent, whereas exclude topics can be used to filter out a subset of the selected events.
133+
134+
The payload of the event contains a list of string with the topics:
135+
136+
```json
137+
{
138+
"type": "WebSocketEvent",
139+
"topic": "openhab/websocket/filter/topic",
140+
"payload": "[\"openhab/items/*/command\", \"!openhab/items/MyItem/command\"]",
141+
"source": "WebSocketTestInstance",
142+
"eventId": "10"
143+
}
144+
```
145+
146+
This example will only send `ItemCommandEvents` for all Items except `MyItem`.
147+
148+
The reception is acknowledged with the filter that is applied:
149+
150+
```json
151+
{
152+
"type": "WebSocketEvent",
153+
"topic": "openhab/websocket/filter/topic",
154+
"payload": "[\"openhab/items/*/command\", \"!openhab/items/MyItem/command\"]",
155+
"eventId": "10"
156+
}
157+
```
158+
122159
#### Filter by source (`openhab/websocket/filter/source`)
123160

124161
Source filters can be used to remove events from a specific source from the event stream.
@@ -152,6 +189,7 @@ The reception is acknowledged with the filter that is applied:
152189

153190
Type filters are used to select a specific sub-set of all available events.
154191
They are a inclusive, that means only those event types sent in the filter message are sent.
192+
155193
The payload of the event contains a list of strings with the event names:
156194

157195
```json

0 commit comments

Comments
 (0)