How to invoke python interpreter from kodi on raspberry pi 4

  • Hi, I am totally new to LibreELEC, Kodi, Python and Raspberry Pi. I have no coding experience!

    I have installed the latest version of LibreELEC on my Raspberry Pi 4, and some addons - Raspberry Pi tools.

    I just need to play a video on a loop that is stored on the SSD I have connected to the pi.

    I've wired a motion detector to the GPIO pins and want the video to pause and play in response to motion detected in a room.

    I'm using LibreELEC because the video is 4K - it needs to be at this high resolution.

    I can't work out how to even invoke the python interpreter from Kodi. Do I have to do this from a Terminal on my Macbook connecting via SSH to the pi? Do I type a python script into the Terminal on my Macbook once connected to the pi? Or is there an add on in kodi to bring up a shell where I can type the python code?

    I had someone helping me to do this but have had to now do it myself.... any help would be amazing. It's for art if that makes a difference?!

  • Something to start with...

    Just to give you an idea what you need...

    change pin 11 to your motion gpio pin...remove debugging when done if you don't want logging...

    not tested..


    Now I just seen that you wanted to pause and play not stop and play so you might need to change some of the script but at least try and see if it works this way..

    Edited 2 times, last by Mario77: Merged a post created by Mario77 into this post. (June 9, 2023 at 9:17 PM).

  • Thanks so much Mario, will try this and see how it goes. Just checking - do I need to enter this code via SSH Terminal on my Mac?

    Sorry never touched a mac in my life...but if you have access to your libreelec via ssh terminal just copy all the following code at once and paste it in your terminal...you might need to press enter more then once for all commands to run...

    Dont forget to change MOTION_PIN = 11 to your motion detector pin you are using...

  • Ah, really sorry have tried searching everywhere for this information - it's very basic, but how can I see the file path? My video is called "perennialseries.mp4" and is located on an external SSD called "T7" which is plugged into my Raspberry Pi. I can't seem to find the file path information anywhere.

  • Ah, really sorry have tried searching everywhere for this information - it's very basic, but how can I see the file path? My video is called "perennialseries.mp4" and is located on an external SSD called "T7" which is plugged into my Raspberry Pi. I can't seem to find the file path information anywhere.

    Is it in a directory/folder on the ssd?

    If not it should be

    /var/media/T7/perennialseries.mp4

  • Preferably if you want video to loop you will have to add it to a playlist,you do that from kodi menu and then the path has to be that of the playlist..


    SO you make a small playlist and move it to

    Code
    /storage/.kodi/userdata/playlists/video
    Quote

    #EXTCPlayListM3U::M3U

    #EXTINF:0,perennialseries.mp4

    /var/media/T7/perennialseries.mp4

    and name it perennialseries.m3u

    then in the script line 24

    Code
    xbmc.executebuiltin("PlayMedia(/storage/.kodi/userdata/playlists/video/perennialseries.m3u)")

    Edited once, last by Mario77: Merged a post created by Mario77 into this post. (June 11, 2023 at 11:24 AM).

  • Ok. So I have been able to create the playlist perennialseries.m3u and moved it to the loaction /storage/.kodi/userdata/playlists/video

    I then tried entering code into the Terminal but nothing happens. Do I need to then type something to call the function to run it?

  • Ok. So I have been able to create the playlist perennialseries.m3u and moved it to the loaction /storage/.kodi/userdata/playlists/video

    I then tried entering code into the Terminal but nothing happens. Do I need to then type something to call the function to run

    If you saved the playlist from kodi ui there will be no need to move it as iy will e saved in the playlists folder by default.

    Do you know which gpio you r using for motion detection?Did you change that in the script?