Breina / idrac_power_monitor

HomeAssistant integration to monitor the power of a server through its iDrac's Redfish API
30 stars 19 forks source link

Add support for iDRAC9 #19

Open haydonryan opened 5 months ago

haydonryan commented 5 months ago

Hi Breina, I'm running an r7515 that has idrac9 enterprise. After building the curl commands for a cli on /off switch for homeassitant I found your integration.

Happy to say that it runs... Mostly. Screenshot from 2024-05-21 12-22-04

  1. When using the power on control - HA spits an error below but it does turn on the server.

  2. I also noticed that the server status says Running - regardless of if the power is on or not. Is this really detecting if idrac is running or reporting the power-on status of the system? Would you consider adding a separate status for poweron status?

  3. Would you consider adding a graceful shutdown control? (I'm thinking of the usecase for a start of day /end of day turn lab on / off automation.

  4. It looks like the integration isn't detecting fan speeds, as no controls sensors for these are here.

Great work on this integration! Love the work put in! I'm happy to test patches on my setup. Haydon.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 12:18:06 PM (1 occurrences)
Last logged: 12:18:06 PM
[140095097510592] Expecting value: line 1 column 1 (char 0)

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2173, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2210, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
    await self.async_press()
  File "/config/custom_components/idrac_power/button.py", line 63, in async_press
    await self.hass.async_add_executor_job(self.rest.power_on)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/idrac_power/idrac_rest.py", line 78, in power_on
    json = result.json()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Breina commented 5 months ago

I appreciate the report!

iDRAC9 uses a different Redfish version, they're going to be incompatible I'm afraid.

image

https://www.dell.com/support/kbdoc/en-us/000178045/redfish-api-with-dell-integrated-remote-access-controller


While I could, I don't want to implement devices that I don't own. That requires a lot of back and forth, and tends to drag on for months. I've tried this in the past and decided it's not worth it for me. Sorry for that. :(

I'll leave this open for anyone wanting to implement iDRAC9 compatibility. Whenever I buy a new server, I'll make sure to get one with iDRAC9.

bestycame commented 3 months ago

Hello Breina, haydonryan

My own two cents...

  1. When using the power on control - HA spits an error below but it does turn on the server.: I am having the same issue on my iDRAC 7 machine. The issue was the API returning a 204 response without any contents. It was not able to parse the JSON response (as it was empty). If it's the same root-cause this should be fixed by PR #22.

  2. I also noticed that the server status says Running - regardless of if the power is on or not. Is this really detecting if idrac is running or reporting the power-on status of the system? Would you consider adding a separate status for poweron status?: Will look into it if I get the chance: I have also issues with the server status being reported as Running while it's not. But not always the case 🤷

  3. Would you consider adding a graceful shutdown control? (I'm thinking of the usecase for a start of day /end of day turn lab on / off automation. Being implemented as we speak :). This is exactly my use-case and the reason I'm preparing #22 :).

loso2255 commented 3 months ago

hi, guys i'm working in a equal project for my two dell r720 and recently i found you

in these days of dev my integration i found this 2 other project can help you during dev end testing a redfish api

fake server redfish: https://github.com/DMTF/Redfish-Mockup-Server note: this server does not require auth

generator of json file using dell phisical server, https://github.com/DMTF/Redfish-Mockup-Creator

i hope this can be useful, now i'm searcing a method to find redfish version the server i using. because i want to create a general integration and i think in the path: