Sleep /Suspend Behaviour
Added by Bill Mackie about 12 years ago
my htpc which runs xbmc is also my tvh server, I have xbmc set to suspend after 30 mins of inactivity which is fine for recording etc and they are honored however, connected clients are not so if on the laptop watching tv I get cut of unitl a wol packet gets sent to the xbmc/tvh box, anyone aware of a way around this?
How does tvh behave outside xbmc eg if it is the system settings suspending rather than xbmc?
Replies (4)
RE: Sleep /Suspend Behaviour - Added by Adam Sutton about 12 years ago
It doesn't, TVH does not concern itself with suspend/resume, that is (as you've demonstrated) the realm of something that has a wider view of the world.
Since there is no unified power manager suspend/resume controller in Linux TVH has no way of informing the system NOT to suspend etc.. The best you can do is to add some form of hook between the power manager of choice (in this case I guess XBMC's internal stuff) and TVH.
I.e. I used to use something could powernap, and it had a set of modules that would define whether activity was present or not. These included things like users logged in (SSH), TCP traffic (on specific ports), and in theory I could have done something to query TVH for recordings etc...
Maybe this is something to take up with the XBMC devs since you're relying on their power management.
Adam
RE: Sleep /Suspend Behaviour - Added by Bill Mackie about 12 years ago
This script is working well, only thing is it is not recording aware:
#!/bin/bash
sleep 30
if [ `netstat -t | grep -c ":9982"` -ge 3 ]
then
exit 1
elif [ `netstat -t | grep -c "192.168.0.:microsoft-ds ESTABLISHED"` -ne 0 ]
then
exit 1
else
echo pm-suspend
fi
it looks for a connection on a port 9982 3 or more times to take account of xbmc running on the same box and having an active connection always and an established connection to my windows machine which only happens when playing my media.
I need to work out how to integrate https://www.lonelycoder.com/redmine/boards/4/topics/906
specifically:
current_date=`date +%s`
for i in $( ls ); do
tmp_start=`cat $i | grep '"start":' | cut -f 2 -d " " | cut -f 1 -d ","`
tmp_stop=`cat $i | grep '"stop":' | cut -f 2 -d " " | cut -f 1 -d ","`
- check for any current recording
if [ $((tmp_stop)) -gt $((current_date)) -a $((tmp_start)) -lt $((current_date)) ]; then
recording=1
fi
done
I think I just need another elif, or maybe move my recordings directory to a windows share and match more instances of microsoft established.
RE: Sleep /Suspend Behaviour - Added by Bill Mackie about 12 years ago
This is working:
#!/bin/bash
cd ~billy/.hts/tvheadend/dvr/log
current_date=`date +%s`
for i in $( ls ); do
tmp_start=`cat $i | grep '"start":' | cut -f 2 -d " " | cut -f 1 -d ","`
tmp_stop=`cat $i | grep '"stop":' | cut -f 2 -d " " | cut -f 1 -d ","`
- check for any current recording
if [ $((tmp_stop)) -gt $((current_date)) -a $((tmp_start)) -lt $((current_date)) ]; then
exit 1
fi
done
if [ `netstat -t | grep -c ":9982"` -ge 3 ]
then
exit 1
elif [ `netstat -t | grep -c "192.168.0.:microsoft-ds ESTABLISHED"` -ne 0 ]; then
exit 1
else
sudo pm-suspend
fi
RE: Sleep /Suspend Behaviour - Added by Adam Sutton about 12 years ago
As mentioned on IRC. What I think would be really cool is to simply integrate TVH recordings info into something like powernap, which is a ready made (modular'ish) power management system that is part of teh Ubuntu Server package set.
Personally I've done work on powernap and this is what I would have done had I not stopped suspend/resume on my NAS box (as newer board is more power efficient and its not worth the startup lag anymore).
Adam