Solved Unable to add PVR Timer using PVR.AddTimer
#1
I tried out the new function to add PVR Timers but wasn't able to add a new timer. I don't know if it is a bug or if I am doing something wrong.

First I retrieving a list of broadcasts
Code:
http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"PVR.GetBroadcasts","params":{"channelid":11,"limits":{"end":3,"start":0}},"id":29}

Which returns some broadcasts
Code:
{
    "broadcasts": [
        {
            "broadcastid": 217163,
            "label": "La meilleure boulangerie de France"
        },
        {
            "broadcastid": 217165,
            "label": "Chasseurs d'appart'"
        },
        {
            "broadcastid": 217167,
            "label": "Meteo"
        }
    ],
    "limits": {
        "end": 3,
        "start": 0,
        "total": 61
    }
}

Then I tried to add a timer using a broadcast id
Code:
http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"PVR.AddTimer","params":{"broadcastid":217163},"id":33}

It returns an error message
Code:
{
    "code": -32602,
    "message": "Invalid params."
}

I tested using Kodi 17.0-BETA3 from the Ubuntu ppa and as PVR backend I am using tvheadend.
Reply
#2
It is still not possible to add a PVR Timer in the latest release candidate.

I had a short look at the code and could see the following in CPVROperations::AddTimer

The function tries to retrieve the broadcast using the broadcastid however it fails to return the correct entry
Code:
CFileItemPtr broadcast = CPVROperations::GetBroadcastFromBroadcastid(parameterObject["broadcastid"].asUnsignedInteger());

In GetBroadcastFromBroadcastid a EpgSearchFilter is created which is then used to retrieve the entry. Note that only the broadcastid is set in the filter
Code:
EpgSearchFilter filter;
  filter.Reset();
  filter.m_iUniqueBroadcastId = broadcastid;

  CFileItemList broadcasts;
  int resultSize = g_EpgContainer.GetEPGSearch(broadcasts, filter);

At some point GetEPGSearch calls EpgSearchFilter::FilterEntry which returns false for all epg entries since genre, duration etc... have not been set in the filter
Code:
bool EpgSearchFilter::FilterEntry(const CEpgInfoTag &tag) const
{
  return (MatchGenre(tag) &&
      MatchBroadcastId(tag) &&
      MatchDuration(tag) &&
      MatchStartAndEndTimes(tag) &&
      MatchSearchTerm(tag)) &&
      (!tag.HasPVRChannel() ||
       (MatchChannelType(tag) &&
        MatchChannelNumber(tag) &&
        MatchChannelGroup(tag) &&
        (!m_bFTAOnly || !tag.ChannelTag()->IsEncrypted())));
}
Reply
#3
thanks to @ksooo a PR that fixes the issue is on the road Smile

leia: https://github.com/xbmc/xbmc/pull/11506
krypton: https://github.com/xbmc/xbmc/pull/11507
Reply
#4
Thanks for the info. I was able to add a new timer using most recent nightly build Smile
Reply
#5
Hey guys,.is there a json call to just add a timer for the current running live stream?

wants to add an "alexa, tell kodi to record current show" utterance to my custom skill :-)

thx
pOpY
Reply
#6
I had success on getting broadcast ids but cant add timer.

This is what i did:

request:

Code:
[host]:[port]/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 20 }

answer:

Code:
{"id":20,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

ok we got player id and type -> match to type "video" and us playerid for the next request:

Code:
[host]:[port]/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetItem", "params": {"playerid" : 1,"properties":["title", "album", "artist", "season", "episode", "showtitle", "tvshowid", "description"]}, "id": 21 }

answer:

Code:
{"id":21,"jsonrpc":"2.0","result":{"item":{"id":21,"label":"ORF eins HD","title":"IBU Biathlon WM 2017 Hochfilzen: 15km Massenstart Herren","type":"channel"}}}

match the type to channel and id is the channel id for the next request:

Code:
[host]:[port]/jsonrpc?request={"jsonrpc":"2.0","method":"PVR.GetBroadcasts","params":{"channelid":21,"limits":{"end":3,"start":0}},"id":22}

we now got the broadcasts ids:

Code:
{"id":22,"jsonrpc":"2.0","result":{"broadcasts":[{"broadcastid":176977534,"label":"IBU Biathlon WM 2017 Hochfilzen: 4x7,5km Herren Staffel"},{"broadcastid":176977535,"label":"IBU Biathlon WM 2017 Hochfilzen: 4x7,5km Herren Staffel"},{"broadcastid":176977536,"label":"New Girl"}],"limits":{"end":3,"start":0,"total":615}}}

First question, why there are returend three? which one is the current running?
Now ill want to add a timer with the first id:

Code:
    [host]:[port]/jsonrpc?request={"jsonrpc":"2.0","method":"PVR.AddTimer","params":{"broadcastid":176977534},"id":23}

But sadly answer is:

Code:
{"error":{"code":-32100,"message":"Failed to execute method."},"id":23,"jsonrpc":"2.0"}

In the kodi log there is the following entry, regardless of which broadcast id ill throw at it:
Code:
15:01:05.844 T:8388   ERROR: PVR::CPVRTimerInfoTag::CreateFromEpg - end time is in the past

Any hints what i am doing wrong?

PS: using Kodi v17 final

pOpY
Reply
#7
ok got it Angel
It much easier with the "PVR.Record" method.

pOpY
Reply
#8
I can see this is an old thread, but I find myself with exactly the same problem using kodi 19.4.

I want to progrmatically set a timer for any content in my library that is scheduled to show in the future in the pvr guide. Was this ever fixed or is it just not possible to use PVR.AddTimer via JSONRPC?
I can't use PVR.Record as mentioned above as the things I want to set to record are in the future.

Here's what I am trying to do, the broadcastid I'm testing does exist in Epg13.db > epgtags table (iBroadcastUid) and is a future broadcast:

Code:
{"jsonrpc":"2.0","method":"PVR.AddTimer","params":{"broadcastid":1280758},"id":1}

Result:

Code:
{"error":{"code":-32602,"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

Am I doing something wrong, or is there still an isue with adding a pvr timer via JSONRPC?
Reply
#9
I just tested this quickly (19.4 with Kodi Remote code and Enigma LiveTV Addon). PVR.AddTimer generally works, but only once for the same broadcast id. I get the same error as you when I am sending this the second time for the same broadcast id or for an invalid broadcast id. The remote app generally uses PVR.ToggleTimer with the same parameters to set and unset a timer for given broadcast. Maybe this is worth a try as well.
Reply
#10
(2022-09-01, 12:43)Buschel Wrote: I just tested this quickly (19.4 with Kodi Remote code and Enigma LiveTV Addon). PVR.AddTimer generally works, but only once for the same broadcast id. I get the same error as you when I am sending this the second time for the same broadcast id or for an invalid broadcast id. The remote app generally uses PVR.ToggleTimer with the same parameters to set and unset a timer for given broadcast. Maybe this is worth a try as well.

Thanks for the info Buschel.

I can never seem to get it to work with a valid broadcastid. Is this maybe because I am using a python script to execute the JSONRPC call?

I'll look into PVR.ToggleTimer to see if I cn do anything with that.
Thanks
Reply
#11
PVR.ToggleTimer appears to work fine Smile

Thanks for the info Buschel
Reply
#12
Great, thanks for letting me know.
Reply

Logout Mark Read Team Forum Stats Members Help
Unable to add PVR Timer using PVR.AddTimer0