Skip to content

Commit

Permalink
Fixes and tested OK
Browse files Browse the repository at this point in the history
  • Loading branch information
albaintor committed Apr 24, 2024
1 parent 16b6f66 commit 8197b17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion intg-kodi/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions intg-kodi/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
Expand Down

0 comments on commit 8197b17

Please sign in to comment.