How Do I Reference Settings in settings.xml in Kodi python plugin?
#1
Just a quick question how do I reference settings in settings.xml in my Kodi python plugin?

my settings.xml file is :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="32001">
<setting label="30000" type="text" id="Device Path" default="/dev/ttyACM0"/>
<setting type="sep"/>
<setting label="30001" type="number" id="Starting Volume" default="5"/>
</category>
</settings>

And i just want the plugin in to read the device path and starting volume settings before it starts?

p.s. Sorry if this is a very obvious question, any help is appreciated.
Reply
#2
In your plugin code use this:

addon = xbmcaddon.Addon('plugin.video.xyz')
devicePath = addon.getSetting('Device Path')
startVolume = addon.getSetting('Starting Volume')

where 'plugin.video.xyz' is the name of your plugin

I've never used a setting id with spaces in it, but I don't think it's a problem.
Reply
#3
It is probably worth mentioning that ALL values come back as strings, that's got me a few times in the past Smile
Reply
#4
(2015-10-30, 06:13)learningit Wrote: In your plugin code use this:

addon = xbmcaddon.Addon('plugin.video.xyz')

there's no need to hardcode the addonid.
simply use:
Code:
addon       = xbmcaddon.Addon()
and kodi will resolve the addonid automatically.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
(2015-10-30, 10:12)ronie Wrote:
(2015-10-30, 06:13)learningit Wrote: In your plugin code use this:

addon = xbmcaddon.Addon('plugin.video.xyz')

there's no need to hardcode the addonid.
simply use:
Code:
addon       = xbmcaddon.Addon()
and kodi will resolve the addonid automatically.

If it can, I've had a few instances (usually doing weird stuff like launching scripts via executebuiltin) where it can't resolve it.
Reply
#6
Spoyser is correct on both things he says above.
Even an enum comes back from addon.getSetting as a string which needs to be converted to an int.
There are times when you're not doing weird stuff that xbmcaddon.Addon() doesn't resolve correctly, an obvious example is calling it from a supporting script.module.xyz routine. I've just found it safer to include the addonid.
Reply

Logout Mark Read Team Forum Stats Members Help
How Do I Reference Settings in settings.xml in Kodi python plugin?0