Breina / idrac_power_monitor

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

Add support for iDRAC9 #19

Open haydonryan opened 1 month ago

haydonryan commented 1 month 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 1 month 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.