Can't use setSetting when in service settings screen
#1
I'm a bit confused by this, so would appreciate some comments from anyone who's experienced something similar.

I'm putting together a service that displays live football scores updates (hoping to get it finished before the World Cup!). As it's running as I service I want the user to be able to toggle whether or not to show goal notifications (e.g. if my wife is watching some American teen drama she won't be particularly interested to know that Costa Rica have taken a shock lead against England).

I've got a setting in the service that is used for this purpose. However, as I'd like to be able to be able to do this by pressing a button, there's a short script that toggles this setting without the need to go to the addon settings page. This works fine from anywhere except if I'm viewing the service's settings page, at which point the setting won't change.

Likewise, I have some methods to select/reset stored data (e.g. list of competitions that the user wants to follow). This needs to be called via an "action"-type setting method. However, the same issue applies here i.e. I can't store the setting if the user is in the settings screen, but I need to be there to call these methods (I don't want to bind everything to separate commands).

The script that tries to set these settings looks a bit like this:
Code:
_A_ = xbmcaddon.Addon("service.bbclivefootballscores")
_S_ = _A_.getSetting

def resetLeagues():
    '''Clears all saved league IDs.

    Useful if IDs change leading to duplicate menu entries.
    '''
    _A_.setSetting(id="watchedleagues",value="")
    _A_.setSetting(id="masterlist",value="")

def toggleNotification():
    '''Toggles score notifications on or off.'''
    state = not (_S_("Alerts") == "true")
    Notify("BBC Football Scores", "Alerts are now %s" % ("on" if state else "off"))
    _A_.setSetting(id="Alerts", value=str(state).lower())

The resetLeagues method is called from the settings page, toggleNotification is called via a parameter to a script. Neither works when user is in the settings page, both work if not in that page.

Does anyone know how I can get this to work?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#2
This gets weirder:

If I add the setting id to the settings.xml file, I can see that my script updates the setting as expected. However, if I leave the settings page and go back in it's clear that the changes haven't saved.

For example:

Starting position:
setting "watchleagues" has value "[]"

Enter settings screen and run script from action setting:
setting "watchleagues" has value "[1234,5678]" (this is correct)

Exit settings screen and go back in.
setting "watchleagues" has value "[]" (this is wrong)

Does anyone have any idea what's going on here?!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#3
i think the settings window simply overwrites the value if you actually use that same ID in the settings screen
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#4
Ok. But if I want to set a setting via an action type setting, how do I do it?

Ah. It's fairly simple. I've still got to hit "OK" to save settings that have been set by setSetting if I'm in the settings window.

Now I feel stupid...
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply

Logout Mark Read Team Forum Stats Members Help
Can't use setSetting when in service settings screen0