Skip to content

Commit

Permalink
Fix parsing of SSE topic for groups (openhab#3503)
Browse files Browse the repository at this point in the history
There can be an optional group in the topic path.

Signed-off-by: mueller-ma <[email protected]>
  • Loading branch information
mueller-ma authored Oct 22, 2023
1 parent cea5348 commit 71ffcb9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ class ItemsControlsProviderService : ControlsProviderService() {
}
val topic = event.getString("topic")
val topicPath = topic.split('/')
if (topicPath.size != 4) {
/* Possible formats:
* - openhab/items/<item>/statechanged
* - openhab/items/<group item>/<item>/statechanged
* When an update for a group is sent, there's also one for the individual item.
* Therefore always take the element on index two.
*/
if (topicPath.size !in intArrayOf(4, 5)) {
throw JSONException("Unexpected topic path $topic")
}
val item = allItems[topicPath[2]]
Expand Down

0 comments on commit 71ffcb9

Please sign in to comment.