add json-rpc method in an addon ?
#1
Hi,

I'll start an addon development and i search if it's possible in addon to develop a json-rpc method ? If the answer is Yes, is it possible to add the method in the answer of the JSONRPC.introspect method ?


thanks

Reply
#2
Not currently possible. What kind of idea did you have in mind?
Reply
#3
I want to create an addon which communicate with an hardware module (like arduino) and use XBMC as IR relay between an android phone (in wifi mode ) and my Audio/Video amplificator.

android --- send remote command via JSON-RPC --> xbmc ---- send IR command via Arduino ---> audio/video ampli

Reply
#4
My best guess effort would be:

Code:
# defined in Key.h
ACTION_VOLUME_UP = 88
ACTION_VOLUME_DOWN = 89

class VolumeMonitorDialog(xbmcgui.WindowXMLDialog):
    def onAction(self, action):
        actionID = action.getId()
        if actionID == ACTION_VOLUME_UP:
            # Volume up
        if actionID == ACTION_VOLUME_DOWN:
            # Volume down

When you call the dialog's doModal() it will start receiving actions. Caveat: Only as long as the dialog is open.

The best way to intercept these events in the background would be a service addon that extends xbmc.Monitor (see PR#856). You would then need to use C++ to code an onAction() method for xbmc.Monitor.

If you talk with Montellese and Amet, they might suggest a better way than enhancing xbmc.Monitor, and they'd most likely have some insight as to why this currently isn't possible.

Regards,
Garrett
Reply
#5
My best guess effort above was a pretty crappy solution Smile Here's two much better options:

1. The resource-hog, delay volume change method: notice the sad face Sad
Basically, change a property (like volume) with your remote and poll that value with a service addon
Code:
class ExitMonitor(xbmc.Monitor):
    def onAbortRequested(self):
        sys.exit()

def getVolume():
    query = '{"jsonrpc": "2.0", "method": "Application.GetProperties", "params": "volume", "id": 1}' # Probably wrong
    result = xbmc.executeJSONRPC(query)
    # etc

monitor = ExitMonitor()
volume = getVolume()

while (True):
    newVolume = getVolume()
    if volume != newVolume:
        # like a g6
    volume = newVolume
    xbmc.sleep(X) # lag vs system load



2. The "hardcore" option. plain and simple, chicks dig guys who compile their own XBMC
Apply a patch: github.com/garbear/xbmc/commit/dffd96e
Compile XBMC
Code:
class VolumeMonitor(xbmc.Monitor):
    def onVolumeChanged(self, volume):
        volume = int(volume) # Too lazy to convert in C++
        # get high like planes
    
    def onAbortRequested(self):
        sys.exit()
Reply

Logout Mark Read Team Forum Stats Members Help
add json-rpc method in an addon ?0