is there a way to "hook" a function when an addon is enabled/disabled ?
#1
Hi, I made an addon; but I would like to "hook" some function when the plugin is enabled.  Is that possible, and how ?

For the story, I do cache some datas with my addon.  But from one version to another, I might change how the data is stored.
And if so, when I open the addon, it gets the cache and the addon crashes because the old data is not well formatted.

I would like to systematically delete the cache when the plugin is enabled (or disabled > updated > enabled again).

Thanks !
Reply
#2
You mean enabled / disabled as in addon running or just status in Kodi library?

If you like to check status in Kodi library then use condition visibility:
xbmc.getCondVisibility('System.AddonIsEnabled(plugin.xxx)'

Otherwise checking if addon is running use this:
xbmcgui.Window(10000).getProperty('plugin.xxx_Running')
Reply
#3
(2021-05-17, 08:02)gordie Wrote: Hi, I made an addon; but I would like to "hook" some function when the plugin is enabled.  Is that possible, and how ?

For the story, I do cache some datas with my addon.  But from one version to another, I might change how the data is stored.
And if so, when I open the addon, it gets the cache and the addon crashes because the old data is not well formatted.

I would like to systematically delete the cache when the plugin is enabled (or disabled > updated > enabled again).

Thanks !
I don't think there is any hook to call an add-on after it is installed. Although if you had a service component to your add-on, it would be launched after install.  So you could create some logic there to check a version number or something that would then clear and download the new data and update the version number. Then you could add some logic to the "run" component of the add-on that verifies the version number it needs and displays a dialog saying it's still updating if they don't match.
Reply

Logout Mark Read Team Forum Stats Members Help
is there a way to "hook" a function when an addon is enabled/disabled ?0