Jump to content

Windows 10 PC doesn't wake up to record.


wayloncovil

Recommended Posts

wayloncovil

Hi.

From my reading, my Windows PC should be waking up to record shows. I've done several tests so far and it doesn't appear to be working for my install.

I have Emby installed under my Admin account and I'm logged in to my Admin account and start sleep from my admin account.

When I look at the logs, it shows that recordings are scheduling correctly but I don't see any line items when I search for the word wake.

When I go to Task Scheduler --> Active Tasks --> Scheduled Start (I'm assuming this is where my Emby Wake Timers should be) I don't see anything for Emby.

Screenshot attached.

If Logs are required, may I PM them to you rather than posting them publicly on this thread?

Thanks!

 

 

 

post-382161-0-67586100-1549756812_thumb.jpg

Edited by wayloncovil
Link to comment
Share on other sites

No it would actually be in the Task Scheduler list like this:
 

5c60dca0e126e_Untitled.png

 

Then when you double click it you can see in the conditions that it is set to wake the PC.

Link to comment
Share on other sites

wayloncovil

UPDATED: I see the tasks in task scheduler. See attached screenshot.

It doesn't appear that the computer actually woke up and recorded.

 

UPDATE 2: I see that under security options, the radio button next to Run only when user is logged on is checked. See additional screenshot.

My admin user is logged in, however the computer is asleep. I'm running a computer with multiple users on it.

 

UPDATE 3: I've attached screenshots of the individual settings to this post.

 

Update 4: I've enabled history in the task manager. I'm thinking that maybe the security or conditions might need some tweaking.

 

UPDATE 5: I took a look at the system log (see embypower.jpg attached). The computer actually woke on Sunday at 10:54 AM. But, it went back to sleep at 10:57 (see embypower2.jpg attached) so it never recorded.

 

So it looks like Emby is scheduling the task but the computer is going back to sleep.

 

Is it possible that the Task Scheduler condition (Stop if the computer ceases to be idle) is causing it to go back to sleep?

 

UPDATE 6: What's the power command powercfg that Emby uses to keep the computer awake once it wakes up?

Thanks!

post-382161-0-33219900-1549948114_thumb.jpg

post-382161-0-06260400-1549948423_thumb.jpg

post-382161-0-72239800-1549948688_thumb.jpg

post-382161-0-10513200-1549950043_thumb.jpg

post-382161-0-39289600-1549950128_thumb.jpg

Edited by wayloncovil
Link to comment
Share on other sites

 

 

UPDATE 6: What's the power command powercfg that Emby uses to keep the computer awake once it wakes up?

 

There isn't one, unless users are actively connected. The server gets woken up five minutes ahead of the recording.

Link to comment
Share on other sites

wayloncovil

Luke, thanks for your help. I'm going to reinstall on a newer windows 10 build that doesn't have much going on and see how things go and report back in a new thread with any issues on that box. Thinking that it could be something with my current rig.

 

I do have one question before we move on from this thread...

You mentioned that Emby doesn't have anything to keep the computer awake while it's recording. (At least that's how I read it.)

There isn't one, unless users are actively connected. The server gets woken up five minutes ahead of the recording.

 

If Emby isn't telling the computer to stay away, if I record a 2 hour show, will I need to have my sleep time set for 2 hours?

 

Thanks!

Link to comment
Share on other sites

I think it should stay awake but I'll to double check. What I meant is that it wakes up five minutes ahead but if your sleep time is shorter than that then in theory it could wind up sleeping again.

Link to comment
Share on other sites

cispbunk

Hi,

I appear to be having exactly the same issue with my installation. Using a Hauppauge winTV-dualHD, the PC wakes up 5 minutes before the programme is due to record, but by the time the programme has started, it's fallen back asleep again. Clean install of Windows 10, with Emby, then WinTV installed. Recording using WinTV works perfectly, PC wakes up and records the programme. Power settings are the default balanced Windows settings. Has only recently started doing this... Any ideas as to why this would happen? Thanks in advance

Link to comment
Share on other sites

wayloncovil

Not sure if this is helpful but it looks like there might be a different way to program Emby to wake up the computer:

"NextPVR doesn't need or use the task scheduler. It uses the Windows API calls for asking Windows to wake the machine."

Link to comment
Share on other sites

wayloncovil

On my new machine, I have Emby setup to run as a server. I accessed the server remotely. I then set several items to record. Item's didn't record last night. I don't see anything under the Task Scheduler Library from Emby to wake the computer.

The windows system logs also show that the computer never woke up.

I then logged in locally as admin and scheduled a recording and didn't see anything show up in the Task Scheduler Library.

Link to comment
Share on other sites

wayloncovil

On my new machine, I have Emby setup to run as a server. I accessed the server remotely. I then set several items to record. Item's didn't record last night. I don't see anything under the Task Scheduler Library from Emby to wake the computer.

The windows system logs also show that the computer never woke up.

I then logged in locally as admin and scheduled a recording and didn't see anything show up in the Task Scheduler Library.

 

I believe I found a solution to this issue so posting for others in case there's interest.

When setting up nssm, under the login screen, I changed the "Log on as" from the "Local System account" to "This account:" and entered the username and password to the admin account under which I initially installed Emby.

I then rebooted and did not login to the computer but connected to it remotely. I then found a show in the guide for around 4 in the morning and scheduled it to record.

I then logged in to my Emby server as the admin account and looked under "Task Scheduler Library".

Sure enough, there was a line item for Emby to wake up at 3:54 AM.

Edited by wayloncovil
Link to comment
Share on other sites

cispbunk

I'm looking at another possible solution - I couldn't work out why the PC was waking as expected but then falling back asleep virtually immediately - anyway, came across this: https://www.tenforums.com/general-support/6847-win-10-unattended-sleep-timeout-same-vista-win-7-8-1-a.html 

 

Still testing but I think this could be a possible solution - I changed it from the default 2 mins (which would send the PC back to sleep before recording started) to 10 mins. This allowed the recording to start, but it still didn't record the full programme. Am going to try changing to 120mins (I never record anything longer than that) and see if it records the whole programme. Only worry that any other "unattended wake up" would then cause the PC to remain on for 2 hours..

Link to comment
Share on other sites

wayloncovil

As mentioned above, I scheduled a program called Music Voyage to record at 0400 local time.

As you can see in the attached embserver-63686479304 log, it scheduled the event and created a task to wake the computer.

According to the Windows logs, the PC woke up at the designated time:

The system has returned from a low power state.
Sleep Time: ‎2019‎-‎02‎-‎23T10:15:59.741249300Z
Wake Time: ‎2019‎-‎02‎-‎23T11:53:30.788732600Z
Wake Source: Timer - Windows will execute 'NT TASK\Emby Recording Music Voyager Sat, 23 Feb 2019 03 59 00 GMT' scheduled task that requested waking the computer.

And then the computer went back to sleep at 0356 local time.

 

@@cispbunk, you said:

I'm looking at another possible solution - I couldn't work out why the PC was waking as expected but then falling back asleep virtually immediately - anyway, came across this: https://www.tenforum...n-7-8-1-a.html 

 

Still testing but I think this could be a possible solution - I changed it from the default 2 mins (which would send the PC back to sleep before recording started) to 10 mins. This allowed the recording to start, but it still didn't record the full programme. Am going to try changing to 120mins (I never record anything longer than that) and see if it records the whole programme. Only worry that any other "unattended wake up" would then cause the PC to remain on for 2 hours..

 

 

@@cispbunk, Good find!

 

I did some digging and I think I found why the computer isn't staying awake:

https://docs.microsoft.com/en-us/windows/desktop/power/system-wake-up-events

 

When the system wakes automatically because of an event (other than power switch or user activity), the system automatically sets an unattended idle timer to at least 2 minutes. This timer gives applications sufficient time to call the SetThreadExecutionState function to indicate that they are busy. This time enables the system to return to the sleep state quickly after the computer is no longer required.

 

 

@@cispbunk, It sounds like you're updating the unattended idle time based on my interpretation of the document from Microsoft's website. I'm thinking the onus should be on the application to keep the computer awake.

 

@@Luke, you mentioned that Emby doesn't do anything to keep the computer awake.

It seems like Emby needs to be calling the SetThreadExecutionState to keep the computer awake.

 

Since Emby runs in userspace, if it can't call SetThreadExecutionState, one option is that you could create a windows service to turn the computer on, maintain the SetThreadExecutionState and release the lock once the recording is done so the computer can go back to sleep. I'm thinking you would use this in lieu of task scheduler. I've got some more ideas about this if you have to go down this route.

 

@@Luke, thanks for all your hard work on Emby. I love the program!

embyserver-63686479304.txt

embyserver.txt

Edited by wayloncovil
Link to comment
Share on other sites

cispbunk

@@Luke - agree with @@wayloncovil - great application, much preferred to the main opposition :)


 


OK - I've tried another fix for this - I reset the Windows balanced power settings to default, which also set the unattended sleep value back to 2 mins. I then changed the turn screen off setting to Never ​(the PC is connected to a TV screen, so I'd never leave it on anyway...) Up to now, the PC has successfully resumed from sleep on a number of occasions, then stayed awake long enough to start and complete the recording. I did have a couple of failed recordings last night, but this was down to an error with the tuner being unavailable (not power related). Have restarted the PC and will try some more recordings and see what happens with those. 


 


If this has fixed it, it seems bizarre that altering the screen time out settings would have an impact on the unattended sleep, and suggests a Windows, rather than Emby issue? Much as I love Microsoft Windows, and wouldn't dream of changing to other OS's, they do sometimes make things more complicated than necessary...

Link to comment
Share on other sites

  • 2 weeks later...

We already call SetThreadExecutionState, but part of the reason why Emby does not have an embedded windows service is because we haven't tested every single feature when running that way.

 

I think currently this might be something that still needs development when running as a windows service. Until then you may have to continue with the workarounds that you've discovered. Thanks !

Link to comment
Share on other sites

wayloncovil

@@Luke, thanks for the reply.

I've seen Emby refuse to stay awake on 2 of my computers. One with running it as a service and another with it running with logged in Admin.

@cispbunk is seeing the same behavior and doesn't mention that the system is running as a service so I'm assuming it's with a logged in user.

It seems like something is amiss even with it running is userspace.

It appears that SetThreadExecutionState needs to be reinitialized every so often as explained here.

Is Emby reinitializing SetThreadExecutionState every few minutes?

Currently I'm using another recording application until this issue is resolved.

If you'd like me to do any additional testing, please let me know.

Thanks!

Link to comment
Share on other sites

wayloncovil

Luke, sounds good.

I've followed the instructions provided by @cispbunk and updated my idle time to 10 minutes and set a test recording for later today.

Link to comment
Share on other sites

  • 2 weeks later...
wayloncovil

I updated my system to have an idle time of 15 minutes according to the criteria earlier in the thread.

I was reading that you added some enhancements to the latest Beta's regarding waking up the computer and keeping it away so I installed the latest Beta Version 4.1.0.17 yesterday.

Then, at 17:30 local on the 28th, I scheduled a show called Dinosaur train to record at 00:30 on the 29th.

According to the Emby logs (attached) it scheduled the system to wake.

According to the windows system logs, the PC woke at 00:23 on the 29th.

It went back to sleep at 00:39 which is about 15 minutes.

The funny thing is that I don't even have 9 minutes of the show recorded.

 

When I tested before updating to the Beta on the 18th, the system did record about 9 minutes of Let's Go Luna!. (Sorry. Luna's not in the logs from what I could find - too far back I expect.)

 

I don't think this is a valid test of the system staying awake because it isn't actually recording. I'm guessing that you have the code setup to send the keep awake while the system is actually recording.

 

I'll schedule another test and see how it goes.

 

As I reminder, I'm running Emby in Server mode with NSSM under the Admin user. If this is too far out of scope and too many variables and we need to scrap this testing because of my configuration, let me know and we can just table this for now until I can acquire another computer to try this on.

 

Thanks!

embyserver_log.zip

Edited by wayloncovil
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...