v16 Controll Kodi from Rpi gpio buttons [SOLVED]
#16
(2016-11-28, 18:30)DarrenHill Wrote: It should be yes. I've uploaded it to OneDrive, try the link below

https://1drv.ms/u/s!Ajjrib39en7kgQtdSTVePAxuJvMe

Thanks. Now I can download it.
Reply
#17
Hello,

This appears to be the right place to post this question...

I am looking to use GPIO buttons as well, at least one for certain, and this being to send a shutdown signal using LIbreElec and through a GPIO > momentary button > 1k resistor ground.
I have tried using your zip add on and when installing, I get an error message and cannot find the add on in the listing with the others.. It simply says to check the logs, and my log only says 'kodi has started"

Must I do some configuration of your file before I install the zip? or is it configurable from within kodi?

Thanks
Scott
Reply
#18
You need to set it up, but after install (edit the script). It's basically just a background script which polls the pins and sends Kodi commands on button press. You need to set that up in the script (which pins you use and what you want them to do).

Also make sure that you have rpi.gpio installed. To do that install the raspberry pi tools addon from the programs section of the LibreElec repo.

The script is a bit rough and ready as it was originally just for my personal use, but I thought others might find it helpful.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#19
Ok this time when I installed your addon it worked, however I get an error on bootup into kodi now that says service.protozero.buttons error after I added my action.. Is the way I wrote it wrong? I would just like to at least get this one function to work. on a low signal when the button is pulled low.

Thanks

shutdownPin = 16 # board pin 36
upPin = 17 # board pin 11
downPin = 27 # board pin 13
leftPin = 22 # board pin 15
rightPin = 6 # board pin 31
selectPin = 13 # board pin 33
shiftPin = 19 # board pin 35

def shutdown_callback(channel):
xbmc.executebuiltin("ShutDown")
Reply
#20
You need to add a setup and an event detect in class main as well. See the existing ones as examples.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#21
I'm back to receiving errors when installing the addon in it's original format, fresh download.
Both installing and once it boots, it gives the popup error in the upper right of the screen with a red circle "x"
Reply
#22
Can you gather a debug log (wiki) of the issue, upload it to PasteBin.com and supply the link they will give you here?

Also upload your version of the script there and give that URL too.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#23
Here's the part with the error.. If you need the whole thing, I could figure out how to use PasteBin
I've reinstalled LibreElec and both Raspberry Pi Tools and System Tools addons
Version - "service.protozero.buttons" name="Zero Buttons" version="1.0.1" provider-name="DarrenHill"
Thanks


12:19:39.071 T:1777333152 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.ImportError'>
Error Contents: No module named RPi.GPIO
Traceback (most recent call last):
File "/storage/.kodi/addons/service.protozero.buttons/buttons.py", line 6, in <module>
import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO
Reply
#24
The Raspberry Pi Tools add-on should provide that module. Can you check that it is installed and enabled correctly?

I'll double-check on my Pi where I use it myself this evening whether there is something else, but from memory that's all you should need in addition to the protozero add-on.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#25
Visually it appears to be installed, a red pineapple. If I attempt to configure it, it says that it's console only.
I also attempted to use a simple gpiozero script in place of yours and got an error ...

"ImportError: No module named gpiozero"

These are the relevant addons that show up in ~/.kodi/addons
service.protozero.buttons
virtual.rpi-tools
virtual.system-tools

Perhaps a side note, the only other error that I get in logs is a Dbus error

Thanks again
Reply
#26
OK found the problem - that version of the script is an old one and was designed for a different source of rpi.gpio.

What you need to do is change the 4th line of the script from

Code:
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')
to
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

and then it should work. I'll upload that new version to box and onedrive too.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#27
Ok,

Initially when I installed it with the above change, it had the same error in the display, however upon reboot there's no apparent error. The logs show some form of loading the addon without error.. Buuut, I tried just a 1k resistor to ground through button and GPIO 6 to see if anything happens. GPIO 6 is "play/pause" if I'm not mistaken. I get no action or indication while watching a movie.. My only use at the moment is to initiate a shutdown command when a low signal is sensed on a GPIO. Any pointers on what I can do to see if it's actually loaded and operable?

Thanks again
Reply
#28
Got it going...
able to shutdown etc...
I think there was something going on where I had to actually enable the service after installing it.
I also think that you have a typo in your first line of your new updated script..

#!/usr/bin/pyt


Once again, Thank You

Heres what got me what I needed for shutdown..

#!/usr/bin/python

import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

import RPi.GPIO as GPIO
import xbmc

sdownPin = 16 # board pin 36


def sdown_callback(channel):
xbmc.executebuiltin("ShutDown")

class Main:
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(sdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(sdownPin, GPIO.FALLING, callback=sdown_callback, bouncetime=300)


while not xbmc.abortRequested:
xbmc.sleep(5)

class TidyUp:
GPIO.remove_event_detect(sdownPin)

GPIO.cleanup([sdownPin])


if (__name__ == "__main__"):
Main()
TidyUp()
Reply
#29
Looks good to me.

I'll check that first line, but it doesn't affect the code running anyway. It's just an indicator as to what language the script runs in. I should probably overhaul it a bit anyway and make the tools addon a proper dependency in the addons.XML file. But as it was just originally a quick script for my own usage it's a bit rough and ready.

But glad it's been useful and is working anyway.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#30
Hi dear DarrenHill,
I have installed your add-on service.prozero.buttons, but i have the following errors
13:56:56.944 T:1734341616 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: No access to /dev/mem. Try running as root!
Traceback (most recent call last):
File "/home/osmc/.kodi/addons/service.protozero.buttons/buttons.py", line 46, in <module>
class Main:
File "/home/osmc/.kodi/addons/service.protozero.buttons/buttons.py", line 49, in Main
GPIO.setup(upPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
RuntimeError: No access to /dev/mem. Try running as root!
-->End of Python script error report<--
How can i resolve this error ?
Thanks a lot
Reply

Logout Mark Read Team Forum Stats Members Help
Controll Kodi from Rpi gpio buttons [SOLVED]0