Jump to content

Putting PC to Sleep whilst EmbyServer is streaming


Recommended Posts

GeorgeCalli
Posted (edited)

I’m trying to automate putting my PC (Windows 10, Emby Version 4.8.10.0) to sleep at an allocated time using a Script, Task Scheduler, and PowerShell, but I want to keep it awake when media (like movies or music) is playing.

However, while playing media, I receive the message: “Emby Server is idle with no significant activity, putting the PC to sleep.” Emby Server’s CPU usage is 0%.

I’ve tried using the Emby Server API key and localhost, but I can’t get PowerShell to recognize that Emby Server is playing movies or music even though PowerShell sees it as idle i.e. the server.

I’ve even tried monitoring network traffic, CPU usage, CPU spikes or a combination thereof.

Has anyone had experience with this and can offer a solution? Any suggestions on how to prevent the PC from sleeping when Emby Server is playing?

Your assistance will be appreciated.

Thanks.

P/S Apologies: I just notice that I posted this under Android Server and not Windows. Unfortunately, I don't know how to move.

Edited by GeorgeCalli
Posted
Quote

However, while playing media, I receive the message: “Emby Server is idle with no significant activity, putting the PC to sleep.” Emby Server’s CPU usage is 0%.

I

Hi, what gives you this message? that is not an emby message. We don't have that text anywhere.

GeorgeCalli
Posted

Windows Powershell gives me the message. 

So sorry that I wasn't clear!

Thought I'd ask, maybe someone would know what of the Emby Server I needed to monitor. Apologies for not being clearer. 

GeorgeCalli
Posted

My question in simpler terms:

I'm trying to prevent my PC from going to sleep when media (like movies or music) is playing on Emby.

I want the PC to sleep only via script, task scheduler, and PowerShell.

Has anyone found a solution for keeping the PC awake while Emby is active?

Posted
Quote

I'm trying to prevent my PC from going to sleep when media (like movies or music) is playing on Emby.

Hi, on Windows, Emby will already handle this for you.

GeorgeCalli
Posted

Thanks for that.

I was watching a movie on TV through Emby, and PC went to sleep.

Hence the reason I'm looking into this.

Also, If I'm streaming music through Emby, PC also goes to sleep.

I'm trying to prevent PC going to sleep if I'm streaming media.

Posted

All you need to do is setup windows sleep mode normally.
 

Posted
On 10/25/2024 at 10:25 AM, GeorgeCalli said:

Thanks for that.

I was watching a movie on TV through Emby, and PC went to sleep.

Hence the reason I'm looking into this.

Also, If I'm streaming music through Emby, PC also goes to sleep.

I'm trying to prevent PC going to sleep if I'm streaming media.

By PC do you mean the same machine as the server?

GeorgeCalli
Posted

I did exactly that, but whilst streaming a movie, PC went to sleep and subsequently Emby and movie stopped.

GeorgeCalli
Posted

Yes, same machine.

It's a Windows 10 computer that also runs Emby for Windows.

GeorgeCalli
Posted (edited)

Some feedback

I reset the power settings to default and checked settings ensuring sleep is set to allocated time.

Streamed music from Emby and noticed that the computer went to sleep even though music was playing.

Exactly what had happened whilst playing a movie.

This is what I was trying to overcome.

Thank you.

 

Edited by GeorgeCalli
Grammar
  • Thanks 1
GeorgeCalli
Posted
On 10/28/2024 at 2:50 AM, Luke said:

By PC do you mean the same machine as the server?

Yes.

Posted
On 10/28/2024 at 9:08 AM, GeorgeCalli said:

Some feedback

I reset the power settings to default and checked settings ensuring sleep is set to allocated time.

Streamed music from Emby and noticed that the computer went to sleep even though music was playing.

Exactly what had happened whilst playing a movie.

This is what I was trying to overcome.

Thank you.

 

Can we please look at a specific example?

Thanks.

  • 2 weeks later...
GeorgeCalli
Posted

I think I might have figured out the issue.

If the PC goes to sleep via Power Plan settings by selecting a time interval to sleep, and Emby is streaming, Emby keeps the PC awake.

However, if the PC is set to go to sleep at a specific time via Task Scheduler and PowerShell with the following command:

Program/Script: rundll32.exe

Argument: powrprof.dll,SetSuspendState 0,1,0

Emby seems not to recognize this command and thus can't prevent the PC from sleeping while streaming media.

Is there perhaps an additional argument I need to add to the script, or won't this option work?

Posted

you need to setup windows sleep mode normally.

Posted
11 hours ago, VIDE08 said:

you need to setup windows sleep mode normally.

Hi @VIDE08can you explain to him what you mean by normally? Thanks !

Posted
Quote

However, if the PC is set to go to sleep at a specific time via Task Scheduler and PowerShell with the following command:

Program/Script: rundll32.exe

Argument: powrprof.dll,SetSuspendState 0,1,0

Emby seems not to recognize this command and thus can't prevent the PC from sleeping while streaming media.

Is there perhaps an additional argument I need to add to the script, or won't this option work?

Maybe the argument is don't have it sleep this way at all? 

I realize you're looking at this from the point of view of thinking that this is an Emby problem, but Emby has registered a hold with the system to keep it awake. I think it is more accurate to say that the method of sleeping that you are using with the task scheduler is bypassing this.

GeorgeCalli
Posted

I realise that. I thought it would work with any sleep command.

Don't see it as an Emby problem at all, just thought there might be a way to make it work if a specific sleep time is set.

Thanks for your comments. You are right, won't have it sleep this way.

Posted
On 13/11/2024 at 08:26, GeorgeCalli said:

I think I might have figured out the issue.

If the PC goes to sleep via Power Plan settings by selecting a time interval to sleep, and Emby is streaming, Emby keeps the PC awake.

However, if the PC is set to go to sleep at a specific time via Task Scheduler and PowerShell with the following command:

Program/Script: rundll32.exe

Argument: powrprof.dll,SetSuspendState 0,1,0

Emby seems not to recognize this command and thus can't prevent the PC from sleeping while streaming media.

Is there perhaps an additional argument I need to add to the script, or won't this option work?

Can you not set a 'Condition' on the windows scheduler task to say only start the 'sleep' task if the PC is idle ?

If streaming, Emby is forcing it to be 'not idle' - so your sleep task would not run.  If it's not, then your sleep task would run and sleep the PC .. 

I haven't tested this - but this may work .. 

image.png.f56dff1b6de7b99cb92faea18493938b.png

GeorgeCalli
Posted
44 minutes ago, rbjtech said:

Can you not set a 'Condition' on the windows scheduler task to say only start the 'sleep' task if the PC is idle ?

If streaming, Emby is forcing it to be 'not idle' - so your sleep task would not run.  If it's not, then your sleep task would run and sleep the PC .. 

I haven't tested this - but this may work .. 

image.png.f56dff1b6de7b99cb92faea18493938b.png

 

Thanks for that.

I had tried that, and to reaffirm tried it again now, unfortunately it does not work.

Yet, setting PC to sleep normally via intervals, Emby keeps PC awake whilst streaming.

  • Thanks 2

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...