Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14
Linux [RELEASE]Plugin for Timer- and Powermanagement in XBMC/Kodi and TVHeadend
#1
First of all, I’m not shure if this is the right place for announcment or maybe the next subforum (Python development), second I thank nmcaullay for inspiration and parts of source code from his pvruptime-addon (see http://forum.xbmc.org/showthread.php?p=7...post725958) and at least, sorry for my bad english.

Ok lets go!

Download and screenshots you'll find at (new download location): http://vdr4bj1.no-ip.org?item=addon or install it from my repository (see signature)

Description:

The combination of XBMC/Kodi(Buntu) and TVHeadend as backend hasn’t a power or timer management for ongoing and upcoming recordings. A wake-up mechanism for future recordings either under XBMC nor under TVHeadend isn't completed yet or needs several bash scriptings. Therefore I've written a Python-Script, which is registered as a service on XBMCKodi running since Frodo up to actual versions.

The operation of this script can be summarized as follows:

  • a pressure on the power button on the remote control whilest a current or soon upcoming recording is ignored and an appropriate message is shown. After recording and analyzing for next possible timers a wake-up via ACPI or NVRAM (nvram-wakeup must be installed and properly configured) is set and the system shuts down.
  • Every keypress (Play, Pause, Mute, Volume etc.) except power aborts the above mechanism, i.e., the computer don’t poweroff after recording. Power management is turned back on by simply pressing the power button remote again.
  • Before switching off after a timer, an adjustable countdown is shown by progress bar, that can be stopped.
  • Additional network and process monitoring is implemented if needed. Define network ports and/or processes which should monitoring in setup.
  • Is there a timer recording without any user activity occurs (eg. at night / user absent), the system will shut down without notice message after the recording was done and set next wakeup. Before doing this an email is optional delivered to the user.
  • If power button is pressed and there are no upcoming/soon schedules required, the system shuts down immediately, however, timers are set.
The power button on the unit shows the normal behavior, i.e. the device switches off, timers are not set.

"Soon" fitting timers are calculated from:
ACPI: Recording Time < boot time + shutdown time + countdown time -> see screenshot
NVRAM: <11 minutes

Inside the package is a wrapper script (shutdown.sh) that needs some special settings as python itself cannot have root privileges. This is necessary for setting the system clock and shutdown operations.

Therefore: YOU MUST read the README and follow the instructions whitin the package, because there's a lot to be configured (user rights, remote.xml, etc.). Just take a look inside the zipfile.

It would be grateful to inform me about errors, issues or other informations. Be free to contact me in this forum or PM me.

_BJ1

____________________________________________________________________

Current Release: see changelog

Initial Release Oct. 2011

Installation: Copy zip to a directory where XBMC has access. Then: System -> Addons -> Install from zip file -> select location

Next steps for configuration you'll find in the README in this package.
Reply
#2
This is exactly what I need!
I will try it on my htpc rebuild and see how it works.

Thank You!
Reply
#3
I try to use your addon. I have media PC based on ASUS M3N78-EM mainboard. I have problem with PC wake up.
This is the log:
2011-12-20 20:05:32.106721: PVR Manager: next recording in 68 minutes
2011-12-20 20:05:32.106919: PVR Manager: service driven by User
2011-12-20 20:05:32.129694: PVR Manager: Wakeup by ACPI at 2011-12-20 21:13:32.$
2011-12-20 20:05:32.129857: PVR Manager: Instruct the system to shut down
2011-12-20 20:05:34.217110: PVR Manager: service finished
2011-12-20 20:08:20.377772: PVR Manager: next recording in 65 minutes
2011-12-20 20:08:20.389005: PVR Manager: service driven by User
2011-12-20 20:08:20.448837: PVR Manager: no PIDFile, system powered on first ti$
2011-12-20 20:08:20.449872: PVR Manager: service finished
And the time and hwclock:
rtc_time : 20:10:28
rtc_date : 2011-12-20
alrm_time : 20:13:32
alrm_date : 2011-12-20
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1024
max user IRQ frequency : 64
24hr : yes
periodic_IRQ : no
update_IRQ : no
HPET_emulated : yes
BCD : yes
DST_enable : no
periodic_freq : 1024
batt_status : okay
root@Mediapc:/# date
2011. dec. 20., kedd, 20.10.32 CET
root@Mediapc:/# date -u
2011. dec. 20., kedd, 19.10.35 UTC
root@Mediapc:/#

The IRQ not set and the alarm time less than I need.

I try this small script:
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date -d "2011-12-20 21:13:32" +%s` > /sys/class/rtc/rtc0/wakealarm
cat /sys/class/rtc/rtc0/wakealarm
Nothing good:
rtc_time : 20:14:01
rtc_date : 2011-12-20
alrm_time : 20:18:52
alrm_date : 2011-12-20
alarm_IRQ : no

After I try this:
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date -u -d "2011-12-20 21:13:32" +%s` > /sys/class/rtc/rtc0/wakealarm
cat /sys/class/rtc/rtc0/wakealarm

root@Mediapc:~# ./wake_test
1324415612

And the rtc settings are good:
rtc_time : 20:16:01
rtc_date : 2011-12-20
alrm_time : 21:13:32
alrm_date : 2011-12-20
alarm_IRQ : yes
alrm_pending : no

Are there any problem with UTC or local time? I'm not a programmer, and sorry for my english.

Can you help me?
Reply
#4
Yes, you have to set your system to UTC. Is the system powered on with the 'good settings' (wake_test)?

_BJ1

To tell your Ubuntu system that the hardware clock is set to UTC:

1. edit /etc/default/rcS
2. add or change the following section

# Set UTC=yes if your hardware clock is set to UTC (GMT)
UTC=yes
Reply
#5
_BJ1 Wrote:Yes, you have to set your system to UTC. Is the system powered on with the 'good settings' (wake_test)?

_BJ1

To tell your Ubuntu system that the hardware clock is set to UTC:

1. edit /etc/default/rcS
2. add or change the following section

# Set UTC=yes if your hardware clock is set to UTC (GMT)
UTC=yes

Yes. The system started properly.
I set it before this log: UTC= yes, but it does not solve.
Before this try, I change the rtc clock to UTC clock. It does not help. It works only with -u parameter.
The BIOS time is UTC.
Reply
#6
Ok. Will try to find a solution

_BJ1
Reply
#7
Same output as yours:

xbmc@Echnaton:/$ date
Wed Dec 21 17:53:23 CET 2011
xbmc@Echnaton:/$ date -u
Wed Dec 21 16:53:29 UTC 2011
xbmc@Echnaton:/$

But for me it works...

_BJ1

EDIT: Goto : ~/.xbmc/addons/script.program.pvrmanager/resources/lib

and edit the shutdown.sh

Change: echo $2 > /sys/class/rtc/rtc0/wakealarm
to: echo `date -ud @$2` > /sys/class/rtc/rtc0/wakealarm

Hope this works.
Reply
#8
Wow, needed help but no feedback. So I'm trapped in the dark...

_BJ1
Reply
#9
_BJ1 Wrote:Wow, needed help but no feedback. So I'm trapped in the dark...

_BJ1
Wait a minute! I have no time every day to do my hobby.Nod
I change shutdown.sh as you said, but it does not work. I can't shutdown system at all. I changed it back.
After I comment the last line in shutdown.sh. In this way I trying it without really shutdown.
I change the rtc time with "hwclock --localtime" command to localtime. After this the rtc accept the date and time and wake up system. Now, I have one success record. Unfortunately it didn't switch off after the record. I don't understand exactly what was the really solution. I wait some other success records. I think very important the relationship of RTC, local time, BIOS time, UTC.
Thank you for your help!
Reply
#10
fecus Wrote:Unfortunately it didn't switch off after the record. I don't understand exactly what was the really solution. I wait some other success records. I think very important the relationship of RTC, local time, BIOS time, UTC.
Thank you for your help!

Thanks for information. I don't know why it didn't switch off after record. Perhaps a remote key pressing whilest recording? Look into log (pvrmanager.log)
around the poweroff-time...

_BJ1
Reply
#11
The life isn't easy. The ubuntu update files. I never do it again. New xbmc.bin arrived. Now, the xbmc display error with shutdown.sh.:

12:21:18 T:2980039536 ERROR: Error Contents: ('invalid syntax', ('/home/fecus/.xbmc/addons/script.program.pvrmanager/resources/lib/shutdown.sh', 2, 7, 'sleep 2\n'))
12:21:18 T:2980039536 ERROR: SyntaxError: ('invalid syntax', ('/home/fecus/.xbmc/addons/script.program.pvrmanager/resources/lib/shutdown.sh', 2, 7, 'sleep 2\n'))

It doesn't finish the power down.
Reply
#12
It fails on the very first instruction into the shutdown.sh. Are executable rights, owner and group changed for the shutdown.sh? Also, looks the first line like:

#! /bin/sh

?

Merry Christmas.

_BJ1
Reply
#13
_BJ1 Wrote:It fails on the very first instruction into the shutdown.sh. Are executable rights, owner and group changed for the shutdown.sh? Also, looks the first line like:

#! /bin/sh

?

Merry Christmas.

_BJ1

I reinstall, and re-set the rights. Nothing work.
Is it a python interpreter problem?
Reply
#14
fecus Wrote:Is it a python interpreter problem?

The shutdown.sh is an usual shellscript. Who is the user running xbmc? Maybe there are permissions.

_BJ1
Reply
#15
_BJ1 Wrote:The shutdown.sh is an usual shellscript. Who is the user running xbmc? Maybe there are permissions.

_BJ1
It has 3 user : mythtv, fecus, hts
Before upgrade I added the xbmc to autorun programs and clear mythTV frontend. (This was the Mythbuntu install, originally)
I set the rights - as you wrote - for fecus, and everithing work.
After upgrade something change.
In remote.xml:
<power>XBMC.RunScript(script.program.pvrmanager)</power>

visudo:
### XBMC specific configuration ###

# XBMC
Cmnd_Alias PVR_CMDS = /home/fecus/.xbmc/addons/script.program.pvrmanager/resources/lib/shutdown.sh
fecus ALL=NOPASSWD: PVR_CMDS # XBMC

Rights of default.py:
owner: fecus
group: fecus
100755

Rights of shutdown.sh:
owner: fecus
group: fecus
100755

Rights of xbmc.bin:
owner: root
group: root
100755

I don't have more idea.No
I'm sorry for this disturbing and Merry Christmas!
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14

Logout Mark Read Team Forum Stats Members Help
[RELEASE]Plugin for Timer- and Powermanagement in XBMC/Kodi and TVHeadend2