Switch tuners on and off as needed
Added by Max Bey almost 2 years ago
I'm using TVHeadend on Ubuntu 20.04, installed from a deb package from https://apt.tvheadend.org/stable, deb version is 4.2.8-36~g5bdcfd8ac~bionic amd64.
I've been using TVHeadend and Xbmc/Kodi as the TV and PVR solution in my home for the past 10 years. During this time, many cheap USB DVB-S(2) tuners have become broken and had to be replaced. I guess they are not meant to run 24/7. I have finally replaced them with a more expensive Kathrein Sat/IP device with 4 built-in DVB-S2 tuners some 5 years ago, still using it with TVHeadend.
As I did not want to risk this device also dying from 24/7 service (and in order to save energy), I've written a Node-Red flow which switches the SAT/IP device (via a Wifi-controlled power socket) and the TVHeadend service (via systemctl) on and off based on need:
- As long as any Kodi instance in the home runs, TVHeadend runs or is switched on.
- As long as TVHeadend has active "subscriptions", it continues to run. Subscriptions can be streams to users or active recordings and can be detected in http://tvheadend:9981/status.xml
- TVHeadend is kept idle for 1 hour after the last seen usage to allow it to scan EPG, and to be available without waiting time if a user only pauses usage.
- When TVHeadend is switched off, the next planned switch-on time is computed: Either 15 minutes before the next recording, or 24 hours from switch-off for updating the EPG, whichever is earlier.
- If the downtime would be less than 1 hour, nothing is switched off.
My main interest here is switching off the DVB device to save energy and conserve the device. I'm only switching off the tvheadend service, too, to prevent tvheadend from detecting that the DVB device is missing, and panicking.
As I'm currently reorganizing my home network, I would have to adapt the Node-Red flow, and I realize that I do not like working in Node-Red very much anymore. Therefore I would like to replace it.
Before reimplementing the same functionality in another language, I'd like to ask if TVHeadend maybe has something built-in that I can use for my purpose, like- Executing a custom script before using a DVB tuner (allowing me to switch on the Wifi power socket).
- Executing another custom script after the last DVB tuner is released.
- Restrict EPG updates to once (or one hour) per day.