In Unraid, drives spin down after a set period of inactivity to save power and reduce unnecessary wear. I have configured my drives to spin down after 30 minutes of inactivity (In Unraid – Settings -> Disk Settings -> Default spin down delay). This setup works well for power savings, but it can cause delays when accessing media files, such as when I want to play a movie in Plex. The drives need to spin up from their slumber, which can take about 30 seconds before playback begins.
To solve this issue, I created a Home Assistant automation that automatically spins up my Unraid drives whenever Plex gets opened on my TV. While I use Apple TV, the exact same method can work for Chromecast or other streaming devices (and instead of Plex, you can use whatever app you want as a trigger).
Step 1: Mount Your Unraid Media Drive in Home Assistant
If you haven’t done this already, you need to mount your Unraid media drive in Home Assistant:
- In Home Assistant, Go to Settings -> System -> Storage -> Add Network Storage.
- Set a type for the share is “Media“, type your Unraid server IP under Server, and select Samba under the Protocol option.
- Under Remote share, write the name of your share in Unraid (mine is “HTPC” – no slashes or backslashes).
Step 2: Add Shell Command to Configuration.yaml
Next, add the following shell command to your configuration.yaml
:
shell_command:
wake_up_unraid: 'touch /media/HTPC/Downloads/wakeup.now'
Step 3: Create the Automation in Home Assistant
Finally, create the following automation in Home Assistant:
alias: Spin-up drives when running plex on Apple TV
description: ""
trigger:
- platform: template
value_template: "{{state_attr('media_player.living_room','app_name')=='Plex'}}"
condition: []
action:
- service: shell_command.wake_up_unraid
metadata: {}
data: {}
mode: single
Customizing the Automation
You will need to change the media_player
entity name (mine is “living_room”) to match your own device and change “Plex” to whatever app you want to use as a trigger for spinning up the Unraid drive.
Conclusion
With this setup, whenever Plex is opened, a 0-byte file will be accessed on your hard drive, which automatically spins up the drive. This method doesn’t solve the issue where if you leave Plex open for an extended period and the drives spin down while you’re still browsing your media collection, so ideally, you won’t take too long to pick what to watch.
As always, if you find a better way of doing things, I’d be happy to hear about it!