v16 Controll Kodi from Rpi gpio buttons [SOLVED]
#1
Hello kodi people, my first post & new to kodi

I hope i am in the right section, if not, well, admin, please help Wink

I need to control kodi from rpi gpio buttons.

So, I have raspberry pi b, i have arch running, and on top of it i have kodi.
I have adafruit IR remote controller and IR receiver (so gpio is used).
No keyboard or mouse in this rig.
System is set up to boot, auto login, and auto start kodi. This setup works sweetly.

As it happens, i misplace RC a lot, and in future a battery will run out,
so I figured I can make a little solderable plate with buttons (momentary switches),
to control kodi.

With reboot and shutdown button I need 13 of them altogether.
Since rpi has 8 pins, and one is in use for IR receiver, I use mcp23017 IO expander, with wireingpi.

I also found this thread, which makes script runs at certain points, I need mine to run at kodi's start:
http://forum.kodi.tv/showthread.php?tid=151011

In kodi i can see under the running scripts that linked script is listed as running,
but nothing happens when I push my buttons (top command is not listing my script).
Rpi gpio buttons need root privileges, so I made my user sudoer and no need for password. No go.
I also started kodi as user (sudo kodi), but still no go.

So first things first, how to run a root script from kodi at start,
and second, I could not find kodi's python command for commands that i issue from my remote,
like play/pause, enter, left, right, back, setup,...


Any help is most welcome.
Thank you
Reply
#2
Look at this thread for some more discussion on this topic.

I've got an IR receiver plus 6 GPIO buttons set up on my Pi zero and they work fine to control it either via the remote or as basic controls via the buttons. I'm on a business trip at the moment, but if you can wait a few days I can give you a copy of the final version of the add-on and circuit I use.
|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
#3
Hello there DarrenHill

Hope your trip is going along well, thank you for taking time for noobs like me.

I will now read linked thread, and by the time your trip finishes, I hope I will have something to show, and I would be most glad if you could than provide me with circuit and scripts.

Thank you and hopefully talk to you soon.
Reply
#4
OK, you should be able to download the current (final) version of my script, set up as a service add-on so that it runs at start-up - click here.

Just install that zip file like a normal add-on, and it should set itself up and run on Kodi start-up (you can enable and disable it if you need to as a service add-on). You will also need to install RPi.GPIO, which should be available from the built-in repositories (it depends on quite what you are running on your Pi, OSMC or LibreElec/OpenElec).

The hardware set-up I use is 6 push buttons on GPIO 17, 27, 22, 6, 13 and 19 (pins 11, 13, 15, 31, 33 and 35). One side of each button is connected to ground, the other side to the GPIO pin. They act as up, down, left, right, select and shift respectively, with shift switching the other buttons action to back (up), info (down), stop (left), pause/play (right) and context menu (select) respectively.

My hardware is wired up on a protozero board, hence why I only use 6 buttons (it's all that will fit) and use the shift button to give 10 input options. The board also has an IR receiver diode on it, wired up to the usual GPIO pins (data on GPIO18 (pin 12), ground to pin 6 and 3V3 power to pin 1). So I can run my zero either with an old IR remote or via the buttons.
|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
#5
Hello kodi people,


Hey DarrenHill, thanks for reply.
On pi I run arch linux. (so no OSMC or LibreElec/OpenElec)
And on it I run Kodi-rbp (rpi version)

I got your zip, thank you, but we are not there yet:

1/ It appears I already have RPi.GPIO thingy:
Code:
$ python
Python 3.5.1 (default, Mar  6 2016, 12:32:57)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.VERSION
'0.6.2'
>>> quit()
If I try to install:
Code:
[root@kodi viewer]# pip install RPi.GPIO
Requirement already satisfied (use --upgrade to upgrade): RPi.GPIO in /usr/lib/python3.5/site-packages
Looking for 'lib' on my system:
Code:
[root@kodi viewer]# find / -name "lib"
/usr/local/lib
/usr/share/gdb/auto-load/usr/lib
/usr/share/kodi/addons/service.xbmc.versioncheck/lib
/usr/share/texinfo/lib
/usr/share/texinfo/lib/libintl-perl/lib
/usr/share/texinfo/lib/Unicode-EastAsianWidth/lib
/usr/share/texinfo/lib/Text-Unidecode/lib
/usr/share/perl5/core_perl/unicore/lib
/usr/lib
/usr/lib/modules/4.4.9-1-ARCH/kernel/lib
/usr/lib/firmware/carl9170fw/tools/lib
/home/viewer/.kodi/addons/service.subtitles.opensubtitles/resources/lib
/home/viewer/.kodi/addons/script.module.lat2cyr/lib
/home/viewer/.kodi/addons/weather.wunderground/resources/lib
/home/viewer/.kodi/addons/script.common.plugin.cache/lib
/home/viewer/.kodi/addons/service.subtitles.subscenter/resources/lib
/home/viewer/.kodi/addons/service.subtitles.podnapisi/resources/lib
/home/viewer/.kodi/addons/plugin.video.exodus/resources/lib
/home/viewer/.kodi/addons/service.subtitles.titlovi/resources/lib
/home/viewer/.kodi/addons/service.xbmc.versioncheck/lib
/home/viewer/.kodi/addons/script.module.simplejson/lib
/home/viewer/source/gpio/python-raspberry-gpio/pkg/python-raspberry-gpio/usr/lib
/lib
/opt/vc/lib
/var/lib
[root@kodi viewer]#


The one in /home/viewer/source/... is the one i downloaded and wanted to install, but have failed, since it seems installed
I use that lib in my kodi/python script.


on wiki it says kodi comes with python 2,
as I run python my version is 3.5.1. Should those versions be in sync? I know there is some difference between those two, tho i do not know the difference...

DroppedPJK suggested replacing version number in 'addon.xml' file, I did even that, but still no go..



2/ The other approach is suggested by the command: kodi-send --action='RunScript("/path/to/script.py")'
in shell i do not have this command. Where can i try this?


And what else can I try?

Thank you
Reply
#6
Hello Kodi people

DarrenHill oi oi, sorry for delayed response, RL got in the way, but now i have great news!
So it turns out, after days of trying/installinf a bunch of packages, for arch I need this to build: http://pkgbuild.com/git/aur-mirror.git/t...berry-gpio
Afterwards I got script to work, but only in sudo mode, which is just fine.

I used your script to make mine, well i modified yours, I added one more button and all works well on proto-board, now I have to soldier it, and thet is the next challange.

DarrenHill, thank you again for your input!
Reply
#7
You're welcome, glad to know it's working for you too Smile

GPIO normally needs root priv's to run, so needing sudo is not a big surprise (it works under OE/LE and OSMC as those use the root user anyway).

I just used 6 buttons on mine as it was all that will physically fit (I'm using a Pi Zero and a ProtoZero board), but the principle is completely extendable to any number of buttons (or at least as many as you have free GPIO inputs 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
#8
(2016-05-13, 23:08)DarrenHill Wrote: OK, you should be able to download the current (final) version of my script, set up as a service add-on so that it runs at start-up - click here.

Hi DarrenHill,

I cannot download your addon at this link. The page simply does nothing when I click on the download button. Is there any other download link?
I am also adding HW buttons to Pi and also prepared a service addon. It works fine however Kodi does not recognize the navigation input form the addon as a user activity and does not reset the inactivity timer.
How did you solve this?
Reply
#9
https://app.box.com/s/a242yrvq7lxtxzes65xgwxu57eaegyp0

Try the link above.

I didn't do anything with regard to any user activity time, as for me the buttons are just backup for the IR remote and receivers I also built into my hat board.
|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
#10
(2016-11-26, 15:27)DarrenHill Wrote: https://app.box.com/s/a242yrvq7lxtxzes65xgwxu57eaegyp0

Try the link above.

I didn't do anything with regard to any user activity time, as for me the buttons are just backup for the IR remote and receivers I also built into my hat board.
Thanks for the fast response. This is the same link as was in the original post. It does not work for me.
Reply
#11
It's the current working one from my box account.

I'm on a business trip at the moment until Christmas so I'm rather busy at the moment, but I'll as if I can find somewhere else to host it. But if you follow the link you should get to a page where you click on the icon to download (right click save as won't work).
|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
#12
(2016-11-27, 06:23)DarrenHill Wrote: It's the current working one from my box account.

I'm on a business trip at the moment until Christmas so I'm rather busy at the moment, but I'll as if I can find somewhere else to host it. But if you follow the link you should get to a page where you click on the icon to download (right click save as won't work).

Yes, I follow the link and click on the download icon, then nothing happens...
Reply
#13
Works fine for me - i'd guess you have scripts or something like that blocked on your browser that's screwing it up at your end?
|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
#14
I tried on two computers, from three different networks and with three different browsers.
BTW, is it allowed to download without registering to that site?
Reply
#15
It should be yes. I've uploaded it to OneDrive, try the link below

https://1drv.ms/u/s!Ajjrib39en7kgQtdSTVePAxuJvMe
|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

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