[Support] Fork Unraid API-RE


Recommended Posts

  

13 hours ago, light2089 said:

@BlaM - I use the APC UPS integration in HA to extract UPS information from my Unraid server

 

Uh, nice. I didn't know that Unraid would open a port you can connect to. I have seen the integration in HA, but assumed that you have to connect directly to the UPS (and mine does not have a network connection).

 

Thanks :) - Problem solved.

Link to comment
3 hours ago, BlaM said:

  

 

Uh, nice. I didn't know that Unraid would open a port you can connect to. I have seen the integration in HA, but assumed that you have to connect directly to the UPS (and mine does not have a network connection).

 

Thanks :) - Problem solved.

Hahaha, exactly the same for me I've spent ages trying to work out how to run NUT on hassio or on my pfsense firewall and then share with unraid, but never could be bothered with the effort. I could kick myself that I never knew this before now.

 

(and its already fully working and looking good....grrr)

Edited by twistedsanity
added my result
Link to comment

Cool project, just what I was looking for!

 

I just installed it on unraid and I can start/stop my VMs via API calls (I did not do any HA integration, I just curl the API from a script on another machine).

 

My only problem is that even though the APIs seem to work at first, my unraid panel becomes unresponsive soon after I start Unraid-API-RE. Anything I can do to avoid this?

 

Thanks.

Link to comment
  • 2 weeks later...

Hi, first off all great work and thank you.
I am using the Unraid API to turn my server on and off with Home Assistant. However, I am having a problem where the server state changes back to "on" a few seconds after I send the "server power_off" command.

I have been able to reproduce the issue consistently.
It only happens if on off the disks is in sleep mode before I send the power_off command.
When Unraid starts to shut down, it wakes the disks up, and then the server state changes back to "on".


Steps to reproduce:

Put all of the disks in sleep mode.

Send the "server power_off" command using the Unraid API.

Wait a few seconds.

Check the server state.


Expected behavior:

The server state should remain "off".

Actual behavior:

The server state changes back to "on".

 

Thank you

Edited by Orishas
Link to comment
  • 2 weeks later...
On 2/14/2024 at 6:10 AM, corgan said:

thank you so much!

Works great directly as datasource in grafana.

 

grafik.thumb.png.52e82d30b4ec53844537046c07c22679.png

 

Did you do anything special to get this to work? I am having trouble adding the data source to Grafana.

 

I am following the guide here: https://github.com/HStep20/Ultimate-Unraid-Dashboard-Guide

 

Which details how to add the data source below:

 

UnraidAPI

Hit 'Add Data Source' and choose an 'JSON API' data type

With the containers being on the same docker compose network, we can refer to them by container name in URLs.

Top fields:

URL - http://YOURSERVERIP:YOURUNRAIDAPIPORT/api/getServers

Note: The default unraidapiport is 3005. If you did not edit the docker-compose.yml, set the port to 3005

 

When I do this, I am presented with the following error:

 

JSON API: Internal Server Error

 

Any advice on how to get this to work?

Link to comment

Data Source: Type: JSON API

 

Data Source Config:
my server is on 192.168.2.254
port of the api: 3005
So the URL must be http://192.168.2.254:3005/api/getServers
 

grafik.thumb.png.a483631fe54887e23b834ca62f6d2c14.png

 

 

Grafana Panel Config for Docker Container:
Panel https://grafana.com/grafana/plugins/dalvany-image-panel/

 

use your IP!

 

$.['servers']['192.168.2.254']['docker']['details']['containers'][*].name

$.['servers']['192.168.2.254']['docker']['details']['containers'][*].imageUrl

$.['servers']['192.168.2.254']['docker']['details']['containers'][*].status

 

grafik.thumb.png.d71f9fc9f57e010e5736f7d35aff42d0.png

 

 

 

 

 

 

  • Like 1
Link to comment
  • 2 weeks later...

I'm looking for a way to filter what is published via mqtt to not clutter up my home assistant with dozen of switches again.

Sadly with autodiscover ON in HA I can't filter which devices are discovered.

 

With autodiscover, it woudl create 130 switches, 52 sensors, aso.

grafik.png.594267191587e9bfab3f5ac87d70c3e5.png

 

I found the mqttDisabledDevices.json in the appdata folder, but no documentation or example how to use this file.

In the end, I only want to have 2 docker container controlled via HA and don't want all the information inside HA.

Edited by corgan
Link to comment
  • 4 weeks later...
44 minutes ago, BoKKeR said:

Yes, when I find time i will the entities that are broken. Hopefully this weekend. 

 

Great! That's are good news!

I have some questions regards the update interval. Is there any rule that defines how often components are updated?
Sometimes it takes forever after a Home assistant restart till the components are available, and sometimes there are dozens of updates in one minute.
And is there any way to request or trigger an update?
Is it an expected behavior that the API sends the discovery message over and over, or is there something broken? 

 

grafik.thumb.png.60cefc69bd55eb43340343abb329dd3e.png

 

For me, the API sends all sensors from the server, docker and the VMs. I don't have broken entities after discovery.

 

Thanks and greetz Stefan

Link to comment
  • 3 weeks later...

Thanks for reviving this. I have been trying to get this work on Unraid 6.12.8, but seems like there is something I am missing. I got the unraidapi running and can only see dockers. No server details are displayed. Don't see anything in the logs either. Servers.json has all the details as can be seen below.

 

Here is my docker compose (Fyi: Using docker compose first time). 

 

Also, I don't see MQTTUser in there. Is it not required or defined somewhere else?

 

  unraidapi:
    container_name: GUS-unraidapi
    image: bokker/unraidapi-re:6.12 # Use tag for your version - 6.11 or 6.12
    network_mode: bridge
    hostname: ${HOSTNAME}
    ports:
      - ${UNRAID_API_UI_PORT}:80
    volumes:
      - ${APPDATA_PATH}/GUS-UnraidAPI:/app/config
    environment:
      MQTTBroker: hassio
      MQTTPort: 1883
      MQTTPass: pass
      MQTTBaseTopic: homeassistant
      KeyStorage: config
      TZ: ${TIMEZONE}
    restart: unless-stopped
    depends_on:
      - influxdb
    labels:
      - "net.unraid.docker.icon=https://raw.githubusercontent.com/ElectricBrainUK/UnraidAPI/master/static/iconx64.png"
      - "net.unraid.docker.webui=http://[IP]:[PORT:3005]/"

 

image.thumb.png.38f9c0246b1a6d0718bffae2ab36ca2b.png

image.png.a7dfac535df7c2db6b98893d52cdec02.png

image.png.d22c64d567d34c63db7f4e3eb0d44355.png

Link to comment

Hello,

 

I'm having no joy getting this to work. The documentation isn't very clear and, certain on my server, the Docker image isn't working correctly. 

 

I added the Management Server app from the CA then added the Docker image using the image from the OP here (not the old one). Added the environment variables for my MQTT broker and started the container. But when I connect, there's nothing there. The webpage loads, I enter my server details, it says connected but that's it. Nothing populates. If wait, nothing happens, if I refresh the server details on "setup unraid server" disappear.

 

image.png.e027acc77ffe174f4f411cbe6425029e.png

 

On the Home Assistant side, I cannot get the add-on to install at all. I wasn't sure if there was a newer add-on I should be using. 

 

1815519982_Screenshot2024-04-23134244.png.43f077cad5b5e509b69f4e72cb76f409.png

Link to comment

@corgan I am not sure how mqttDisabledDevices.json works,

image.thumb.png.905bcd12918aff6b2186d7eff0de3048.png

It looks like you can disable docker for a full host, but not really specific containers?

 

I could look into disabling auto discovery since its quite messy with the docker containers... I am also not sure if the discovery feature is broken. I have not touched it from the old project and frankly I am not sure how that feature should behave. I will have to do some research or you can fill me in on the details if you have experience.

 

The update intervall can be possibly adjusted with an environmental variable `MQTTRefreshRate` also seen on the screenshot.

 

@viktortras I have not tested with a public myunraid address. Could you try locally on the same network?

 

@Orishas Noted, will have to revisit this issue

 

@vicious-transgression6851 You seem to have all the data so it might be unrelated to unraid-api? I mostly use this with home assistant.

 

@Puntoboy There is no home assistant version. I am using it as a container deployed on UNRAID connecting it to HA with MQTT. The home assistant version would just run the unraid api container within HA OS. 

 

 

Edited by BoKKeR
Link to comment
19 hours ago, BoKKeR said:

@vicious-transgression6851 You seem to have all the data so it might be unrelated to unraid-api? I mostly use this with home assistant.

 

Got it working. Had to specify Home assistant IP as mqttbroker rather than the name.

 

Still I can only see all the dockers listed, but no server info including drives. What am I missing?

Link to comment
6 hours ago, BoKKeR said:

@Puntoboy can you check the config folder if there are any files? You could try wiping them also. You could enable writing the HTML files with the WRITE_HTML_OUTPUT=true environmental variable. That will generate more logs about the scraping.

 

You can share these logs privately with me for more debugging.

 

Sorry for the stupid question, but how can I browse to the config files? 

I've added that variable.

Snippet from the log file I have found

 

{"log":"}\n","stream":"stdout","time":"2024-04-24T11:16:36.312422879Z"}
{"log":"The secure keys for mqtt may have not been generated, you need to make 1 authenticated request via the API first for this to work\n","str>
{"log":"Failed to retrieve config file, creating new.\n","stream":"stdout","time":"2024-04-24T11:16:47.408770032Z"}
{"log":"Error: ENOENT: no such file or directory, open 'secure/mqttKeys'\n","stream":"stdout","time":"2024-04-24T11:16:56.313429941Z"}
{"log":"    at Object.openSync (node:fs:590:3)\n","stream":"stdout","time":"2024-04-24T11:16:56.313845917Z"}
{"log":"    at Object.readFileSync (node:fs:458:35)\n","stream":"stdout","time":"2024-04-24T11:16:56.313862841Z"}
{"log":"    at updateMQTT (/app/mqtt/index.js:382:19)\n","stream":"stdout","time":"2024-04-24T11:16:56.313876898Z"}
{"log":"    at Timeout._onTimeout (/app/mqtt/index.js:439:7)\n","stream":"stdout","time":"2024-04-24T11:16:56.313885199Z"}
{"log":"    at listOnTimeout (node:internal/timers:559:17)\n","stream":"stdout","time":"2024-04-24T11:16:56.313892732Z"}
{"log":"    at processTimers (node:internal/timers:502:7) {\n","stream":"stdout","time":"2024-04-24T11:16:56.313898864Z"}
{"log":"  errno: -2,\n","stream":"stdout","time":"2024-04-24T11:16:56.313904981Z"}
{"log":"  syscall: 'open',\n","stream":"stdout","time":"2024-04-24T11:16:56.31391113Z"}
{"log":"  code: 'ENOENT',\n","stream":"stdout","time":"2024-04-24T11:16:56.313917005Z"}
{"log":"  path: 'secure/mqttKeys'\n","stream":"stdout","time":"2024-04-24T11:16:56.313923134Z"}
{"log":"}\n","stream":"stdout","time":"2024-04-24T11:16:56.313929404Z"}
{"log":"The secure keys for mqtt may have not been generated, you need to make 1 authenticated request via the API first for this to work\n","str>
{"log":"Error: ENOENT: no such file or directory, open 'secure/mqttKeys'\n","stream":"stdout","time":"2024-04-24T11:17:16.315129599Z"}
{"log":"    at Object.openSync (node:fs:590:3)\n","stream":"stdout","time":"2024-04-24T11:17:16.315161179Z"}
{"log":"    at Object.readFileSync (node:fs:458:35)\n","stream":"stdout","time":"2024-04-24T11:17:16.315170932Z"}
{"log":"    at updateMQTT (/app/mqtt/index.js:382:19)\n","stream":"stdout","time":"2024-04-24T11:17:16.315192317Z"}
{"log":"    at Timeout._onTimeout (/app/mqtt/index.js:439:7)\n","stream":"stdout","time":"2024-04-24T11:17:16.315198664Z"}
{"log":"    at listOnTimeout (node:internal/timers:559:17)\n","stream":"stdout","time":"2024-04-24T11:17:16.315203648Z"}
{"log":"    at processTimers (node:internal/timers:502:7) {\n","stream":"stdout","time":"2024-04-24T11:17:16.315208523Z"}
{"log":"  errno: -2,\n","stream":"stdout","time":"2024-04-24T11:17:16.31521341Z"}
{"log":"  syscall: 'open',\n","stream":"stdout","time":"2024-04-24T11:17:16.315218275Z"}
{"log":"  code: 'ENOENT',\n","stream":"stdout","time":"2024-04-24T11:17:16.31522497Z"}
{"log":"  path: 'secure/mqttKeys'\n","stream":"stdout","time":"2024-04-24T11:17:16.315231808Z"}
{"log":"}\n","stream":"stdout","time":"2024-04-24T11:17:16.315236996Z"}
{"log":"The secure keys for mqtt may have not been generated, you need to make 1 authenticated request via the API first for this to work\n","str>
{"log":"Get VM Details for ip: 192.168.1.19 Failed\n","stream":"stdout","time":"2024-04-24T11:17:36.564266739Z"}
{"log":"Request failed with status code 500\n","stream":"stdout","time":"2024-04-24T11:17:36.56429392Z"}
{"log":"There was a problem retrieving a field for a docker image\n","stream":"stdout","time":"2024-04-24T11:17:36.593781823Z"}
{"log":"Cannot read properties of undefined (reading '0')\n","stream":"stdout","time":"2024-04-24T11:17:36.593810992Z"}

 

Edited by Puntoboy
Link to comment

Is there no way to slow down the polling frequency of the disks? Every 30 s is way too fast for me, my server rarely changes over a day or two.

 

Also, is there really no way to prevent unneccessary entities from the MQTT queue? I have 4 disks + a cache drive but the API seems to think I have 23 or so...

 

image.thumb.png.506abe8cc769976e3e2ed052e1508faa.png

Edited by emilgil
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.