Update sensor based on events in python

Hi,

I have an integration based on Kodi integration that displays the playlist. The data of the playlist is contained in a sensor. Currently, I use a lot of service calls to update the sensor, but this is not efficient and I want to use the kodi events to update the data.

I registered an event listener in the sensor and I see all the kodi events coming. This is not a problem. I use a callback to handle the events and refresh the playlist if needed. This is where it comes problematic.

When switching to the ‘next’ track, kodi fires 3 events. For each event, I call my own methods, and even if the data contained by the sensor is updated, the Dev tools doesn’t display the data until the method async_update is called.

Does anyone have an idea how I can force the update ? Do I have to fire an event?