REST API and Server-sent events

I am playing around with an application (written in Python and using the requests and sseclient modules) that is intended to monitor some items in my openHAB setup.

For test-purposes I have created a Switch item that I am monitoring, and I have created two clients that monitor this item: one that is using SSE and one that is simply continuously polling the REST API.

What I am seeing is confusing me a bit:

The polling client reports any change to the Switch state correctly, but the SSE client is sort of “one state behind”.

By this I mean that at the first flip off the switch (OFF to ON) nothing is reported. At the next flip of the switch (ON to OFF), the SSE client reports Switch state = ON, next flip reports OFF; etc. i.e. it seems to be reporting the previous state.


Anyone seeing something similar, or have a good (or at least fairly good) suggestion for why I am seeing this behavior?