Delayed start of addons

Hello,

I have a problem with tvheadend not seeing the recordings.
I have the system booting from SD-Card, the recordings are on a USB HDD.

I suppose the mounting of the volume happens after tvheadend is started.
I was able to solve this issue by setting a Delay of 10s in Tvheadend Addon-Settings.

Now the next problem is that I have to restart the Tvheadend HTSP Client
I can’t find an option for startup delay.
Is there another way to get this working?

Regards
Andy

1 Like

You can set a delay in coreelec-network settings.
/edit: i see you already set a value.This makes kodi start after network becomes active and should fix it. Try to increase the number of seconds kodi should wait for network.

You can try creating file /storage/.kodi/userdata/autoexec.py and if doesn’t work try changing first sleep time.

import xbmc
import time

time.sleep(10)

# disable and enable addon
jsonCmd = '{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.hts","enabled":false}}'
jsonRv = xbmc.executeJSONRPC(jsonCmd)

time.sleep(1)

jsonCmd = '{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.hts","enabled":true}}'
jsonRv = xbmc.executeJSONRPC(jsonCmd)

You could delay starting kodi until USB disk is mounted with some loop in autostart.sh file. Then pvr client doesn’t need to be restarted.

Thanks, this made it work!

If network delay wasn’t successful, I’d have tried editing
/usr/lib/systemd/system/kodi-autostart.service.
This line

ConditionPathExists=/storage/.config/autostart.sh

be used to wait for a USB storage, like

ConditionPathExists=/var/media/USBHDD/recordings

Unfortunately the file can’t be saved:

[ File ‘/usr/lib/systemd/system/kodi-autostart.service’ is unwritable ]

The best solution would be to just make the addons wait for the storage.
Anybody knows how to do this?

cp /usr/lib/systemd/system/kodi-autostart.service /storage/.config/system.d
and edit file /storage/.config/system.d/kodi-autostart.service

But I doubt this would work because autostart will be just skipped.

Put this in autostart.sh and it will delay starting kodi until path exist. Or 15 sec max.

cnt=1
while [ $cnt -lt 15 ]; do
  if [ -d /var/media/USBHDD/recordings ]; then
    sleep 2
    break
  fi
  
  let cnt=cnt+1 
  sleep 1
done

Also create folder /storage/.kodi/addons/driver.dvb.delay_mount/bin and create file /storage/.kodi/addons/driver.dvb.delay_mount/bin/userspace-driver.sh with content

cnt=1
while [ $cnt -lt 15 ]; do
  if [ -d /var/media/USBHDD/recordings ]; then
    break
  fi
  
  let cnt=cnt+1 
  sleep 1
done

This will delay starting tvheadend addon until path exist.

One other option would be to restart PVR client from userspace-driver.sh.

1 Like