Closed PocketMiner82 closed 2 weeks ago
Just to add, i've noticed as well that if a device becomes unreachable at some point, the particular device errors and then no longer updates.
Alright lads, please check out v1.3.0. :)
Tested by writing code to manually raise a ConnectionError, couldn't test it on hardware directly.
Hi @Breina,
I installed your updated version and at least for me it seems like the error unfortunately is not fixed. When Home Assistant is started and the server is not reachable, the integration errors out:
When I then plug in the server, the sensors remain unavailable (I did wait for over an hour). If I restart Home Assistant, the integration is able to connect to iDRAC and the sensors show the data.
I do not know (didn't test) if @cbrherms issue was fixed.
I also removed and re-added the integration to see if it makes any difference, but the behavior did not change.
Just to make sure we're on the same page, the integration needs to be set up when the server is active. It will then store stuff so that it can survive a restart if a server is unreachable. Subsequent restarts should be fine from then.
On my phone right now, will check your logs when I get home.
Hi @Breina,
I installed your updated version and at least for me it seems like the error unfortunately is not fixed. When Home Assistant is started and the server is not reachable, the integration errors out:
Log When I then plug in the server, the sensors remain unavailable (I did wait for over an hour). If I restart Home Assistant, the integration is able to connect to iDRAC and the sensors show the data.
I do not know (didn't test) if @cbrherms issue was fixed.
I also removed and re-added the integration to see if it makes any difference, but the behavior did not change.
Been a while since I looked at this but I branched and made a few janky changes that fixed my issue with the dropouts. I'd have to go back through what I changed locally though and whether I pushed that all up to the dev branch I was storing it on.
@Breina Admittedly can't remember how much testing i'd done with an idrac port being fully unreachable during homeasisstant startup (which i think is what @PocketMiner82 is saying), but i think this just needed the connection error catching and raising with ConfigEntryNotReady so that it'd try setting the platform up again once it became available https://github.com/cbrherms/idrac_power_monitor/commit/d65bc3bbcbb3f29507b2009d96f259c5d3119564 ?
While playing around with it I also added in a bunch of exception catching and also made use of setting the entity availability attribute when errors were raised which may be something to look in to? As i said though, janky, and mostly just picking a few things from the dev site and a few others from examples š I'm still trying to familiarise myself with python. lol.
Those are some good clues, thanks for the info!
Just to make sure we're on the same page, the integration needs to be set up when the server is active. It will then store stuff so that it can survive a restart if a server is unreachable. Subsequent restarts should be fine from then.
On my phone right now, will check your logs when I get home.
I set up the integration when the server was reachable, yes. My problem is exactly what cbrherms described: The iDRAC is unreachable when I start Home Assistant (I automatically restart Home Assistant, which I run on a Pi 4, every night - at this time the server is powered off and power is cut by the zigbee plug - that's how I discovered the issue). When Home Assistant starts, the integration only throws one error for each platform (that it can't set it up due to connection error) and then it doesn't retry to connect.
Edit: I just noticed that I wrote "setup" in the title, will update it š
@Breina I managed to fix the issue in #21
Released this as 1.4.0.
Thanks a lot PocketMiner! :)
The integration fails setup when the server is fully powered off - I use a smart plug to cut the power to the server when it is unused. When Home Assistant starts when the server is powered down, the integration fails to setup and never displays the server status, even if the server gets powered on afterwards.
Log
``` 2024-05-04 02:03:53.472 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up idrac_power platform for binary_sensor Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) OSError: [Errno 113] Host is unreachable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request self._validate_conn(conn) File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn conn.connect() File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 363, in connect self.sock = conn = self._new_conn() ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError:Moreover, if I try to reload the integration when it failed to setup, this error gets thrown:
Log
``` 2024-05-04 14:25:54.684 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry PowerEdge R630 for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 139, in async_setup_entry return await component.async_setup_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry raise ValueError("Config entry has already been setup!") ValueError: Config entry has already been setup! 2024-05-04 14:25:54.697 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry PowerEdge R630 for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 239, in async_setup_entry return await component.async_setup_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry raise ValueError("Config entry has already been setup!") ValueError: Config entry has already been setup! 2024-05-04 14:25:54.704 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry PowerEdge R630 for button Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 73, in async_setup_entry return await component.async_setup_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry raise ValueError("Config entry has already been setup!") ValueError: Config entry has already been setup! ```So it is impossible to get the server iDRAC status when powering on the server after home assistant without completely restarting home assistant.