Hello, help me Im dumb. Addon to control relays
#31
Python is case sensitive and cares about stuff like full store too.

"import rpigpio as GPIO" is not the same as "import RPi.GPIO as GPIO"

It also cares about indentation of code (just to save you finding that out the hard way later). There are some good python tutorials on the net.
|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
#32
Ik, here is the new issue. I had to install rpi.gpio python update located here:

https://pypi.python.org/pypi/RPi.GPIO

I have that installed and it still cannot locate the file. It says error no module named RPi.GPIO

Here is the log:
https://pastebin.com/6dkMd5LC
Reply
#33
Did you include the correct append line in your script? The Raspberry Pi Tools addon you have installed provides RPi.GPIO so you shouldn't need to add anything else if you have the library path to it appended to your Python path
|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
#34
(2017-05-27, 07:48)DarrenHill Wrote: Did you include the correct append line in your script? The Raspberry Pi Tools addon you have installed provides RPi.GPIO so you shouldn't need to add anything else if you have the library path to it appended to your Python path
Code:
import xbmcaddon
#import xbmcgui
import os
import xbmc
import sys
sys.path.append('/storage/.kodi/addons/Adafruit_Python_GPIO-master/')

import Adafruit_GPIO as GPIO

gpio = GPIO.get_platform_gpio()
gpio.setup(9, GPIO.OUT)

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)


Im still getting problems importing the GPIO.
Reply
#35
I'm a bit confused. DarrenHill's posts suggested installing the Raspberry Pi Tools addon as this gives you RPi.GPIO. I'm therefore not sure why your script is therefore using the Adafruit_GPIO module.

Admittedly, I think the Adafruit_GPIO module does try to access RPi.GPIO but we've no idea how you've installed it or whether RPi.GPIO is actually installed at all.

Lastly, if you're getting problems, please post the actual error messages from your log as general statements like "Im still getting problems importing the GPIO" make it virtually impossible to give you any meaningful assistance.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#36
(2017-06-06, 10:33)el_Paraguayo Wrote: I'm a bit confused. DarrenHill's posts suggested installing the Raspberry Pi Tools addon as this gives you RPi.GPIO. I'm therefore not sure why your script is therefore using the Adafruit_GPIO module.

Admittedly, I think the Adafruit_GPIO module does try to access RPi.GPIO but we've no idea how you've installed it or whether RPi.GPIO is actually installed at all.

Lastly, if you're getting problems, please post the actual error messages from your log as general statements like "Im still getting problems importing the GPIO" make it virtually impossible to give you any meaningful assistance.

Sorry about that. I downloaded and let KODI install Raspberry Pi Tools so I can use GPIO. It does seem like the GPIO is not installed though. I changed it back to the RPi.GPIO, Here is my error log:

https://pastebin.com/Pjh3XiZN
Reply
#37
So Kodi can't find the RPi.GPIO module..

DarrenHill's earlier post said, assuming you've installed the Raspberry Pi Tools addon, your script should include these lines:
Code:
import sys
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')

import RPi.GPIO as GPIO
However, I note that you've also used pip to install RPi.GPIO. The sys.path.append line may therefore need to point to that installation instead.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#38
(2017-06-06, 15:40)el_Paraguayo Wrote: So Kodi can't find the RPi.GPIO module..

DarrenHill's earlier post said, assuming you've installed the Raspberry Pi Tools addon, your script should include these lines:
Code:
import sys
sys.path.append('/storage/.kodi/addons/python.RPi.GPIO/lib')

import RPi.GPIO as GPIO
However, I note that you've also used pip to install RPi.GPIO. The sys.path.append line may therefore need to point to that installation instead.

Now this is the error I get: dynamic module does not define init function (initGPIO)

https://pastebin.com/VFDwdGnD
Reply
#39
Ok, I think the GPIO is located, this is my NEW error message:

https://pastebin.com/Bc94kB31
Reply
#40
Hmm. It would probably help to see your code. That's the kind of error message you get when a python file has the same name as another module.

Could you also put these lines in your code after the line importing RPi.GPIO:
Code:
import xbmc
xbmc.log("GPIO path: {0}".format(GPIO.__file__), xbmc.LOGERROR)
Run it again and paste the log message including the line beginning "GPIO path..."
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#41
https://pastebin.com/hkdTejKF

Code:
import xbmcaddon
#import xbmcgui
import os
import xbmc
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/')

import RPi.GPIO as GPIO
import xbmc
xbmc.log("GPIO path: {0}".format(GPIO.__file__), xbmc.LOGERROR)
GPIO.setmode(GPIO.BCM)

GPIO.setup(9, GPIO.OUT)

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)
Reply
#42
Was there a line in your logfile beginning "GPIO path:"?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#43
The libreelec forum suggests the append line should be:
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
Have you tried that?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#44
(2017-06-06, 20:35)el_Paraguayo Wrote: The libreelec forum suggests the append line should be:
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
Have you tried that?

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: dynamic module does not define init function (initGPIO)
Traceback (most recent call last):
File "/storage/.kodi/addons/script.relay/addon.py", line 7, in <module>
import RPi.GPIO as GPIO
ImportError: dynamic module does not define init function (initGPIO)
-->End of Python script error report<--
That was using the
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
Reply
#45
(2017-06-06, 21:09)ablues10 Wrote:
(2017-06-06, 20:35)el_Paraguayo Wrote: The libreelec forum suggests the append line should be:
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
Have you tried that?

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: dynamic module does not define init function (initGPIO)
Traceback (most recent call last):
File "/storage/.kodi/addons/script.relay/addon.py", line 7, in <module>
import RPi.GPIO as GPIO
ImportError: dynamic module does not define init function (initGPIO)
-->End of Python script error report<--
That was using the
Code:
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

This error means that a compiled dynamic library cannot be initialized as a Python module. It looks as if the binary GPIO module (_GPIO.so) is either incorrectly compiled or for a wrong platform. Make sure that you have installed this module from the official LibreELEC repo via Kodi Addon Manager. This should guarantee that you have correct binary components installed.

And for Kodi module addons you don't need to manipulate sys.path. Just add the necessary module addon to the requires section of your addon.xml and it will be added to sys.path of your addon automatically.

BTW, just out of curiosity I've installed RPi tools addon and imported it with no problems:
addon.xml (excerpt):
Code:
<requires>
    <import addon="xbmc.python" version="2.19.0"/>
    <import addon="virtual.rpi-tools" />
</requires>
main.py:
Code:
from pprint import pformat
import xbmc
import RPi.GPIO as GPIO
xbmc.log(pformat(dir(GPIO)), xbmc.LOGNOTICE)
Result:
Code:
23:33:49.107 T:1240986528  NOTICE: ['BCM',
                                             'BOARD',
                                             'BOTH',
                                             'FALLING',
                                             'HARD_PWM',
                                             'HIGH',
                                             'I2C',
                                             'IN',
                                             'LOW',
                                             'OUT',
                                             'PUD_DOWN',
                                             'PUD_OFF',
                                             'PUD_UP',
                                             'PWM',
                                             'RISING',
                                             'RPI_INFO',
                                             'RPI_REVISION',
                                             'SERIAL',
                                             'SPI',
                                             'UNKNOWN',
                                             'VERSION',
                                             '__builtins__',
                                             '__doc__',
                                             '__file__',
                                             '__name__',
                                             '__package__',
                                             '__path__',
                                             'add_event_callback',
                                             'add_event_detect',
                                             'cleanup',
                                             'event_detected',
                                             'getmode',
                                             'gpio_function',
                                             'input',
                                             'output',
                                             'remove_event_detect',
                                             'setmode',
                                             'setup',
                                             'setwarnings',
                                             'wait_for_edge']
Reply

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