Skip to content

Commit

Permalink
fix(kodi-idle-time): Send proper request
Browse files Browse the repository at this point in the history
This commit fixes a syntax error in the request sent to Kodi in the
KodiIdleTime check. A sample request from autosuspend is following:
{{"jsonrpc": "2.0", "id": 1, "method": "XBMC.GetInfoBooleans","params": {"booleans": ["System.IdleTime(300)"]}}

It has a surplus opening curly brace at the beginning, leading Kodi to
ignore the request with the following log entry:
error <general>: JSONRPC: Failed to parse [the above request]

This leads to the following exception in autosuspend:
autosuspend.Processor - WARNING - Check kodi-browsing[class=KodiIdleTime] failed. Ignoring...
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/autosuspend/checks/kodi.py", line 93, in check
    if not reply["result"][f"System.IdleTime({self._idle_time})"]:
           ~~~~~^^^^^^^^^^
KeyError: 'result'
  • Loading branch information
Mynacol committed Sep 18, 2024
1 parent 88f35c3 commit 8bb6dad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/autosuspend/checks/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create(cls, name: str, config: configparser.SectionProxy) -> "KodiIdleTime":

def __init__(self, name: str, url: str, idle_time: int, **kwargs: Any) -> None:
request = url + (
'?request={{"jsonrpc": "2.0", "id": 1, '
'?request={"jsonrpc": "2.0", "id": 1, '
'"method": "XBMC.GetInfoBooleans",'
f'"params": {{"booleans": ["System.IdleTime({idle_time})"]}}}}'
)
Expand Down

0 comments on commit 8bb6dad

Please sign in to comment.