Hello, help me Im dumb. Addon to control relays
#16
Let's see what Roman says to my above post. If LE runs kodi as root by default then I'm not sure this is the issue.

However, in answer to your question, there doesn't seem to be a gpio group so you could create one with the addgroup line in the post I linked to.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#17
There's an add-on in the LibreElec repo, I think called raspberry pi tools. That has rpi.gpio in it, and you can use it to interface between gpio and Kodi. I use it on my Pi zero for a hat with 6 control 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
#18
Nice! Sounds like the permission issue isn't an issue then!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#19
It's not an issue. With that addon installed you can use RPI.gpio in python scripts and so you have a path between Kodi and the pins. The script can be driven by the normal Kodi python events to change to pin states.
|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
#20
(2017-05-23, 20:59)DarrenHill Wrote: There's an add-on in the LibreElec repo, I think called raspberry pi tools. That has rpi.gpio in it, and you can use it to interface between gpio and Kodi. I use it on my Pi zero for a hat with 6 control buttons.
I have that installed also. When I click it, it says "this is a console only addon"
Reply
#21
Yes, it provides the GPIO module for python scripts. It's not a visual/GUI addon.
|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
#22
Sad 
(2017-05-23, 21:17)DarrenHill Wrote: It's not an issue. With that addon installed you can use RPI.gpio in python scripts and so you have a path between Kodi and the pins. The script can be driven by the normal Kodi python events to change to pin states.
Ok, so what do I do next? Create a script? I have never done that before....
Reply
#23
#!/bin/bash

# GPIO Control with Raspberry Pi

GPIOPORT=18
STATE=$(cat /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/gpio$GPIOPORT/value)

echo $GPIOPORT > /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/export
echo "out" > /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/gpio$GPIOPORT/direction

if [ "$STATE" == "1" ]; then
echo "0" > /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/gpio$GPIOPORT/value
else
echo "1" > /storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO/gpio$GPIOPORT/value
high




I edited the relay.sh script that was in the addon I downloaded. I added my GPIO location using RPi tools. Does this look right?

Nope, that didnt work....
Reply
#24
No that's a bash script. The add-on provides a Python module - different language.

Look up "gpio python raspberry pi" on the net to get you started. Kodi (and variants) ship with python2.
|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
(2017-05-24, 20:29)DarrenHill Wrote: No that's a bash script. The add-on provides a Python module - different language.

Look up "gpio python raspberry pi" on the net to get you started. Kodi (and variants) ship with python2.
Well... Im not too sure what im doing wrong. Here is the code that is currently in use.

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
import xbmcaddon
#import xbmcgui
import os
import xbmc

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')

line1 = "Turned on/off a relay"
line2 = "Version: " + addon.getAddonInfo('version')

os.system("sh /storage/.kodi/addons/relay-addon-kodi-master/relay.sh")

xbmc.executebuiltin('Notification(Relay Addon, The relay was turned on/off,5000,//storage/.kodi/addons/script.relay.master/icon.png)')
#xbmcgui.Dialog().ok(addonname, line1, line2)



The addon gives me an error and says to check logs. I have no clue where those logs are. Here is the original python script that came with the addon:

import xbmcaddon
#import xbmcgui
import os
import xbmc

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')

line1 = "Turned on/off a relay"
line2 = "Version: " + addon.getAddonInfo('version')

os.system("sh /storage/.kodi/addons/relay-addon-kodi-master/relay.sh")

xbmc.executebuiltin('Notification(Relay Addon, The relay was turned on/off,5000,//storage/.kodi/addons/script.relay.master/icon.png)')
#xbmcgui.Dialog().ok(addonname, line1, line2)


Here is the source I used:

https://sourceforge.net/p/raspberry-gpio...asicUsage/
Reply
#26
The log is the debug log (wiki). If you're going to post it here, please upload it to PasteBin.com and supply their link here, don't post the log directly.
|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 I found the issue. It cannot find :
Import RPi as GPIO. What is the correct path to the GPIO in RPi?
Is it:

/storage/.kodi/addons/virtual.rpi-tools/lib/RPi

Or do I need to go to:
/storage/.kodi/addons/virtual.rpi-tools/lib/RPi/GPIO
Reply
#28
https://pastebin.com/VaK9nrZ2
Reply
#29
At the top of your script after the Python declaration put:

Code:
import sys
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')

import RPi.GPIO as GPIO

You can then refer to the library via GPIO.<command> such as GPIO.setmode GPIO.setwarnings GPIO.setup etc
|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
https://pastebin.com/0fvVpmuw



I keep getting this:
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 rpigpio
Traceback (most recent call last):
File "/storage/.kodi/addons/script.relay/addon.py", line 4, in <module>
import rpigpio as GPIO
ImportError: No module named rpigpio

No matter what I use for the GPIO import. Ive tried RPi.GPIO, rpigpio.sy, and the one im currently using. It looks like its searching for the GPIO in my addon folder not my RPitools folder.
Reply

Logout Mark Read Team Forum Stats Members Help
Hello, help me Im dumb. Addon to control relays0