Addon Module Dependency Question

  • I'm trying to re-write the addon I created to control the fan inside the Deskpi Pro case.
    (https://github.com/jojobrogess/script.deskpifanservice)

    In order to control the fan, I need the serial. Currently this is how I install it

    https://github.com/pyserial/pyserial
    pyserial_installer.sh, code inside:
    cd ~/
    wget https://github.com/jojobrogess/py…ags/v3.5.tar.gz -O pyserial-3.5.tar.gz
    export tmp_dir=~/install_temp/
    mkdir $tmp_dir
    cd $tmp_dir
    tar -xvf ~/pyserial*.tar.gz
    cd pyserial*
    python setup.py install --user
    cd ~/
    rm $tmp_dir/ -Rf
    rm pyserial-3.5.tar.gz

    I then run that file with install_pyserial.py, code inside:
    os.system(f'cp {addon_directory}/resources/lib/pyserial_installer.sh {user_storage}/')
    os.system(f'sh {user_storage}/pyserial_installer.sh')

    With this method, everything gets installed to:
    /storage/.local/lib/python3.8/site-packages/serial

    What I'm wondering is, is this an accepted install method?
    or should I be creating a subdirectory within my addon with the module inside that.

    As that is what the kodi docs seem to suggest:
    https://kodi.wiki/view/Python_li…s%20inside%20it.

    https://kodi.wiki/view/Add-on:Pyserial
    Although it does say that there are modules available for use and pyserial is one of those modules but I don't know the addon id for it.
    And modules can't be searched, or at least they don't have their own widget category.
    And if I install pyserial with my current methodology, I can't use it as a dependency in addon.xml and it installs in a location outside of the addon directory/addon_data directory.


    *********************************************************************************************************************************

    SIDE note, if a mod reads this:
    My addon needs to modify the /flash/config.txt file, adding "otg_mode=1,dtoverlay=dwc2,dr_mode=host,dtoverlay=gpio-ir,gpio_pin=17" to the EOF:

    Display Spoiler

        mount -o remount,rw /flash
       echo "otg_mode=1,dtoverlay=dwc2,dr_mode=host,dtoverlay=gpio-ir,gpio_pin=17" >> /flash/config.txt
       mount -o remount,ro /flash

    Is an addon "allowed" to modify that file?

  • Cherry picking two points. For general addon development questions you may get more feedback in Kodi forum.

    Although it does say that there are modules available for use and pyserial is one of those modules but I don't know the addon id for it.

    Following the usual naming conventions <import addon="script.module.pyserial"/> should work.

    My addon needs to modify the /flash/config.txt file

    IMO this requires some caution. E.g. check of supported HW, already modified config.txt...

    From the UI there should be a deinstallation button.

  • I was thinking there was an already made module like rpi-tools or systemtools i could import. But I just imported it into the addon itself and called on it with <extension point="xbmc.python.module" library="resources/lib/serial" />

    IMO this requires some caution. E.g. check of supported HW, already modified config.txt...
    From the UI there should be a deinstallation button.

    As for the config.txt, I made sure I checked for each of them individually and then only add the ones that are missing to the very bottom.
    The uninstaller works in a similar way and is available through the addon's settings window.

    Thank you mglae!