Help to remap Vero 4k+ remote

Hello,
I am remapping the vero 4k+ remote for my vero4k+_oppo project. All is going well, but I have an annoyance when using the vero 4k+ remote controlling the oppo. There is a delay of approximately 5 seconds from button press to action. And my kodi.log shows a WARNING containing this, which I believe is the delay I am seeing in the triggered action.

WARNING : CPythonInvoker(13): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.

My remote.xml file located inside /.kodi/userdata/leymaps/ is the following.

<keymap>
  <global>
    <keyboard>
      <volume_up>Runscript(/home/osmc/.kodi/addons/webostv_oppo/remote_menu.py)</volume_up>
      <volume_down>Runscript(/home/osmc/.kodi/addons/webostv_oppo/remote_topmenu.py)</volume_down>
      <stop>Runscript(/home/osmc/.kodi/addons/webostv_oppo/remote_stop.py)</stop>
    </keyboard>
  </global>
</keymap>

My addon.xml file inside /webostv_oppo/ is as follows.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="webostv" name="webostv" version="1.0.0" provider-name="tcd">
    <extension point="xbmc.python.script" library="playback.py">
        <provides>video</provides>
        <requires>
            <import addon="xbmc.python" version="3.0.0"/>
        </requires>
    </extension>
    <extension point="xbmc.python.script" library="webostv.py"/>
    <extension point="xbmc.python.script" library="connect.py"/>
    <extension point="xbmc.python.script" library="hdmi1.py"/>
    <extension point="xbmc.python.script" library="remote_stop.py"/>
    <extension point="xbmc.python.script" library="remote_topmenu.py"/>
    <extension point="xbmc.python.script" library="remote_menu.py"/>
    <extension point="xbmc.addon.metadata">
    <summary lang="en">LG webos TV control</summary>
    <description lang="en">control lg webos tv with kodi</description>
    <platform>all</platform>
  </extension>
  <disclaimer>
    <p>This addon uses the pywebostv library to control LG webOS TVs</p>
  </disclaimer>
</addon>

How can I run this remote.xml properly ?

Any help or suggestions are greatly appreciated. Thank you

That is a very strange way to organize an addon. Honestly, I’m not sure it’s really even technically a valid addon. You seem to have mixed several things together. Does this really provide video? If not you should claim it does. That puts it in the wrong place in Kodi. It looks like you’re trying to call each script separately, but that isn’t really how addons work. You need to have the addon load the right thing based on some extra info when you run the addon. Take a look at Audio Profiles to see how that might work.

https://kodi.wiki/view/Add-on:Audio_Profiles

As for the delay, Kodi has to load an entire Python interpreter each time an addon is run, so that adds some time to things. If you want faster response, you might have to look at a service addon instead. That would load the addon at startup and then have it listen for events. Audio Profiles has that as well.

None of this is straight forward if you’ve never written Kodi addons, and you really can’t get a tutorial via a forum on it. You might be better off looking for ways to run the Python scripts separate from Kodi.

to my understanding "video"is just a categorization for kodi (video addon). But I may wrong.

My playback.py script launches the video selected for playback in kodi and takes the base_name path and sends it as a http get request to my oppo.
Connect.py is wrapped and called by my playback.py script after the http get request is sent. Connect.py switches my LG C1 source to HDMI 3 (my oppo).
remote_stop.py is triggered when I press STOP, also sending a http get request to my oppo, triggering the Oppo IP control command STOP. hdmi1.py is also wrapped and called at this time (setting LG C1 source back to hdmi1 (Vero 4k+).

What this does for me, is provide a GUI Kodi frontend and and all playback occurs on my Oppo 203 and hdmi sources are automatically switched via the LG webostv API.

My only annoyances are they remote.xml button remapping scripts. The warning I am getting says they are not associated with an addon. And the remoe.xml remapping is the only place where I am seeing a delay. My webostv_oppo scripts run instanteously.
I’m just wondering how I would go about setting remote.xml so the scripts I am calling are assoicated with an addon.

The way you have your stuff setup, there is no change to remote.xml that will ever magically associate those scripts with an add-on because they aren’t part of any add-on. They are just random scripts that happen to be in an add-on directory. If you want them to be part of the add-on, they have to be part of the add-on. You would call the add-on with an extra parameter that would tell it what to do.

I would really encourage you to look at the example I provided. Audio Profiles takes a parameter when you run it and does something with that information. You could do something similar and end up with something like this:

<keymap>
  <global>
    <keyboard>
      <volume_up>Runscript(webostv,'remote_menu')</volume_up>
      <volume_down>Runscript(webostv,'remote_topmenu')</volume_down>
      <stop>Runscript(webostv,'stop')</stop>
    </keyboard>
  </global>
</keymap>

edit I’m realizing there is something else that you might not know about addons. The extension point says to Kodi, “when I call this this a certain way, here’s the py file to run.” You can only have one entry per extension point. Your add-on can have different extension points for, say, a service versus a script (as Audio Profiles does), but not more than one per extension point. In your case, all the extension points after playback are ignored because you’ve already defined the xbmc.python.script to use playback.py.

I will dig into the audio res profiles later today, but after reading your response, i got an idea. I created a new addon, where remote_stop.py, remote_topmenu.py and remote_menu.py exist, i copied hdmi1.py over and created a new addon.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="remote_handler" name="Remote Handler" version="1.0.0" provider-name="tcd">
    <extension point="xbmc.python.script" library="remote_stop.py"/>
    <extension point="xbmc.python.script" library="remote_menu.py"/>
    <extension point="xbmc.python.script" library="remote_topmenu.py"/>
    <extension point="xbmc.python.script" library="hdmi1.py"/>
    <extension point="xbmc.addon.metadata">
        <summary lang="en">Remote Handler</summary>
        <description lang="en">Handles remote key presses</description>
        <platform>all</platform>
    </extension>
    <requires>
        <import addon="xbmc.python" version="3.0.0"/>
    </requires>
</addon>

in my remote_stop.py

import requests
import hdmi1

url = "http://192.168.1.100:436/sendremotekey?%7B%22key%22%3A%22STP%22%7D"

response = requests.get(url)

hdmi1.set_source1()

and finally in my /userdata/keymaps/remote.xml

<keymap>
  <global>
    <keyboard>
      <volume_up>RunScript(remote_handler,remote_menu)</volume_up>
      <volume_down>RunScript(remote_handler,remote_topmenu)</volume_down>
      <stop>RunScript(remote_handler,remote_stop)</stop>
    </keyboard>
  </global>
</keymap>

This remote_handler addon in conjunction with my webostv_oppo addon now results in instanteous playback, hdmi switching, stopping and hdmi switching!!! Brilliant.

I have been working on this project for 1 month, learning python and subsequently kodi addons from scratch.

I next plan on only having the remote.xml initilize after the playback.py is run, as i intend to remap all of the vero buttons to be http get requests to the oppo. I understand as of now is setting the remaps from reboot for the entire system, but I will look around and see if i can figure it out.

Any hints?
Thank you for your responses @pkscout

Correction, I believe I made a mistake. remote_stop.py was being called for each keymap button press. I went back and followed your suggestion of audio profiles and arguments passed to the individual script. I removed the remote_stop.py, remote_menu.py and remote_topmenu.py from the addon.xml. Created remote_handler.py

import sys
import os

def run(arg1):
    if arg1 == "remote_menu":
        os.system("python /home/osmc/.kodi/addons/remote_handler/remote_menu.py")
    elif arg1 == "remote_topmenu":
        os.system("python /home/osmc/.kodi/addons/remote_handler/remote_topmenu.py")
    elif arg1 == "remote_stop":
        os.system("python /home/osmc/.kodi/addons/remote_handler/remote_stop.py")

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Error: Invalid number of arguments.")
    else:
        run(sys.argv[1])

It now appears, I have the remote.xml passing the arguments to the script and thus am now cxontrolling the oppo with the vero 4k+ remote. Onto the project element:)