How do Addon script and settings.xml communicate? - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: How do Addon script and settings.xml communicate? (/showthread.php?tid=367823) |
How do Addon script and settings.xml communicate? - jojobro - 2022-04-10 I'm trying to build an addon that controls a case fan for raspberry pi 4. I need to open a .conf file, read line by line, associate lines to values(line1=temp1,line2=speed1,...) then set those values to be controlled by setting type=number in settings.xml. So at the moment I'm trying to understand how an addon script communicates with the settings.xml file. I can open the file and set each line as a reference to be used later. I just don't know where to start to have that work in conjunction with my settings.xml code. This is the code in settings.xml: Code:
The addon.py: file = 'C:\\Users\\Joe\\AppData\\Roaming\\Kodi\\addons\\script.hellotestwindow\\resources\\test.conf' Code:
does anyone know how to do this? Or at least where to start? Anything about anything would help, I have absolutely no idea what to search. I did find a kodi docs website, that showed options like: Code: XBMCAddon::xbmcplugin::getSetting (int handle, const char *id) But I don't know how they work, or if it's even the correct code to use. Any help would be GREATLY APPRECIATED thank you RE: How do Addon script and settings.xml communicate? - jojobro - 2022-04-10 I think I just got it. The magic code is(depending on what type of content you're dealing with or doing(setting/getting): Code: .getSettingString Example code for addon.py: (settemp1 and setspeed1 are the values the user changed(as a string or default as an integer?) in settings.xml) Code: __addon_id__ = 'script.hellotestwindow' Corresponding example settingsxml: Code: <setting label="start temp" type="number" id="settemp1" default="30"/> IF I'M WRONG ON THIS, please let me know =/ I am literally throwing code at this until it works lol Now all I have to do is take that user input value, and save it into the location. I think... lol RE: How do Addon script and settings.xml communicate? - scott967 - 2022-04-11 Yes, kodi provides xbmcaddon module you can import. That gives access to the Addon class and for Kodi 20 the Settings class. Note there is new syntax for settings.xml see Add-on_settings_conversion (wiki) scott s. . |