• 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 14
Linux [RELEASE]Plugin for Timer- and Powermanagement in XBMC/Kodi and TVHeadend
#76
Hi,
When are the checks supposed to be executed?
For instance on my computer the last time they have been executed is 23 hours ago:
Code:
07.09.2013 22:43:19: PVR Manager: Check for current recordings... Yes
07.09.2013 22:43:19: PVR Manager: Check for upcoming recordings... No
07.09.2013 22:43:19: PVR Manager: Check for current running EPG-Update... No
07.09.2013 22:43:19: PVR Manager: Check for postprocessors... No
07.09.2013 22:43:19: PVR Manager: Check for network activity... No
07.09.2013 22:43:19: PVR Manager: Found PIDFile with ID 3556 but this should be 4574,
07.09.2013 22:43:19: PVR Manager: XBMC is probably crashed or has been restarted without using me ;).
07.09.2013 22:43:49: PVR Manager: Service polling, monitoring powerbutton/others... No/No
07.09.2013 22:43:49: PVR Manager: Recording of "Les �nigmes du Sphinx" is active.
07.09.2013 22:43:49: PVR Manager: Check for current recordings... Yes
07.09.2013 22:43:49: PVR Manager: Check for upcoming recordings... No
07.09.2013 22:43:49: PVR Manager: Check for current running EPG-Update... No
07.09.2013 22:43:49: PVR Manager: Check for postprocessors... No
07.09.2013 22:43:49: PVR Manager: Check for network activity... No
07.09.2013 22:44:19: PVR Manager: User activty detected.
07.09.2013 22:44:19: PVR Manager: Service finished but will be possibly restarted.
07.09.2013 22:44:19: PVR Manager: ------------------------------------------------
08.09.2013 00:23:20: PVR Manager: Check for current recordings... Yes
08.09.2013 00:23:20: PVR Manager: Check for upcoming recordings... No
08.09.2013 00:23:20: PVR Manager: Check for current running EPG-Update... No
08.09.2013 00:23:20: PVR Manager: Check for postprocessors... No
08.09.2013 00:23:20: PVR Manager: Check for network activity... No
08.09.2013 00:23:51: PVR Manager: Service polling, monitoring powerbutton/others... Yes/No
08.09.2013 00:23:51: PVR Manager: Recording of "Treme" is active.
08.09.2013 00:23:51: PVR Manager: Recording of "Doctor Who" is active.
08.09.2013 00:23:51: PVR Manager: Check for current recordings... Yes
08.09.2013 00:23:51: PVR Manager: Check for upcoming recordings... No
08.09.2013 00:23:51: PVR Manager: Check for current running EPG-Update... No
08.09.2013 00:23:51: PVR Manager: Check for postprocessors... No
08.09.2013 00:23:51: PVR Manager: Check for network activity... No
08.09.2013 00:24:21: PVR Manager: User activty detected.
08.09.2013 00:24:21: PVR Manager: Service finished but will be possibly restarted.
08.09.2013 00:24:21: PVR Manager: ------------------------------------------------

Shouldn't they run on a periodic basis (e.g. every 5 minutes...)?

Thanks!
Reply
#77
The service checks every 30 secs for recordings, epg, postprocessors and network until a user presses a button on remote or keyboard (this is the message 'User activity detected') and the service finished. It comes back by simply pressing the power button on remote or a specific key on keyboard (F12). So the last action _musst_ be pressing the power button. Every other button ('Service polling, monitoring powerbutton/others... Yes/No') rejects the service. Anyway if there isn't a important task active while polling, the service will shut down the system.
Reply
#78
Does that mean that every time you use XBMC, you have to press the Power button at the end, and that if you forget to press it, the service won't shut the system down? This would explain why I have no log in pvrmanager.log for more that 24 hours.
Can't it just run every 30 seconds and keep the system alive is there is user activity? I thought that the power button was to "force" the polling between the scheduled executions of the service.
Thanks
Reply
#79
(2013-09-09, 10:50)spontex Wrote: Does that mean that every time you use XBMC, you have to press the Power button at the end, and that if you forget to press it, the service won't shut the system down?
Yes, this _is_ a normal behaviour of nearly every system (e.g. a video recorder) in your living room. This Addon prevents a system from shutdown if a important task is alive and shutdown it later. But if is user activity detected the service will finished because a user is active (listening music, watching a movie etc.). If you decide you want to go to bed, press power. The system will not shut down until a recording etc. is running...

(2013-09-09, 10:50)spontex Wrote: I thought that the power button was to "force" the polling between the scheduled executions of the service.
No, if there isn't an active task, the power button shutdown the system but will set a wakeup timer (next recording, next epg-update etc.) in your RTC. If your PC wakes up and there isn't any user activity (you're absent) the service will run all the time, check all relevant tasks, set next wakeup and shutdown after all tasks have finished. Thats full automatic mode Wink
Reply
#80
I understand, and I will now press this button.
But XBMC is not "nearly every system", and user activity could be detected in a more elegant way (XBMC already has such a detection mechanism).
Before switching to this plug-in, I was using htpc-wakeup-scheduler which was able to detect the user activity by itself, without any user action required.

Below is the code it was using in order to check for user activity using the XBMC JSON-RPC protocol. Perhaps it could allow to improve this plug-in, so that it is fully automatic:

Code:
# detects
# required setup on XBMC: system/settings/network/
def detectXBMCActive():
  TCP_IP = '127.0.0.1'
  TCP_PORT = 9090

  logging.info('opening socket to %s:%s', TCP_IP, TCP_PORT)

  try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((TCP_IP, TCP_PORT))
    s.send('{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \"id\": 666}')
    players = s.recv(512)
    s.close()
  except IOError as (errno, strerror):
    logging.error("failed to get XBMC status due to - %s (errno: %s)", strerror, errno)
    return False;

  logging.debug("received : %s", players)

  xbmcplayers = json.loads( players )

  # todo check screensaver
  currentlyPlaying = False

  if not 'error' in xbmcplayers:
    print xbmcplayers['result']
    for i, player in enumerate(xbmcplayers['result']):
      logging.debug('Player %s = %s', i, player)
      if player:
        currentlyPlaying = True
        break
  else:
    logging.warn("error detected %s = %s", xbmcplayers['error']['code'], xbmcplayers['error']['message'])

  logging.info("XBMC activity - %s", currentlyPlaying)
  return currentlyPlaying

Regards
Reply
#81
Since xbmc has a property xbmc.getGlobalIdleTime() that is available in plugins/scripts it is not necessary to check activity (or inactivity) from outside via json-rpc. Note that this addon is mainly used in a home theater environment on a dedicated system. If a system has to perform other tasks then xbmc you have to decide if an addon like this really makes sense of coarse.
Reply
#82
Hi,
Yes, this add-on is great!
I only do not understand why you require the user to press the Power button. If the computer is idle for, let's say, 5 minutes, and no recording is active, then you can shut the computer down, no matter the user has pressed this button or not. Do you get what I mean?
Regards
Reply
#83
(2013-09-09, 16:08)spontex Wrote: I only do not understand why you require the user to press the Power button. If the computer is idle for, let's say, 5 minutes, and no recording is active, then you can shut the computer down, no matter the user has pressed this button or not. Do you get what I mean?
Yes I know what you meant but we have different points of view Wink. My addon is initially designed to act like a 'normal' Video-Recorder or PVR-TV. That was the intention as I'm beginnig to write this addon years ago. It's of course possible to implement a 'min User Activity' or 'min Idle Time' like VDR does. This is also implemented by xbmc (energy saving) - but this time you can't use it because its independent/unattached from tvheadend. This will kill your recordings in bad times ;-(

Regards
Reply
#84
Hi,
I understand what you mean, but I think that you could require BOTH user inactivity for e.g. 5 minutes AND the other tests (recordings, network, ...) to shut the computer down. I still don't get it why my computer should stay awake if anyone forgets to press this button. At least, this could be an option.
htpc-wakeup-scheduler uses this idle time information and that works well (of course with less features than this plug-in), with less hassle for the user. Really, you should consider removing the need to press the power button. Don't leave to the user something that can be automated!

Regards
Reply
#85
Hi,
Apparently, the plug-in shuts down my computer but it never wakes up. Wakeup used to work with my previous script, htpc-wakeup-scheduler.
Can it be related to the use of a local time different from the UTC time?

Code:
11.09.2013 00:37:52: PVR Manager: Service polling, monitoring powerbutton/others... Yes/No
11.09.2013 00:37:52: PVR Manager: Check for current recordings... Yes
11.09.2013 00:37:52: PVR Manager: Check for upcoming recordings... No
11.09.2013 00:37:52: PVR Manager: Check for current running EPG-Update... No
11.09.2013 00:37:52: PVR Manager: Check for postprocessors... No
11.09.2013 00:37:52: PVR Manager: Check for network activity... No
11.09.2013 00:38:22: PVR Manager: Service polling, monitoring powerbutton/others... Yes/No
11.09.2013 00:38:23: PVR Manager: Recording of "Luther" has finished.
11.09.2013 00:38:23: PVR Manager: Check for current recordings... No
11.09.2013 00:38:23: PVR Manager: Check for upcoming recordings... No, next schedule in 140 mins.
11.09.2013 00:38:23: PVR Manager: Check for current running EPG-Update... No
11.09.2013 00:38:23: PVR Manager: Check for postprocessors... No
11.09.2013 00:38:23: PVR Manager: Check for network activity... No
11.09.2013 00:38:23: PVR Manager: Init countdown, system will shut down in 300 secs.
11.09.2013 00:38:23: PVR Manager: Display countdown message.
11.09.2013 00:43:24: PVR Manager: EPG-Update interval is set to 2 days.
11.09.2013 00:43:24: PVR Manager: Wakeup for Recording by ACPI at 11.09.2013 02:56:00 (UNIX-Time: 1378860960).
11.09.2013 00:43:29: PVR Manager: Instruct the system to shut down.
11.09.2013 00:43:31: PVR Manager: Service finished but will be possibly restarted.
11.09.2013 00:43:31: PVR Manager: ------------------------------------------------

11.09.2013 00:59:01: PVR Manager: Check for current recordings... No
11.09.2013 00:59:02: PVR Manager: Check for upcoming recordings... No, next schedule in 119 mins.
11.09.2013 00:59:02: PVR Manager: Check for current running EPG-Update... No
11.09.2013 00:59:02: PVR Manager: Check for postprocessors... No
11.09.2013 00:59:02: PVR Manager: Check for network activity... 1 connection(s)
11.09.2013 00:59:02: PVR Manager: No PIDFile found, system powered on first time.
11.09.2013 00:59:32: PVR Manager: Service polling, monitoring powerbutton/others... No/No
11.09.2013 00:59:33: PVR Manager: Check for current recordings... No
11.09.2013 00:59:33: PVR Manager: Check for upcoming recordings... No, next schedule in 119 mins.
11.09.2013 00:59:33: PVR Manager: Check for current running EPG-Update... No
11.09.2013 00:59:33: PVR Manager: Check for postprocessors... No
11.09.2013 00:59:33: PVR Manager: Check for network activity... No
11.09.2013 00:59:33: PVR Manager: Service was running without any user activity in automatic mode.
11.09.2013 00:59:33: PVR Manager: EPG-Update interval is set to 2 days.
11.09.2013 00:59:33: PVR Manager: Wakeup for Recording by ACPI at 11.09.2013 02:56:00 (UNIX-Time: 1378860960).
11.09.2013 00:59:38: PVR Manager: Instruct the system to shut down.
11.09.2013 00:59:40: PVR Manager: Service finished but will be possibly restarted.
11.09.2013 00:59:40: PVR Manager: ------------------------------------------------
11.09.2013 16:29:38: PVR Manager: Check for current recordings... No
11.09.2013 16:29:38: PVR Manager: Check for upcoming recordings... No, next schedule in 44 mins.
11.09.2013 16:29:38: PVR Manager: Check for current running EPG-Update... No
11.09.2013 16:29:38: PVR Manager: Check for postprocessors... No
11.09.2013 16:29:38: PVR Manager: Check for network activity... No
11.09.2013 16:29:38: PVR Manager: No PIDFile found, system powered on first time.
11.09.2013 16:29:38: PVR Manager: Service finished but will be possibly restarted.

As you can see, the system did shut down at 00:43 but did wake up at 00:59 instead of 02:56.
Then it shuts down at 00:59 and does not wake up (instead of 02:56).
Perhaps is there a 2-hour mismatch between the expected time and the actual time, due to the 2-hour difference between the rtc time and my EPG/local time (I live in France) ? Is there a specific requirement with regard to the local time settings?
Thanks a lot
Reply
#86
(2013-09-11, 17:36)spontex Wrote: Can it be related to the use of a local time different from the UTC time?
...
Perhaps is there a 2-hour mismatch between the expected time and the actual time, due to the 2-hour difference between the rtc time and my EPG/local time (I live in France) ? Is there a specific requirement with regard to the local time settings?

Yes, you have set your BIOS to UTC. See also Post #4 and #5 in this thread.
Reply
#87
Now it works fine! I have edited my rtS file with UTC=yes and I have set my clock to UTC time in BIOS. XBMCbuntu still "corrects" the time and displays the local time, so it is perfect.
The network connections test also works fine.
The only thing left is the power button behaviour :-)
Thank you
Reply
#88
Hello,

Thanks for this addon which is really important for a PVR !
Just a question ...
It seems to work pretty well when I press the F12 touch (keymapped as recommended), then I choose "Suspend" or "Sleep" in main shutdown menu of xbmc.
But It doesn't work when I choose "Stop the system" (in other words: complete shutdown).
Is it the attended behavior ?

Thanks a lot for any advices and precisions.
Reply
#89
(2013-09-27, 16:43)Gulliver Wrote: It seems to work pretty well when I press the F12 touch (keymapped as recommended), then I choose "Suspend" or "Sleep" in main shutdown menu of xbmc.
It isn't necessary to choose an option from xbmc menu, F12 should down the system immedately (if there are no tasks present). You have set the right permissions (see readme)?

Or, you have pressed the F12-key and after that made another keypresses? This will indicate as user activity and the shutdown aborts. The very well last key must be the poweroff (F12) key...
Reply
#90
Hello BJ1,

As a matter of fact, it seems I've got a problem on he shutdown.
If a creae a timer, then, I press F12, the system tells me a timer is setted but no shutdown.
If I suspend o ram or disk, the system wakes up and proceed the timer.

Right for shutdown.sh seems good: 755 wih may user in owner and group.
And with visudo:
"my-user" All=NOPASSWD: PVR_CMDS

I'm going to try to write the command withou using an alias.

Thanks.

pvrmanager.log is quite light:

28.09.2013 13:14:11: Wakeup for Recording by ACPI at 28.09.2013 14:56:00 (UNIX-Time: 1380372960).
28.09.2013 13:14:16: Instruct the system to shut down.
28.09.2013 13:14:16: Service(28) finished.
28.09.2013 13:14:16: <<<

This if I only press F12 and wait...
No countdown, no shudown.
Any idea where I can search ?
Reply
  • 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 14

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