Fma965

Community Developer
  • Posts

    175
  • Joined

  • Last visited

Everything posted by Fma965

  1. I will be starting a new thread for this plugin as this has become more than what the OP originally created.
  2. This will allow you to get raw values. i am working on getting the dashboard code working properly, being able to be moved etc and then will release.
  3. Upon further inspection of the code i can see there is already work in progress code for an API in 6.8 via a plugin called unraid.net so this may solve my issue, it doesn't solve the OP's issue though. in the /boot/config/plugins/dynamix/dynamix.cfg file you have this [remote] apikey="bbff6d7320a3cfa74964c58b5c5d3b0XXXXXXXXXXXXXXXXXXXXXXe2bc79518f2e4f0c4" wanaccess="no" wanport="0"
  4. Upon further inspection of the code i can see there is already work in progress code for an API in 6.8 via a plugin called unraid.net so this kinda makes my program redundant. in the /boot/config/plugins/dynamix/dynamix.cfg file you have this [remote] apikey="bbff6d7320a3cfa74964c58b5c5d3b0XXXXXXXXXXXXXXXXXXXXXXe2bc79518f2e4f0c4" wanaccess="no" wanport="0" { "data": { "vars": { "version": "6.8.0", "port": 965 }, "disks": [ { "device": "/dev/sda", "type": "HD", "name": "Extreme" }, { "device": "/dev/sdb", "type": "SSD", "name": "MTFDDAK256MAM-1K12" }, { "device": "/dev/sdc", "type": "SSD", "name": "Crucial_CT250MX200SSD4" }, { "device": "/dev/sdd", "type": "HD", "name": "ST2000LM007-1R8174" }, { "device": "/dev/sde", "type": "SSD", "name": "LITEON_LCH-256V2S-HP" }, { "device": "/dev/sdf", "type": "HD", "name": "WDC_WD5000AAKX-60U6AA0" }, { "device": "/dev/sdg", "type": "HD", "name": "WDC_WD20EZRZ-00Z5HB0" }, { "device": "/dev/sdh", "type": "SSD", "name": "SAMSUNG_MZ7PD256HCGM-000H7" }, { "device": "/dev/sdi", "type": "HD", "name": "WDC_WD20EZRZ-00Z5HB0" }, { "device": "/dev/sdj", "type": "HD", "name": "WDC_WD20EZRZ-00Z5HB0" }, { "device": "/dev/sdk", "type": "SSD", "name": "MTFDDAK256MAM-1K12" }, { "device": "/dev/sdl", "type": "HD", "name": "ST2000DM008-2FR102" }, { "device": "/dev/nvme0n1", "type": "NVMe", "name": "Samsung_SSD_960_EVO_250GB" } ] } } looks like Unraid API is definitely a thing in 6.8 and therefore completely makes this quick plugin redudant.
  5. i finish work at 4pm (UK Time) i will get this done then
  6. Yes i saw that, haven't looked in to it yet, it uses MQTT from my understanding, i already have a MQTT broker so thats simple. Please note this plugin is going to break in 6.8 but i have looked through the nginx configuration files in and can see references to a node REST api at /api, it doesn't currently work but it shows limetech / dynamix is working on a API
  7. So i looked at the nginx conf for unraid 6.7 deny all; auth_basic "unRAID"; auth_basic_user_file /etc/nginx/htpasswd; the 6.8 config is this deny all; auth_request /auth_request.php; There is no reason at all that i can think of on why you can't have it fall back to BASIC auth if the php auth_request fails I do similar to the following for services like sonarr, radarr, lidarr, ombi, etc by using the organizr auth_request and if organizr fails to verify i'm valid then it falls back to auth_basic for use by things like NZB360 a android app for sonarr/radarr/lidarr/nzbget etc. auth_request /auth_request.php; satisfy any; auth_basic "Unraid"; auth_basic_user_file /etc/nginx/htpasswd; EDIT: here are the dumped config, auth and login files from 6.7 / 6.8 (htpasswd is obviously just a htpasswd file) https://gist.github.com/Fma965/0d79beeece0a52969ec22093b9e70990 I see there are mentions of a node REST api so that looks promising but i still think it's wrong to disable the only programmatic access to unraid before a API is implemented.
  8. No worries, there are a few workaround options but they are clunky and unnecessary, really some sort of programmatic login should be added to unraid. Whether it's a simple ?apikey= or something more complicated. Either way me and my friend will see what workaround we come up with.
  9. Please note this does not work on unraid 6.8 due to the removal of basic auth and the change to form authentication. There are a few workaround options for this but really limetech should consider a API system or key in this day and age. Basically every other application out there has one now a days.
  10. This is a bad decision. There is no reason to be stopping support for basic auth you can easily do both I literally run form auth and if it fails fall back to basic auth. Just like applications like sonarr, radarr, lidarr, etc can. This breaks a lot of external access to plugin files. I imagine this might break the controlr plugin and also breaks my JSON API plugin it also stops me adding my stats from the Corsair power supply plugin to my home assistant installations. If you are going to implement form authentication you really need to have a method to programmatically access unraid such as a API key or something.
  11. Is it possible to revert back to basic authentication? It's useful for externally grabbing data for example for my JSON API Perhaps a option? I haven't personally checked yet but had a issue raised on my plugin about it not working on 6.8
  12. Thanks, my friend is going to look in to a companion custom home assistant component but he is super busy currently so not sure when he will get it done. In the meantime the workaround sensor attributes works. It's possible there are other files used by unraid that might be usable in different folders so I'm happy to add others if they are relevant.
  13. Guys be aware that the repo has changed and therefore the already installed versions won't update any more, your best way around this is to remove the plugin and install it from the community apps plugin or with the updated URLS on https://github.com/CyanLabs/corsairpsu-unraid
  14. Thanks. i will add this to the community apps once i figure out the process
  15. Just to clarify, due to limitations afaik in the Unraid plugin system this does require basic auth when accessing the json. example snippet of HA code would be this - platform: rest resource: "http://TOWER/plugins/jsonapi/api.php?file=XXX.ini" username: root password: !secret unraid_password authentication: basic
  16. Anyone using HA may also want to check out which i just created
  17. Introduction I recently modified the Corsair PSU plugin and made it easier to add to applications that can use REST such as Home Assistant, this got me thinking what i if i wrap the ini files used by emhttp in to JSON so i can get WAY WAY more statistics in Home Assistant from Unraid and so this plugin was created. super simple at only about 6 lines of PHP code. https://community.home-assistant.io/t/unraid-json-api/158652 This plugin is a wrapper for reading the files used by Unraid / emhttpd for displaying various statistics, the files are read from /var/local/emhttp/*.ini and are converted to JSON for easy access by services/applications like Home Assistant This plugin has no 'frontend' and is only accessible directly via http://TOWER/plugins/jsonapi/api.php?file=XXX.ini for example to get the disks.ini file you would do http://TOWER/plugins/jsonapi/api.php?file=disks.ini currently the following files exist that can be used but it's dynamic so if new files are added in new versions of Unraid in the same folder then these will be usable also. cpuload.ini devs.ini diskload.ini disks.ini monitor.ini network.ini sec.ini sec_afp.ini sec_nfs.ini shares.ini users.ini var.ini Usage Plugins > Install Plugin https://raw.githubusercontent.com/Cyanlabs/jsonapi-unraid/master/jsonapi.plg Source: https://github.com/Cyanlabs/jsonapi-unraid I will add some Home Assistant examples once i determine the best way. NOTE: please note that this currently is a raw json output, a custom HA component would be the best way to access this data but it is possible without a custom component (HA has a 255 character REST sensor state limit) - platform: rest name: Unraid resource: "http://192.168.1.3:965/plugins/jsonapi/api.php?file=disks.ini" username: root json_attributes: - disk1 - disk2 password: !secret unraid_password authentication: basic value_template: '{{ value_json["disk1"]["status"] }}' headers: User-Agent: Home Assistant Content-Type: application/json despite it not being able to do more than 255 you can work around it with the attributes, the above code will show something like this and you can access specific values with like this My python isn't great but i believe this is a good starting point - https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/pvoutput/sensor.py Things like CPU load are easy though sensor: - platform: rest name: Unraid CPU resource: "http://192.168.1.3:965/plugins/jsonapi/api.php?file=cpuload.ini" username: root password: !secret unraid_password authentication: basic value_template: '{{ value_json["cpu"]["host"] }}' headers: User-Agent: Home Assistant Content-Type: application/json @LintHart thanks for the idea of integrating the PSU statistics in to Home Assistant and therefore making this an idea for me to create
  18. No worries, any issues let me know, the code for the redesigned dashboard is janky so if something breaks the dashboard on a new unraid version my first guess would be this plugin if anything.
  19. sensor: - platform: rest name: Corsair PSU json_attributes: - temp1 - temp2 - fan_rpm - capacity - 12v_watts - 5v_watts - 3v_watts - watts - load - uptime - poweredon resource: "http://TOWER/plugins/corsairpsu/status.php" username: root password: !secret unraid_password authentication: basic value_template: '{{ value_json.product }}' headers: User-Agent: Home Assistant Content-Type: application/json @LintHart This code works and will get all those attributes in to a sensor called sensor.corsair_psu you can also seperate them in to seperate sensors if you wanted with this code sensor: - platform: template sensors: psu_temp1: friendly_name: 'Temperature 1' value_template: '{{ states.sensor.corsair_psu.attributes["temp1"] }}' psu_temp2: friendly_name: 'Temperature 2' value_template: '{{ states.sensor.corsair_psu.attributes["temp2"] }}' psu_fan_rpm: friendly_name: 'Fan Speed' value_template: '{{ states.sensor.corsair_psu.attributes["fan_rpm"] }}' psu_capactiy: friendly_name: 'Capacity' value_template: '{{ states.sensor.corsair_psu.attributes["capacity"] }}' psu_12v_watts: friendly_name: '12v Watts' value_template: '{{ states.sensor.corsair_psu.attributes["12v_watts"] }}' psu_5v_watts: friendly_name: '5v Watts' value_template: '{{ states.sensor.corsair_psu.attributes["5v_watts"] }}' psu_3v_watts: friendly_name: '3v Watts' value_template: '{{ states.sensor.corsair_psu.attributes["3v_watts"] }}' psu_watts: friendly_name: 'Current Load' value_template: '{{ states.sensor.corsair_psu.attributes["watts"] }}' psu_load: friendly_name: 'Current Load Percentage' value_template: '{{ states.sensor.corsair_psu.attributes["load"] }}' psu_uptime: friendly_name: 'Uptime' value_template: '{{ states.sensor.corsair_psu.attributes["uptime"] }}' psu_poweredon: friendly_name: 'Total Power On Hours' value_template: '{{ states.sensor.corsair_psu.attributes["poweredon"] }}' I will likely tweak it to add raw values in the php file so you can get temp1 which would be 45°c or you can get temp1_raw which would be just 45 instead of 45°c
  20. only my new version supports the new layout my understanding is something like this, replace value_json.temp1 with value_json.XXXX depending on which value you want. - platform: rest resource: "http://192.168.1.3:965/plugins/corsairpsu/status.php" username: root password: !secret unraid_password authentication: basic value_template: '{{ value_json.temp1 }}' headers: User-Agent: Home Assistant Content-Type: application/json EDIT: just tested it works.
  21. I use home assistant my self. I could potentially implement a .PHP?value=temp1 or .PHP?value=fan_rpm etc but I think ha can just parse the JSON anyway
  22. I would personally pull from http://TOWER/plugins/corsairpsu/status.php instead of ssh Your layout is the same as mine so I expect all PSU will be output 0 is 12v and output 1 is 5v and output 2 is 3.3v. my new dashboard panel version auto detects this anyway This is the output of the php page { "temp1":"44.2 \u00b0c", "temp2":"37.2 \u00b0c", "fan_rpm":"0.0 RPM", "capacity":"1000W", "12v_watts":"72.0W", "5v_watts":"24.5W", "3v_watts":"11.0W", "watts":"106.0W", "load":"11%", "vendor":"CORSAIR", "product":"RM1000i", "uptime":"6d. 12h", "poweredon":"159d. 3h" }
  23. I plan on adding progress/percent bars if i figure out how the existing progress bars work on the dashboard not released yet, code is super messy UPDATE: Now released. please note that currently this uses a bit of a hack to make it work as a dashboard panel, it doesn't currently support moving the panel (well it does move but it wont stick) i know a way to fix this but haven't got the time to do this right now, it's christmas lol. Beta version as shown above can be downloaded from https://raw.githubusercontent.com/Cyanlabs/corsairpsu-unraid/beta/corsairpsu.plg
  24. i'm also working on a proper "dashboard" panel, the code works just deciding how to lay it out now. and the code is a bit messy as there is no official way to hook in to the dashboard panels.
  25. interesting... i was looking at hacky methods and i found my own way but will defintely check this plugin out to see