From 8197b17e709ab4cf000ea89509827354ce770526 Mon Sep 17 00:00:00 2001 From: albaintor <118518828+albaintor@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:54:02 +0200 Subject: [PATCH] Fixes and tested OK --- README.md | 2 +- intg-kodi/const.py | 4 +++- intg-kodi/remote.py | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 04c0aa6..42ceb05 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Supported commands for Media Player entity : Supported commands for Remote entity : -- Send command : commands are sent as R1 commands in JSON RPC (see https://kodi.wiki/view/List_of_keynames for the list of available commands) +- Send command : commands are sent as KB keymap commands in JSON RPC (see [Kodi keyboard map](https://github.com/xbmc/xbmc/blob/master/system/keymaps/keyboard.xml) for the list of available commands) - Send command sequence (same commands as above) - Simple commands (same as media player + media player commands) diff --git a/intg-kodi/const.py b/intg-kodi/const.py index 17c4b97..5256654 100644 --- a/intg-kodi/const.py +++ b/intg-kodi/const.py @@ -98,7 +98,9 @@ class BUTTON_KEYMAP(TypedDict): # Taken from https://kodi.wiki/view/List_of_keynames, -# For remote buttons see https://github.com/xbmc/xbmc/blob/master/system/keymaps/remote.xml +# For remote buttons : +# see https://github.com/xbmc/xbmc/blob/master/system/keymaps/remote.xml for R1 keymap or +# see https://github.com/xbmc/xbmc/blob/master/system/keymaps/keyboard.xml for KB keymap KODI_BUTTONS_KEYMAP: dict[str, BUTTON_KEYMAP] = { Commands.CHANNEL_UP: {"button": "pageplus", "keymap": "R1"}, # channelup or pageup Commands.CHANNEL_DOWN: {"button": "pageminus", "keymap": "R1"}, # channeldown or pagedown diff --git a/intg-kodi/remote.py b/intg-kodi/remote.py index 4520c3a..dac22fd 100644 --- a/intg-kodi/remote.py +++ b/intg-kodi/remote.py @@ -102,8 +102,12 @@ async def command(self, cmd_id: str, params: dict[str, Any] | None = None) -> St res = await self._device.command_action(KODI_SIMPLE_COMMANDS[cmd_id]) elif cmd_id == Commands.SEND_CMD: command = params.get("command", "") - holdtime = params.get("hold", 0) - res = await self._device.command_button({"button": command, "keymap": "R1", "holdtime": holdtime}) + holdtime = params.get("hold", "") + if len(holdtime) > 0: + holdtime = int(float(params.get("hold"))) + else: + holdtime = 0 + res = await self._device.command_button({"button": command, "keymap": "KB", "holdtime": holdtime}) elif cmd_id == Commands.SEND_CMD_SEQUENCE: delay = params.get("delay", 0) commands = params.get("sequence", "").split(",")