XBMC on Pi: Add TV/monitor Power Save support when idle?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
schumi2004 Online
Posting Freak
Posts: 1,445
Joined: Aug 2011
Reputation: 14
Post: #16
Nice script but i'm in a different situation.
I understand the process why and when to power off HDMI but this will still leave my TV on and giving me a NO SIGNAL message.
I do have a simple sleep time script that powers off TV using cec-client, something like this "echo "standby 0" | cec-client -s"
I then use my remote to power on TV etc and that works but it leaves me with a HDMI enabled interface on my RPi when TV is off etc
Any plans to integrate cec-client to power off and on TV and not just shutdown and enable HDMI from RPi ?

Edit:
(2013-12-14 14:30)MilhouseVH Wrote:  <cut> Its primary purpose is to save TV power consumption ..................

<cut>
I think i'm mixing things up. I was under the impression that disabling HDMI interface also would give a significant lower power-consumption on the RPi but it seems it's not but only for connected TV's ?
(This post was last modified: 2013-12-18 23:40 by schumi2004.)
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #17
(2013-12-18 23:27)schumi2004 Wrote:  Nice script but why are there so many lines only to detect for any activity and power off HDMI?
6040!!!! ?

This is just one of many functions the script performs. The script already includes a lot of JSON-RPC logic, so adding this rbphdmi function was a relatively minor addition. Looking at it from the other point of view, you're right it is a lot of code for what it does but now you have it you can do all sorts of other stuff should you need to, without downloading anything else (pre-loading your cache, investigating media library problems etc.).

Obviously this could easily become an addon, in which case this just serves as a "proof of concept" but I don't write addons! Smile

(2013-12-18 23:27)schumi2004 Wrote:  But i'm in a different situation. I understand the process why and when to power off HDMI but this will still leave my TV on and giving me a NO SIGNAL message.
I do have a simple sleep time script that powers off TV using cec-client, something like this "echo "standby 0" | cec-client -s"
I then use my remote to power on TV etc and that works but it leaves me with a HDMI enabled interface on my RPi
Any plans to integrate cec-client to power off and on TV and not just shutdown and enable HDMI from RPi ?

What, and add even MORE lines of code? Smile

I'm inclined not to add specific CEC support. You can however support this yourself if you want, just write a "proxy" script for tvservice and trap the --off and --preferred arguments then do whatever you like with CEC before/after the real tvservice is called. Something like:
Code:
#!/bin/bash

/usr/bin/tvservice $1

case "$1" in
  "--off")       echo "standby 0" | cec-client -s >/dev/null;;
  "--preferred") echo "on 0" | cec-client -s >/dev/null;;
esac
Give your proxy script execute permission, then specify your proxy script when running rbphdmi:
Code:
/storage/texturecache.py @logfile= @xbmc.host=localhost @bin.tvservice=/storage/mytvservice.sh rbphdmi

Now whenever the Pi tries to turn off or on HDMI (or checks the HDMI status with --status) it will call your script and you can handle the CEC stuff there.

(2013-12-18 23:27)schumi2004 Wrote:  I think i'm mixing things up. I was under the impression that disabling HDMI interface also would give a significant lower power-consumption on the RPi but it seems it's not but only for connected TV's ?

It's all about activating the "eco" mode of the connected display device, and absolutely nothing to do with reducing power consumption of the Pi (which is already low as it is).

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
(This post was last modified: 2014-01-01 03:57 by Milhouse.)
find quote
schumi2004 Online
Posting Freak
Posts: 1,445
Joined: Aug 2011
Reputation: 14
Post: #18
@MilhouseVH
Thanks for your detailed explanation.
I think i'll add cec-client stuff because eco mode on my TV doesn't do much besides constant showing NO SIGNAL Wink

Thanks again.
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #19
The thing is all displays are different, I guess. In my test environment, disabling the HDMI is sufficient to disable the backlight and activate "eco" mode. I can imagine it would be quite annoying if after disabling HDMI the backlight remains active just to show "no signal" and then have that burned into the display... If the "proxy" script above works for you then I'll give it some more thought, otherwise it's a fairly simple addition for anyone that requires it. If you make changes to the proxy script in order for it to work (it's untested - I've no CEC support here) then please post back your changes, thanks.

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
find quote
vbat99 Offline
Posting Freak
Posts: 927
Joined: Aug 2009
Reputation: 20
Location: New Zealand
Post: #20
Interested if this would also work in Raspbmc, but to stop XBMC and restart requires
sudo initctl stop xbmc
sudo initctl start xbmc

Any idea's?

It's just a pity there's no suspend on the Pi.

Media Companion Dev.
Media Companion - XBMC Media Companion
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #21
(2013-12-28 22:09)vbat99 Wrote:  Interested if this would also work in Raspbmc, but to stop XBMC and restart requires
sudo initctl stop xbmc
sudo initctl start xbmc

Any idea's?

It's just a pity there's no suspend on the Pi.

rbphdmi uses JSON-RPC to instruct XBMC to quit, calling Application.Quit(), which should work on Raspbmc, effecting a graceful shutdown and exit of the xbmc.bin process. What Raspbmc does once xbmc.bin has terminated I have no idea, I presume it restarts xbmc.bin (which is what OpenELEC does should xbmc.bin crash). There's certainly no need to use OS calls to terminate xbmc.bin in either OpenELEC or Raspbmc.

If Rasbpbmc requires additional support because it doesn't auto-restart xbmc.bin let me know and I'll try and add something (don't use Raspbmc myself).

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
(This post was last modified: 2013-12-28 22:22 by Milhouse.)
find quote
vbat99 Offline
Posting Freak
Posts: 927
Joined: Aug 2009
Reputation: 20
Location: New Zealand
Post: #22
Woah, that was a quick reply.

Might have to have a play and see what happens.

Thanks for speedy reply. Let ya know.

Media Companion Dev.
Media Companion - XBMC Media Companion
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #23
You can test the Raspbmc response to Application.Quit() by executing the following call:
Code:
./texturecache.py power exit
which will send the Application.Quit() call to the XBMC client - hopefully Raspbmc just restarts xbmc.bin in which case the rbphdmi option should work without a hitch.

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
find quote
vbat99 Offline
Posting Freak
Posts: 927
Joined: Aug 2009
Reputation: 20
Location: New Zealand
Post: #24
so I need to do this first to get texturecache file
Code:
curl -Ls http://is.gd/XGXbTG -o /storage/texturecache.py
but Raspbmc doesn't seem to have curl
Code:
pi@raspbmc:~$ curl -Ls http://is.gd/XGXbTG -o /storage/texturecache.py
-bash: curl: command not found

Media Companion Dev.
Media Companion - XBMC Media Companion
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #25
Yes, those instructions are written from an OpenELEC perspective. For Raspbmc, you'll need to use wget in place of curl:
Code:
wget -q http://is.gd/XGXbTG -O ~/texturecache.py
chmod +x ~/texturecache.py

If you get a certificate error, try adding "--no-check-certificate" to the wget command line.

Not sure what mechanism Raspbmc is using to start scripts at boot, maybe a cron (@boot) entry will suffice, with a delay to ensure xbmc has started before starting "~./texturecache.py rbphdmi".

Although in the first instance you probably want to run "~./texturecache.py rbphdmi 30 @bin.tvservice=/path/to/tvservice @debug=yes" at the command line to test things out - this will try to disable HDMI 30 seconds after the GUI screensaver has kicked in. The default path for tvservice on OpenELEC is /usr/bin/tvservice, so specify your own path if it is different on Raspbmc (view the path with "which tvservice")

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
(This post was last modified: 2013-12-28 22:52 by Milhouse.)
find quote
vbat99 Offline
Posting Freak
Posts: 927
Joined: Aug 2009
Reputation: 20
Location: New Zealand
Post: #26
Done and tested.

Yes, Raspbmc does restart, but at almost 40 seconds before XBMC main menu appears, this is one heck of a wait.

May have to re-think things.

Either way, Thanks for your help in getting this on my pi.

Cheers.

Media Companion Dev.
Media Companion - XBMC Media Companion
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #27
(2013-12-28 22:54)vbat99 Wrote:  Yes, Raspbmc does restart, but at almost 40 seconds before XBMC main menu appears, this is one heck of a wait.

Ouch, I wonder why Raspbmc is so slow? Might be worth determining how long it takes xbmc.bin on Raspbmc to shut down - it can be delayed by addons not exiting promptly - or if startup is slow (again due to addons) or if Raspbmc inserts any extra delays before restarting xbmc.bin.

Good to know it works with Raspbmc, albeit slowly - thanks.

(2013-12-28 22:54)vbat99 Wrote:  May have to re-think things.

Indeed, I'd suggest OpenELEC - only 15 seconds to restart xbmc.bin to a usable state (1GHz Pi, Gotham build).

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
(This post was last modified: 2013-12-28 23:12 by Milhouse.)
find quote
Milhouse Offline
Team-Kodi Member
Posts: 4,249
Joined: Jan 2011
Reputation: 95
Post: #28
(2013-12-28 22:54)vbat99 Wrote:  Yes, Raspbmc does restart, but at almost 40 seconds before XBMC main menu appears, this is one heck of a wait.

Just ran a test with Raspbmc, and it inserts a 10 second delay before restarting XBMC in order for the user to start a console. You can eliminate the 10 second delay by commenting out the following line in /scripts/xbmc-watchdog.sh:
Code:
read -sn 1 -t 10 press < /dev/tty1

With the above 10 second delay removed, xbmc on Raspbmc only takes about 5 seconds longer to re-start than OpenELEC (with a 1GHz ARM overclock) - 20 seconds rather than 15 seconds. Maybe it could be added as an option to include the 10 second wait, or not.

Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
(This post was last modified: 2014-01-18 02:06 by Milhouse.)
find quote
vbat99 Offline
Posting Freak
Posts: 927
Joined: Aug 2009
Reputation: 20
Location: New Zealand
Post: #29
(2014-01-18 00:54)MilhouseVH Wrote:  
(2013-12-28 22:54)vbat99 Wrote:  Yes, Raspbmc does restart, but at almost 40 seconds before XBMC main menu appears, this is one heck of a wait.

Just ran a test with Raspbmc, and it inserts a 10 second delay before restarting XBMC in order for the user to start a console. You can eliminate the 10 second delay by commenting out the following line in /scripts/xbmc-watchdog.sh:
Code:
read -sn 1 -t 10 press < /dev/tty1

With the above 10 second delay removed, xbmc on Raspbmc only takes about 5 seconds longer to re-start than OpenELEC (with a 1GHz ARM overclock) - 20 seconds rather than 15 seconds. Maybe it could be added as an option to include the 10 second wait, or not.
Now I have a spare SD card, I'll have a look at Openelec for Raspberry Pi, but I'll note the require changes for future reference. Thanks.

Media Companion Dev.
Media Companion - XBMC Media Companion
find quote
jose1711 Offline
Junior Member
Posts: 6
Joined: Feb 2012
Reputation: 0
Post: #30
thanks for sharing, though for some strange reason XBMC.Quit on my openelec system equals to shutting down the system. so instead of sending that json request i need to do os.system("killall xbmc.bin")
find quote
Post Reply