[Solved] Keymap Problems

I have a Panasonic TV and remote.
I have been trying to get a keymap to work and have spent too much time on it banging my head against the wall.
What I am trying to achieve is when the “AV” button is pressed I want OSMC to either stay on the screen it is on, or go to the Main Menu screen.
The code for the AV button is 249. Here is my last attempt

cat .kodi/userdata/keymaps/gen.xml

<keymap><global><keyboard><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="11">select</key><key id="216">back</key><key id="249">ActivateWindow(startwindow)</key></keyboard></global></keymap>
  <Home>
    <keyboard>
      <key><key id="249">ActivateWindow(home)</key>
    </keyboard>
  </Home>

I have been using the Keymap Editor addon to generate this keymap, and when that provided a keymap that didn’t do what I wanted, I added the bits. It still didn’t work.

Here is the log for my last attempt

2021-08-22 11:09:40.649 T:461     DEBUG <general>: PushCecKeypress - received key f9 duration 0
2021-08-22 11:09:40.659 T:398     DEBUG <general>: HandleKey: 249 (0xf9, obc6) pressed, action is activatewindow(home)
2021-08-22 11:09:40.659 T:398     DEBUG <general>: Activating window ID: 10000
2021-08-22 11:09:40.915 T:398     DEBUG <general>: ------ Window Deinit (Settings.xml) ------
2021-08-22 11:09:40.915 T:398     DEBUG <general>: FreeVisualisation() done
2021-08-22 11:09:40.958 T:398     DEBUG <general>: ------ Window Init (Home.xml) ------
2021-08-22 11:09:40.978 T:398     DEBUG <general>: [Warning] CGUITextureManager::GetTexturePath: could not find texture 'noop'
2021-08-22 11:09:40.995 T:17848   DEBUG <general>: Thread LanguageInvoker start, auto delete: false
2021-08-22 11:09:40.995 T:17848    INFO <general>: initializing python engine.
2021-08-22 11:09:40.996 T:17848   DEBUG <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): start processing
2021-08-22 11:09:40.996 T:17849   DEBUG <general>: Thread Timer start, auto delete: false
2021-08-22 11:09:41.267 T:17848   DEBUG <general>: -->Python Interpreter Initialized<--
2021-08-22 11:09:41.267 T:17848   DEBUG <general>: 
                                                   
2021-08-22 11:09:41.267 T:17848   DEBUG <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): the source file to load is "/home/osmc/.kodi/addons/script.skinshortcuts/default.py"
2021-08-22 11:09:41.267 T:17848   DEBUG <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): setting the Python path to /home/osmc/.kodi/addons/script.skinshortcuts:/home/osmc/.kodi/addons/script.module.simpleeval/lib:/home/osmc/.kodi/addons/script.module.unidecode/lib:/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages
2021-08-22 11:09:41.268 T:17848   DEBUG <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): entering source directory /home/osmc/.kodi/addons/script.skinshortcuts
2021-08-22 11:09:41.268 T:17848   DEBUG <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): instantiating addon using automatically obtained id of "script.skinshortcuts" dependent on version 3.0.0 of the xbmc.python api
2021-08-22 11:09:41.500 T:17849   DEBUG <general>: Thread Timer 1391456448 terminating
2021-08-22 11:09:43.583 T:17848   DEBUG <CAddonSettings[script.skinshortcuts]>: trying to load setting definitions from old format...
2021-08-22 11:09:43.592 T:17850   DEBUG <general>: Thread Timer start, auto delete: false
2021-08-22 11:09:43.592 T:17848    INFO <general>: CPythonInvoker(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): script successfully run
2021-08-22 11:09:43.592 T:17848   DEBUG <general>: onExecutionDone(144, /home/osmc/.kodi/addons/script.skinshortcuts/default.py)
2021-08-22 11:09:43.619 T:17850   DEBUG <general>: Thread Timer 1391456448 terminating
2021-08-22 11:09:43.619 T:17851   DEBUG <general>: Thread Timer start, auto delete: false
2021-08-22 11:09:43.645 T:17851   DEBUG <general>: Thread Timer 1391456448 terminating
2021-08-22 11:09:43.646 T:17852   DEBUG <general>: Thread Timer start, auto delete: false
2021-08-22 11:09:44.150 T:17852   DEBUG <general>: Thread Timer 1391456448 terminating
2021-08-22 11:09:44.339 T:17848    INFO <general>: Python interpreter stopped
2021-08-22 11:09:44.339 T:17848   DEBUG <general>: Thread LanguageInvoker 1136652480 terminating
2021-08-22 11:09:48.179 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:48.206 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:48.274 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 94
2021-08-22 11:09:48.819 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:48.842 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:48.915 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 95
2021-08-22 11:09:49.159 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:49.175 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:49.255 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 96
2021-08-22 11:09:49.498 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:49.508 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:49.595 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 96
2021-08-22 11:09:49.879 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:49.908 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:49.974 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 95
2021-08-22 11:09:50.408 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 0
2021-08-22 11:09:50.458 T:398     DEBUG <general>: HandleKey: 166 (0xa6, obc89) pressed, action is up
2021-08-22 11:09:50.504 T:461     DEBUG <general>: PushCecKeypress - received key a6 duration 96
2021-08-22 11:09:52.608 T:461     DEBUG <general>: PushCecKeypress - received key a8 duration 0
2021-08-22 11:09:52.611 T:398     DEBUG <general>: HandleKey: 168 (0xa8, obc87) pressed, action is right
2021-08-22 11:09:52.704 T:461     DEBUG <general>: PushCecKeypress - received key a8 duration 96
2021-08-22 11:09:54.571 T:461     DEBUG <general>: PushCecKeypress - received key f9 duration 0
2021-08-22 11:09:54.604 T:398     DEBUG <general>: HandleKey: 249 (0xf9, obc6) pressed, action is ActivateWindow(Weather)
2021-08-22 11:09:54.604 T:398     DEBUG <general>: Activating window ID: 12600
2021-08-22 11:09:54.839 T:398     DEBUG <general>: ------ Window Deinit (Home.xml) ------
2021-08-22 11:09:54.840 T:398     DEBUG <general>: FreeVisualisation() done
2021-08-22 11:09:54.875 T:398     DEBUG <general>: ------ Window Init (MyWeather.xml) ------
2021-08-22 11:09:54.875 T:398     DEBUG <general>: [Warning] CGUITextureManager::GetTexturePath: could not find texture 'noop'
2021-08-22 11:09:54.912 T:17854   DEBUG <general>: Thread JobWorker start, auto delete: true
2021-08-22 11:09:54.913 T:17854   ERROR <general>: DoWork - Direct texture file loading failed for resource://resource.images.weathericons.default/.png
2021-08-22 11:09:54.913 T:17854   DEBUG <general>: GetImageHash - unable to stat url resource://resource.images.weathericons.default/.png
2021-08-22 11:10:02.929 T:461     DEBUG <general>: PushCecKeypress - received key d8 duration 0
2021-08-22 11:10:02.958 T:398     DEBUG <general>: HandleKey: menu (0xd8) pressed, action is PreviousMenu
2021-08-22 11:10:02.958 T:398     DEBUG <general>: CGUIWindowManager::PreviousWindow: Deactivate
2021-08-22 11:10:03.145 T:461     DEBUG <general>: PushCecKeypress - received key d8 duration 217
2021-08-22 11:10:03.164 T:398     DEBUG <general>: ------ Window Deinit (MyWeather.xml) ------
2021-08-22 11:10:03.165 T:398     DEBUG <general>: FreeVisualisation() done
2021-08-22 11:10:03.208 T:398     DEBUG <general>: CGUIWindowManager::PreviousWindow: Activate new
2021-08-22 11:10:03.208 T:398     DEBUG <general>: ------ Window Init (Home.xml) ------
2021-08-22 11:10:03.228 T:398     DEBUG <general>: [Warning] CGUITextureManager::GetTexturePath: could not find texture 'noop'
2021-08-22 11:10:03.246 T:17855   DEBUG <general>: Thread LanguageInvoker start, auto delete: false
2021-08-22 11:10:03.246 T:17855    INFO <general>: initializing python engine.
2021-08-22 11:10:03.246 T:17855   DEBUG <general>: CPythonInvoker(145, /home/osmc/.kodi/addons/script.skinshortcuts/default.py): start processing
2021-08-22 11:10:03.247 T:17856   DEBUG <general>: Thread Timer start, auto delete: false
2021-08-22 11:10:03.517 T:17855   DEBUG <general>: -->Python Interpreter Initialized<--
2021-0

As you can see the initial press of AV resulted in

2021-08-22 11:09:40.659 T:398     DEBUG <general>: HandleKey: 249 (0xf9, obc6) pressed, action is activatewindow(home)

But the next press gave me

2021-08-22 11:09:54.604 T:398     DEBUG <general>: HandleKey: 249 (0xf9, obc6) pressed, action is ActivateWindow(Weather)

Can any help me solve this issue. I am obviously missing something.

Syntax error. Get rid of the first <key>, so the line looks like:

<key id="249">ActivateWindow(home)</key>

No - That didn’t work.

I never know for sure what is case sensitive and what isn’t, but you might try:

ActivateWindow(Home)

I have a bash script that uses kodi-send to “reset” Kodi at night so that I’m always at the same state each morning, and that’s the command I use to do what you’re trying to do.

Frustrated again - I don’t think it was that, tried it and still going to Weather.

Despite a promise to myself that I wouldn’t spend any more time on this. I have to some extent succeeded.

<keymap><home><keyboard><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="251">info</key><key id="216">contextmenu</key><key id="249">activatewindow(home)</key><key id="11">select</key></keyboard></home><global><keyboard><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="11">select</key><key id="216">back</key><key id="249">activatewindow(home)</key><key id="251">info</key><key id="252">contextmenu</key></keyboard></global></keymap>

This keymap does not go to the Weather but opens up the (I think) Context Menu.

So the question changes to can I change the keyid=“249” to a null activity, if so how?

If ActiveWindow(Home) is going to Weather, then there is something else wrong that has nothing to do with keymaps. Do you have Kodi set to startup on the Weather screen? I haven’t looked at how that setting affects windows, but I guess it’s possible that changing the startup screen makes that the Home window. I don’t think that’s true, but I can’t for the life of me figure how ActivateWindow(Home) would get you to Weather. I’d recommend backing you your custom keymap, deleting it, and starting over and add one remote command at a time.

Using my latest keymap I now get the context menu when the AV button is pressed.
The showing of the weather screen has always been a problem even under Kodi 18. There I was using the OSMC supplied keymap. It was only on reading this old post [RESOLVED] Disable a specific TV remote control key that I decided to try and build my own keymap, ohh and because Kodi 19 must have changed the keymap and some of the buttons that did work under Kodi 18 didn’t after the Kodi 19 install.

Well I have it working now. I have set the keyid=249 to “noop” so nothing happens except the TV displays the list of AV sources. Exactly what I want.
Here is the working keymap:

<keymap><home><keyboard><key id="249">noop</key><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="251">info</key><key id="252">contextmenu</key><key id="11">select</key><key id="216">back</key></keyboard></home><music><keyboard><key id="249">noop</key><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="251">info</key><key id="252">contextmenu</key><key id="11">select</key><key id="216">back</key></keyboard></music><global><keyboard><key id="249">noop</key><key id="169">left</key><key id="168">right</key><key id="166">up</key><key id="167">down</key><key id="251">info</key><key id="252">contextmenu</key><key id="11">select</key><key id="216">back</key><key id="216">previousmenu</key></keyboard></global></keymap>