REST API status gets out of sync with actual player state

I’ve noticed an interesting behavior with the Volumio REST API. I have a home automation driver that polls the Volumio API to retrieve player state, track info, etc and use that in some automations. The status updating is done using the JSON GET response from http://volumio.local/api/v1/getState.

The issue is that sometimes the “status” field returned by the GET doesn’t update to reflect the actual state of the player. I can induce this by playing any track (source doesn’t seem to matter), then pressing pause on the Volumio web interface or android app, waiting a few seconds, then pressing play again. The API will initially return status: “play”, then change to status: “pause” when the track is paused, but it will keep reporting status: “pause” when the track is resumed, and doesn’t change even if I play a different track.

Using the API to send a “play” command also produces the same behavior, but if I send a second “play” command (after Volumio has already started playing), the API will then report status: “play” correctly. The play/pause/stop commands themselves work as expected. It’s only the response from the API that gets out of sync. Using a web browser to monitor http://volumio.local/api/v1/getState produces the same behavior.

I submitted a bug report here → http://logs.volumio.org/volumio/G6dSJl5.html
The events below out of the log appear to show the disconnect occurring.

Jul 02 00:07:08 office volumio[719]: info: CoreStateMachine::syncState   stateService pause
Jul 02 00:07:08 office volumio[719]: info: CoreStateMachine::syncState   currentStatus pause

Jul 02 00:07:10 office volumio[719]: info: CoreStateMachine::syncState   stateService play
Jul 02 00:07:10 office volumio[719]: info: CoreStateMachine::syncState   currentStatus pause

Jul 02 00:07:21 office volumio[719]: info: CoreStateMachine::syncState   stateService pause
Jul 02 00:07:21 office volumio[719]: info: CoreStateMachine::syncState   currentStatus pause