Unraid API - Connect and control Unraid servers through Home Assistant via MQTT

Hi guys,
My flat mate and I have recently developed an MQTT bridge for unraid, with support for homeassistant autodiscovery, which also features a REST end point. It allows you to control the servers array state, monitor power status, control VM state as well as hotplug USBs to VMs.

Theres a docker image you can install using this template url: https://github.com/ElectricBrainUK/docker-templates

Let me know if there are major things missing or wrong. Though this is very early stages still so don’t expect it to be completely flawless. But let me know if it is useful! If you have any problems please join our discord https://discord.gg/Qa3Bjr9

If anyone wants to help us extend it you can check out the source code in a repository by the same user as the docker-templates. (Limited to two links, though we are long time HomeAssistant users we are new to the forums as a poster).

Cheers

3 Likes

Hey guys,

I’m crazy excited to give this a go. I’m just having some trouble getting started and receiving the following error in unraid when adding a socket container:

Pulling image: https://github.com/ElectricBrainUK/docker-templates

**TOTAL DATA PULLED:**  0 B

Command:root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='unraid-api' --net='bridge' --log-opt max-size='50m' --log-opt max-file='1' -e TZ="Australia/Sydney" -e HOST_OS="Unraid" 'https://github.com/ElectricBrainUK/docker-templates' 

/usr/bin/docker: invalid reference format: repository name must be lowercase.
See '/usr/bin/docker run --help'.

**The command failed

I’ve also never tried to add my own container so I could be going about it all wrong.

Thank you
Linton

Hey Linton,
Thanks a lot for trying it out! It looks like you’re trying to pull the docker image however that link is to the template repo, the image is available from here:
https://hub.docker.com/r/electricbrainuk/unraidapi

However are you trying to add the docker to unraid?

If so what you need to do is paste that link (https://github.com/ElectricBrainUK/docker-templates) in the docker templates section at the bottom of the docker tab in the unraid ui. Then when you click add container it will be listed as an option.

It may be better to chat on our discord if you’re still having issues, the invite is in the first post (would post again but can’t post more than 2 links).

Thanks a lot,
Will

Works great, integrates nicely with Homeassistant
Example config for lovelace:

3 Likes

Got it all up and running but is there a way to get binary sensors for cpu,mem,diskspace, etc? I’m only getting one binary sensor with the following:

arrayProtection: Parity is valid.
title: Obsidian
cpu: '       Intel® Xeon® CPU E5-2650 0 @ 2.00GHz'
memory: '64 GiB DDR3 Multi-bit ECC '
motherboard: 'Dell Inc. 0020HJ, Version A01'
diskSpace: 13.7 TB used of 20 TB (68.6 %)
'on': true
friendly_name: obsidian_server
device_class: power

I use glances for that with unraid. take a look at the link above. Install a docker container with glances and add it via the integrations menu with Homeassistant.

2 Likes

Yes I do the same as Ezra with glances, but more than one person has asked for this now so I may add it

Got it… Thanks!!!

1 Like

Its great because of the docker stats, would be nice to have glances build in, wont be that hard.
You can set it in server mode then let it export to an MQTT server or run in in WEB mode and connect the homeassistant integration to it.

Prefer option 1 :slight_smile:

Hi
I’m running HA on hass.io on raspberry pi
i also got an unraid server though

Would like to see stats of the unraid machine in my HA-instance on my pi.
Whats best now?

Use glance, or use this API addon?
Is the API hard to implement?

Is there a movie how to do this?

Things i would like to do

  • stats of cpu and mem
  • stats of all drives in aray (free space)
  • docker control
  • stats of sabnzb for downloads
  • turn on/off
  • parity check

this would rock

Sorry if i ask too much

Hey,
So I use glances for the machine stats you are after, cpu usage etc. However for docker and server control (all but parity check but I can always add that) I’d use the unraid API.

To set up glances you simply add a section in your configuration.yaml and for the unraid API if you have an MQTT broker already with autodiscovery you just need to connect it to that.

Please feel free to ask further questions
Cheers

Hey
Thanks for your answer.
I just installed the API on unraid.
This works.

Can you help me with the broker part.
Thats new to me, i dont have it yet.

I’ve set up glances on my unraid too.
How do i add this to my home assistant?

Ah okay, so in order to set up mqtt you need to install an MQTT broker (there are dockers available for both home assistant and unraid) and connect both home assistant and the unraid API to it.

ok this one

?

Yeah that one would do

Trying to start mqtt
i get error

Warning: store_clean_interval is no longer needed.
Error: Duplicate user value in configuration.
Error found at /config/mosquitto.conf:21.
Error: Unable to open configuration file.

enig idee?
Die glances lukt al

Hey, what is this error from the mqtt broker? It looks like there is something wrong with your config file there is a mosquito.conf.example in the conf.d directory that should show you how to set it up

i cant find the mosquito.conf file
where is that conf.d directory?
its on the cache drive or the usb drive?

I got everything setup, is there a way to tell if Unraid server is running on UPS power? i want to run an automation based on this.

Or is is better to passthrough the USB connection to HA? (also running on Unraid in a VM)