JSONRPC.NotifyAll resquest sent but no call to onNotification of custom monitor
#1
JSONRPC.NotifyAll resquest sent but onNotification method of custom monitor class doesn't seem to be called. Is there any specific things to do?
Reply
#2
usually expect to see this with a malformed JSON RPC call

can you share the JSON you are using to invoke NotifyAll?
Reply
#3
def notifyTestAddon(self, data):
        """
        Notify the TestAddon addon with data.
        
        Args:
            data (dict): Data to send to the TestAddon addon.
        
        Returns:
            bool: True if the notification was successful, False otherwise.
        """
        logger.info("notifyTestAddon called")
        try:
            # Encode the data as JSON
            testaddon_data = json.dumps(data)

            # Create the JSON-RPC request
            jsonrpc_request = {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "JSONRPC.NotifyAll",
                "params": {
                    "sender": 'plugin.video.kodiconnect.SIGNAL',
                    "message": 'testaddon_data',
                    "data": [testaddon_data],
                }
            }
            request = json.dumps(jsonrpc_request)
            response = xbmc.executeJSONRPC(request)
            response = json.loads(response)
            
            if response.get('result') == 'OK':
                logger.info("Data successfully notified to TestAddon.")
                return True
            else:
                logger.error("Failed to notify data to TestAddon. Response: %s", response)
                return False

        except Exception as e:
            logger.error(f"Error in notifyTestAddon: {e}")
            return False
Reply
#4
In logfile: "Data successfully notified to TestAddon"
Reply
#5
The data variable contains videofilter from kodiconnect.
Reply
#6
had to fake my own data but it appears to work, maybe it's on the monitor side

created a generic py to output the JSON (outside of kodi)

Code:
import json
data = {'test': 'data'}
testaddon_data = json.dumps(data)
jsonrpc_request = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "JSONRPC.NotifyAll",
    "params": {
        "sender": 'plugin.video.kodiconnect.SIGNAL',
        "message": 'testaddon_data',
        "data": [testaddon_data],
    }
}
request = json.dumps(jsonrpc_request)
print(request)

output is this

Code:
{"jsonrpc": "2.0", "id": 1, "method": "JSONRPC.NotifyAll", "params": {"sender": "plugin.video.kodiconnect.SIGNAL", "message": "testaddon_data", "data": ["{\"test\": \"data\"}"]}}

i sent it to kodi while listening with a generic monitor service

Code:
import xbmc

class Monitor(xbmc.Monitor):
    def __init__(self, **kwargs):
        xbmc.Monitor.__init__(self)

    def onNotification(self, sender, method, data):
        xbmc.log("Monitor: sender %s, method: %s, data: %s" % (sender, method, data),level=xbmc.LOGINFO)

xbmcmon = Monitor()

while not xbmcmon.abortRequested():
    xbmcmon.waitForAbort(10)

del xbmcmon

and the log reflects that the monitor received the notification

info <general>: Monitor: sender plugin.video.kodiconnect.SIGNAL, method: Other.testaddon_data, data: ["{\"test\": \"data\"}"]
Reply

Logout Mark Read Team Forum Stats Members Help
JSONRPC.NotifyAll resquest sent but no call to onNotification of custom monitor0