Skip to content

Commit

Permalink
Fix deletion of repairs/issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dougiteixeira committed May 19, 2024
1 parent 5f9febd commit 693e7d3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
10 changes: 5 additions & 5 deletions custom_components/proxmoxve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from homeassistant.helpers.issue_registry import (
IssueSeverity,
async_create_issue,
async_delete_issue,
delete_issue,
)
from homeassistant.helpers.typing import ConfigType

Expand Down Expand Up @@ -348,7 +348,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
node_proxmox["node"]
for node_proxmox in (nodes_api if nodes_api is not None else [])
]:
async_delete_issue(
delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{node}_resource_nonexistent",
Expand Down Expand Up @@ -418,7 +418,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
(int(resource["vmid"]) if "vmid" in resource else None)
for resource in (resources if resources is not None else [])
]:
async_delete_issue(
delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{vm_id}_resource_nonexistent",
Expand Down Expand Up @@ -455,7 +455,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
(int(resource["vmid"]) if "vmid" in resource else None)
for resource in (resources if resources is not None else [])
]:
async_delete_issue(
delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{container_id}_resource_nonexistent",
Expand Down Expand Up @@ -492,7 +492,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
(resource.get("storage", None))
for resource in (resources if resources is not None else [])
]:
async_delete_issue(
delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{storage_id}_resource_nonexistent",
Expand Down
4 changes: 2 additions & 2 deletions custom_components/proxmoxve/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.helpers.issue_registry import (
IssueSeverity,
async_create_issue,
async_delete_issue,
delete_issue,
)

from .const import (
Expand Down Expand Up @@ -168,7 +168,7 @@ def post_api_command(
f"Proxmox {resource} {command} error - {error}",
) from error

async_delete_issue(
delete_issue(
self.hass,
DOMAIN,
issue_id,
Expand Down
10 changes: 5 additions & 5 deletions custom_components/proxmoxve/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from homeassistant.helpers.issue_registry import (
IssueSeverity,
async_create_issue,
async_delete_issue,
delete_issue,
)

from .api import ProxmoxClient, get_api
Expand Down Expand Up @@ -370,7 +370,7 @@ async def async_process_selection_changes(
entry_id=self.config_entry.entry_id,
device_identifier=identifier,
)
async_delete_issue(
delete_issue(
self.hass,
DOMAIN,
f"{self.config_entry.entry_id}_{node}_resource_nonexistent",
Expand Down Expand Up @@ -411,7 +411,7 @@ async def async_process_selection_changes(
entry_id=self.config_entry.entry_id,
device_identifier=identifier,
)
async_delete_issue(
delete_issue(
self.hass,
DOMAIN,
f"{self.config_entry.entry_id}_{qemu_id}_resource_nonexistent",
Expand All @@ -435,7 +435,7 @@ async def async_process_selection_changes(
entry_id=self.config_entry.entry_id,
device_identifier=identifier,
)
async_delete_issue(
delete_issue(
self.hass,
DOMAIN,
f"{self.config_entry.entry_id}_{lxc_id}_resource_nonexistent",
Expand All @@ -457,7 +457,7 @@ async def async_process_selection_changes(
entry_id=self.config_entry.entry_id,
device_identifier=identifier,
)
async_delete_issue(
delete_issue(
self.hass,
DOMAIN,
f"{self.config_entry.entry_id}_{storage_id}_resource_nonexistent",
Expand Down
13 changes: 6 additions & 7 deletions custom_components/proxmoxve/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from homeassistant.helpers.issue_registry import (
IssueSeverity,
async_create_issue,
async_delete_issue,
delete_issue,
)
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
Expand Down Expand Up @@ -792,6 +792,11 @@ def permission_to_resource(
return "Unmapped"

try:
delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{resource_id}_forbiden",
)
return get_api(proxmox, api_path)
except AuthenticationError as error:
raise ConfigEntryAuthFailed from error
Expand Down Expand Up @@ -824,9 +829,3 @@ def permission_to_resource(
)
return None
raise UpdateFailed from error

async_delete_issue(
hass,
DOMAIN,
f"{config_entry.entry_id}_{resource_id}_forbiden",
)
3 changes: 3 additions & 0 deletions custom_components/proxmoxve/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ def native_value(self) -> StateType:
elif self.entity_description.key in (
ProxmoxKeyAPIParse.CPU,
ProxmoxKeyAPIParse.UPDATE_TOTAL,
ProxmoxKeyAPIParse.MEMORY_USED,
ProxmoxKeyAPIParse.DISK_USED,
ProxmoxKeyAPIParse.SWAP_USED,
):
return 0
else:
Expand Down

0 comments on commit 693e7d3

Please sign in to comment.