Fix Proxmox VE availability on failed updates (#185500)

This commit is contained in:
Erwin Douna
2026-10-09 17:16:22 +02:00
committed by GitHub
parent bd575cd292
commit 8153a69eac
2 changed files with 38 additions and 4 deletions
+1 -2
View File
@@ -103,10 +103,9 @@ class ProxmoxNodeUpdateEntity(ProxmoxNodeEntity, UpdateEntity):
@property
@override
# pylint: disable-next=home-assistant-coordinator-entity-available
def available(self) -> bool:
"""Return if the update platform is available."""
return self._update_info() is not None
return super().available and self._update_info() is not None
@override
def release_notes(self) -> str | None:
+37 -2
View File
@@ -2,16 +2,19 @@
from unittest.mock import MagicMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
import requests
from syrupy.assertion import SnapshotAssertion
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE, Platform
from homeassistant.components.proxmoxve.coordinator import DEFAULT_UPDATE_INTERVAL
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import AUDIT_PERMISSIONS, MERGED_PERMISSIONS, setup_integration
from tests.common import MockConfigEntry, snapshot_platform
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
from tests.typing import WebSocketGenerator
ENTITY_ID = "update.pve1_software_update"
@@ -123,6 +126,38 @@ async def test_update_unavailable_on_permission_change(
assert state.state == STATE_UNAVAILABLE
async def test_update_unavailable_on_failed_update(
hass: HomeAssistant,
mock_proxmox_client: MagicMock,
mock_config_entry: MockConfigEntry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test that the update entity is unavailable while the coordinator update fails."""
mock_proxmox_client.access.permissions.get.return_value = MERGED_PERMISSIONS
with patch(
"homeassistant.components.proxmoxve.PLATFORMS",
[Platform.UPDATE],
):
await setup_integration(hass, mock_config_entry)
assert hass.states.get(ENTITY_ID).state == STATE_ON
mock_proxmox_client.nodes.get.side_effect = requests.exceptions.ConnectionError
freezer.tick(DEFAULT_UPDATE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done(wait_background_tasks=True)
assert hass.states.get(ENTITY_ID).state == STATE_UNAVAILABLE
mock_proxmox_client.nodes.get.side_effect = None
freezer.tick(DEFAULT_UPDATE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done(wait_background_tasks=True)
assert hass.states.get(ENTITY_ID).state == STATE_ON
async def test_update_up_to_date(
hass: HomeAssistant,
mock_proxmox_client: MagicMock,