unRAID API and Home Assistant

In a drive to add more things to home assistant, I found the unRAID API. This container provides unRAID server information to home assistant via MQTT. I figured this could be interesting to add to my stack, and potentially pretty useful in the long run, so I decided to get it going.

The unRAID API uses MQTT to relay information to home assistant. So if you don’t have an MQTT broker setup for home assistant, you should find a guide on how to set it up. MQTT is easy to setup and start using, and quite useful in the long run.

Container Settings

I decided to use a fork of the original project, unRAID-API-RE, for my container. It’s a bit more up to date than the original project which hasn’t seen an update in 2 years.

For the basics, all you need to fill in is your MQTT broker IP, username, and password. Since my broker is hosted on my home assistant server, I put in that IP address, and added a username and password unique to this service to my broker for it to use.

Once the container is started, navigate to the webui for it and log into your unRAID server. This gives the container what it needs to gather data from unRAID and publish it to home assistant.

Once that’s done, head on over to home assistant and check out the new data that’s available. Most of the data is provided as attributes on the main server entity.

Data in Home Assistant

Sensors

All the information from the API comes in as attributes on the server entity in home assistant. We’re going to make some template sensors to take these attributes and turn them into sensors themselves that we can trigger automations off of within home assistant.

sensor:
- platform: template
unraid_array_status:
friendly_name: UnRAID Array Status
value_template: >
{{state_attr("binary_sensor.shadowofintent_server", "arrayStatus")}}
unraid_array_protection:
friendly_name: UnRAID Array Protection
value_template: >
{{state_attr("binary_sensor.shadowofintent_server", "arrayProtection")}}
unraid_array_space:
friendly_name: UnRAID Array Space
value_template: >
{% set state = state_attr("switch.shadowofintent_server", "ArrayFreeSpace") %}
{{ Offline if state == None else state | regex_findall_index(".*\((\d+.?\d+) %\)") | float }}
unit_of_measurement: "%"

Some Automation Ideas

  • Notifications when the server goes down or the array status changes
  • Enable or disable home assistant automations based on server status

Conclusion

This was a nice quick data source to setup for home assistant. I plan on adding a few notifications to be sent out based on the data, and may enable some other automations around it too.

Resources

Leave a Reply