Help with addon - GetDirectory - Error getting plugin
#1
I'm trying to create my first XBMC addon for my openelec Frodo XBMC installation on a headless Raspberry Pi. It is a simple script to stop any music playing, play a doorbell sound, and then restart the music. It will be triggered by Jsonrpc from my server, connected to a doorbell. I have set up the addon in .xbmc/addons/script.module.doorbell and created addon.xml, addon.py and a resources/media directory holding the doorbell sound. If I plug a monitor into the RPi, the addon shows up in the Programs section so has been recognised, but it doesn't seem to play the doorbell sound if I click on it.

The script is in addon.py and looks like this:

Code:
# Doorbell script.  Pauses audio if playing, then plays doorbell
# and restarts audio if relevant

import sys, xbmc, xbmcaddon

__addon__ = xbmcaddon.Addon(id='script.module.doorbell')
__addonname__ = __addon__.getAddonInfo('name')
__icon__ = __addon__.getAddonInfo('icon')

# Doorbell sound is in addon resources/media directory
media = 'special://home/addons/script.module.doorbell/resources/media/doorbell.wav'

playing = xbmc.Player().isPlaying()
if playing:
    xbmc.Player().pause()
xbmc.playSFX(media)
if playing:
    xbmc.Player().play()

Not sure if I need the gubbins at the beginning, but I saw it in an example script so put it in there!

My addon.xml looks like this:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.doorbell" name="Doorbell" version="0.0.1"
provider-name="Ivan Mactaggart">
  <requires>
    <import addon="xbmc.python" version="2.1.0"/>
    <import addon="xbmc.addon" version="12.0.0"/>
  </requires>
  <extension point="xbmc.python.script" library="addon.py">
    <provides>executable</provides>
  </extension>
  <extension point="xbmc.addon.metadata">
    <summary lang="en">Doorbell</summary>
    <description lang="en">Plays a doorbell sound</description>
    <disclaimer lang="en"></disclaimer>
    <language></language>
    <platform>all</platform>
    <license></license>
    <forum></forum>
    <website></website>
    <email></email>
    <source></source>
  </extension>
</addon>

When I call the script the json call reports success, but the script doesn't work and my xbmc.log contains the following:

Code:
16:40:21 T:2925569120  NOTICE: Thread XBPyThread start, auto delete: false
16:40:21 T:2925569120  NOTICE: -->Python Interpreter Initialized<--
16:40:22 T:3047276544   ERROR: GetDirectory - Error getting plugin://script.module.doorbell
16:40:22 T:3047276544   ERROR: CGUIMediaWindow::GetDirectory(plugin://script.module.doorbell) failed

Can anybody see something I'm doing wrong, or tell me what else I should investigate? Any help much appreciated.
Reply
#2
Incidentally I tried commenting out the import of xbmcaddon and the three lines with the underscored variables in case it was not finding them, but no difference.
Reply
#3
I don't have a lot of experience writing scripts, but I've done a few. Firstly, your code should be in default.py, not addon.py I believe. There are a few differences between plugins and scripts which you can get from the writing scripts tutorials. I normally import routines from scripts and call them as routine from other scripts or plugins. As far as I know, a script doesn't get called in the same way as a plugin and your code is behaving more like a plugin than a script. Lastly, I'm not really sure that you can call a script using plugin://script.name but it may be possible. I would probably just rewrite what you have as a script as a plugin. Basically you just need to change the name in default.py and addon.xml to a plugin, put the code you have in addon.py into default.py and you're pretty much done.

You should have a look at how the plugins and scripts provided with XBMC are written in your addons folder to get a better feel for their structures.
Reply
#4
This certainly looks like a script rather than a plugin. So I don't think you want to call it as a plugin. Can you post the JSON code that you're using to call the script.

Also, I wouldn't be concerned about default.py or addon.py as long as your addon.xml file points to the right file, which it does.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
(2014-06-19, 10:45)el_Paraguayo Wrote: This certainly looks like a script rather than a plugin. So I don't think you want to call it as a plugin. Can you post the JSON code that you're using to call the script.

Also, I wouldn't be concerned about default.py or addon.py as long as your addon.xml file points to the right file, which it does.

El_Paraguayo is correct. Sorry I was tired when I read this and didn't see you we're calling from jsonrpc and missed the library= statement in addon.xml.
Reply
#6
Thanks for all of your input. It's certainly a script, but I could not find a way to trigger a script remotely and so took the route of bundling it up as an addon so I could trigger it with Jsonrpc. I'm currently calling it from the command line using curl from a remote machine. The code I use to trigger it is below:

Code:
curl --data-binary '{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": {"wait": false, "addonid": "script.module.doorbell"},"id":1}' -H 'content-type: application/json;' http://192.168.0.13:8080/jsonrpc

I get the following response:

Code:
{"id":1,"jsonrpc":"2.0","result":"OK"}

Of course now I am testing it further it has started working partially. I can tell that it is now being triggered because the playing track stops and restarts at the beginning, but the doorbell sound doesn't play.

As a follow on question, can anyone tell me how to restart a paused track at the point it was paused, and can anyone see an error in the 'special' syntax I'm using to reference the .wav file? It is stored in /storage/.xbmc/addons/script.module.doorbell/resources/media (/storage is the default home directory in openelec) and the filename is correct (doorbell.wav).

Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
Help with addon - GetDirectory - Error getting plugin0