Addon RunScript cant get it to work

  • I'm trying to execute code through an addon settings page.

    The libreelec kodi.log says it successfully ran the script, but nothing happens.

    And without a readout to see where it exactly failed, I've spent hours trying to get this to work,

    with slight variations, over and over...

    The settings.xml button looks like this:

    Code
    <setting label="Turn On Fan" type="action" action="'RunScript(/storage/.kodi/addons/script.hellotestwindow/script/TurnFan_On.py)')"/>

    The code in the script:

    (Which is a python script, idk if that matters)

    Code
    import os
    os.system("echo pwm_100 > /dev/ttyUSB0")

    I have tried using:

    Code
    import xbmc
    xbmc.executebuiltin('echo "pwm_100" > /dev/ttyUSB0')

    I have also tried test code in which I touch/nano/echo a file, to see where it gets created, or if I can create a file but nothing.

    Maybe I'm not understanding how this process works fully.

    I'm trying to execute code as if it was in the CLI.

    (realistically at this point, I'd settle for anyway of doing this)

    Also if anyone could figure out a way to get to "/storage/" from that code execution that would be awesome as well.

    After this I need to figure out how to run an .sh installer, but all of it hinges on the ability to run code in this way and to be able to get to "storage/".

    Anything will help.

    THANKS IN ADVANCE!!!!!

  • The code in the script:

    (Which is a python script, idk if that matters)

    Code
    import os
    os.system("echo pwm_100 > /dev/ttyUSB0")

    Are you sure about redirecting it to '/dev/ttyUSB0'?
    That is usually a serial console attached to USB (at least that's where I know it from).

  • I tried your solution vpeter, but it didn't work.

    I got it to work using

    Code
    action="RunScript(/storage/.kodi/addons/script.hellotestwindow/resources/scripts/TurnFan_On.py)"/>

    which is the same, but inside a resources directory.

    @diederik
    Are you sure about redirecting it to '/dev/ttyUSB0'?

    That is usually a serial console attached to USB (at least that's where I know it from).

    yeah that is where the USB serial bus is located, at least after adding otg_mode=1 in config.txt

    But not at all, idk what I'm doing.

    The company Deskpi created a case for the rpi 4 and haven't been able to create an installer for it for libreelec.

    I impulsively bought one, before they began shipping I guess, and have been sitting on an entire kodi rpi setup for a year and a half.

    So eventually I took their code and got it to work.

    Which is rad, but you can only control it through ssh atm. which I think is lame for realistic long term use.

    Who wants to open an ssh connection to quiet the fan a little, or bump the speed up cuz it's summer.

    So now I'm trying to take that installer that I made, and figure out a way to install it through an addon, set some fan speeds, maybe send code into a .conf file to change overall values. but try to keep it AS SIMPLE AS POSSIBLE.

    Because I can't code, and Idk what I'm doing.

    But I'm trying my hardest to lol

    Thanks for your help!