• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support Troubleshooting SOLVED: prevent-Sleep plugin fails

     
    • 0 Vote(s) - 0 Average

    SOLVED: prevent-Sleep plugin fails

    prevent-sleep plugin not working on 10.11 update
    guthrie
    Offline

    Junior Member

    Posts: 13
    Threads: 6
    Joined: 2024 Jun
    Reputation: 0
    Country:United States
    #1
    2026-02-02, 11:57 PM (This post was last modified: 2026-02-03, 01:23 AM by guthrie. Edited 1 time in total.)
    I am running JellyFin 10.11.6 on a W11 windows laptop, and accessing it from a client Amazon fire-TV stick on a local TV.
    Originally I had the standard problem that it kept disconnecting the TV (Fire-stick) when the laptop would go to sleep, and it would then disconnect from the TV.
    So I installed the "Prevent Sleep" plugin - V0.2.0.0 - and all was wonderful.
    But I just did the update to this current version (10.11.6), and the prevent-sleep does not seem to work anymore.
    The admin dashboard shows that it is installed and running, although clicking on the plugin icon on that plugins dashboard also shows an error: 
    "An error occurred getting the plugin details from the repository"..
    however, while the plugins page shows it as installed, the icon is grayed out, and says "restart". but no obvious way to do that.
    The plugin website shows that this is still the current version of the plugin.
    Any hints on what to do?
    Go to solution
    Rastin
    Offline

    Member

    Posts: 72
    Threads: 0
    Joined: 2026 Jan
    Reputation: 5
    #2
    2026-02-03, 01:02 AM
    To stop your Windows 11 PC from sleeping, go to Settings > System > Power & battery > Screen and sleep, and set the "Turn my screen off after" and "Make my device sleep after" options to Never,
    guthrie
    Offline

    Junior Member

    Posts: 13
    Threads: 6
    Joined: 2024 Jun
    Reputation: 0
    Country:United States
    #3
    2026-02-03, 01:24 AM (This post was last modified: 2026-02-06, 11:26 AM by guthrie. Edited 1 time in total.)
    Hmm, I did an uninstall of the plugin, and then a reinstall, and now it says active (although it was the same version from the same repository), so I'll see if that works!
    Hmm, seems to sorta work - smetimes.
    I also tried he Microsoft powerTools Awake tool, also sems to work sometmes.
    I asked Google-AI, and it wrote a script to monitor JFn by API and do a keep-awake if it is running a stream, I'll try that.
    guthrie
    Offline

    Junior Member

    Posts: 13
    Threads: 6
    Joined: 2024 Jun
    Reputation: 0
    Country:United States
    #4
    2026-02-07, 08:02 PM (This post was last modified: 2026-02-08, 01:46 AM by guthrie. Edited 3 times in total.)
    After a few stumbles with the previous approaches, I had Claude (AI) write a ps1 script to do it, and after a few iterations got one that seems to work, still testing, but seems to work fine!
    This is Windows only (obviously...), and you have to leave the PS window it is running in open.
    One can add other lines to auto-start it, and/or run it in the background.

    -----------------------------------------------------------------------
    Code:
    ##
    #  https://claude.ai/chat/34f76e4c-8738-458c-bb34-e793f246fb8d
    #
    # Here is a PowerShell script that monitors Jellyfin for active streams
    #    and only prevents sleep when something is playing:
    ##
    # ----------------------------------------------------

    # Configuration
    $jellyfinUrl = "http://localhost:8096"
    $apiKey = "Your-API-Key-Here"
    $checkIntervalSeconds = 60

    Write-Host "Jellyfin Sleep Manager started..."

    while ($true) {
        try {
            $headers = @{"X-Emby-Token" = $apiKey}
            $sessions = Invoke-RestMethod -Uri "$jellyfinUrl/Sessions" -Headers $headers
           
            $activeSessions = @($sessions | Where-Object {
                $_.NowPlayingItem -and
                $_.NowPlayingItem.PSObject.Properties.Count -gt 0 -and
                $_.PlayState.IsPaused -ne $true
            })
           
            Write-Host "$(Get-Date -Format 'HH:mm:ss') - Found $($activeSessions.Count) active session(s)"
           
            if ($activeSessions.Count -gt 0) {
                Write-Host "  Stream active, preventing sleep"
                # Prevent sleep on AC (plugged in)
                Start-Process "powercfg" -ArgumentList "/change standby-timeout-ac 0" -WindowStyle Hidden -Wait
                # Prevent sleep on DC (battery)
                Start-Process "powercfg" -ArgumentList "/change standby-timeout-dc 0" -WindowStyle Hidden -Wait
               
                foreach ($session in $activeSessions) {
                    $user = $session.UserName
                    $item = $session.NowPlayingItem.Name
                    $client = $session.Client
                    Write-Host "  -> $user watching '$item' on $client"
                }
            }
            else {
                Write-Host "  No streams, allowing sleep (30 min)"
                # Allow sleep on AC after 30 minutes
                Start-Process "powercfg" -ArgumentList "/change standby-timeout-ac 30" -WindowStyle Hidden -Wait
                # Allow sleep on DC (battery) after 15 minutes (or adjust as needed)
                Start-Process "powercfg" -ArgumentList "/change standby-timeout-dc 15" -WindowStyle Hidden -Wait
            }
        }
        catch {
            Write-Host "Error: $_"
        }
       
        Start-Sleep -Seconds $checkIntervalSeconds
    }
    guthrie
    Offline

    Junior Member

    Posts: 13
    Threads: 6
    Joined: 2024 Jun
    Reputation: 0
    Country:United States
    #5
    2026-02-12, 02:49 PM
    Slight improvement in reporting:
    Code:
    ##
    #  https://claude.ai/chat/34f76e4c-8738-458c-bb34-e793f246fb8d
    #
    # Here is a PowerShell script that monitors Jellyfin for active streams
    #    and only prevents sleep when something is playing:
    ##
    # ----------------------------------------------------

    # Configuration
    $jellyfinUrl = "http://localhost:8096"
    $apiKey = "fcf6e71ce71749608c9af3069e15f71c"
    $checkIntervalSeconds = 60

    Write-Host "Jellyfin Sleep Manager started..."

    $currentMode = $null  # Track current state

    while ($true) {
        try {
            $headers = @{"X-Emby-Token" = $apiKey}
            $sessions = Invoke-RestMethod -Uri "$jellyfinUrl/Sessions" -Headers $headers
           
            $activeSessions = @($sessions | Where-Object {
                $_.NowPlayingItem -and
                $_.NowPlayingItem.PSObject.Properties.Count -gt 0 -and
                $_.PlayState.IsPaused -ne $true
            })
           
            if ($activeSessions.Count -gt 0) {
                if ($currentMode -ne "active") {
                    Write-Host ""
                    Write-Host "$(Get-Date -Format 'HH:mm:ss') - STREAM ACTIVE - Preventing sleep"
                    foreach ($session in $activeSessions) {
                        $user = $session.UserName
                        $item = $session.NowPlayingItem.Name
                        $client = $session.Client
                        Write-Host "  -> $user watching '$item' on $client"
                    }
                   
                    Start-Process "powercfg" -ArgumentList "/change standby-timeout-ac 0" -WindowStyle Hidden -Wait
                    Start-Process "powercfg" -ArgumentList "/change standby-timeout-dc 0" -WindowStyle Hidden -Wait
                    $currentMode = "active"
                }
                else {
                    Write-Host "." -NoNewline
                }
            }
            else {
                if ($currentMode -ne "idle") {
                    Write-Host ""
                    Write-Host "$(Get-Date -Format 'HH:mm:ss') - NO STREAMS - Allowing sleep"
                   
                    Start-Process "powercfg" -ArgumentList "/change standby-timeout-ac 30" -WindowStyle Hidden -Wait
                    Start-Process "powercfg" -ArgumentList "/change standby-timeout-dc 15" -WindowStyle Hidden -Wait
                    $currentMode = "idle"
                }
                else {
                    Write-Host "." -NoNewline
                }
            }
        }
        catch {
            Write-Host ""
            Write-Host "Error: $_"
        }
       
        Start-Sleep -Seconds $checkIntervalSeconds
    }
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode