From bb55dbbea9bbf8499df736861ba490128fad32a7 Mon Sep 17 00:00:00 2001 From: dougiteixeira <31328123+dougiteixeira@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:49:50 -0300 Subject: [PATCH] Update --- custom_components/proxmoxve/__init__.py | 14 +++++++++++++- custom_components/proxmoxve/const.py | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/custom_components/proxmoxve/__init__.py b/custom_components/proxmoxve/__init__.py index 8f42234..519144b 100644 --- a/custom_components/proxmoxve/__init__.py +++ b/custom_components/proxmoxve/__init__.py @@ -62,6 +62,7 @@ ProxmoxNodeCoordinator, ProxmoxQEMUCoordinator, ProxmoxStorageCoordinator, + ProxmoxUpdateCoordinator, ) PLATFORMS = [ @@ -356,6 +357,17 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b coordinators[node] = coordinator_node if coordinator_node.data is not None: nodes_add_device.append(node) + + + coordinator_updates = ProxmoxUpdateCoordinator( + hass=hass, + proxmox=proxmox, + api_category=ProxmoxType.Update, + node_name=node, + ) + await coordinator_updates.async_refresh() + coordinators[f"{ProxmoxType.Update}_{node}"] = coordinator_updates + else: async_create_issue( hass, @@ -574,7 +586,7 @@ def device_info( ) model = api_category.capitalize() - elif api_category is ProxmoxType.Node: + elif api_category in (ProxmoxType.Node, ProxmoxType.Update): coordinator = coordinators[node] if (coordinator_data := coordinator.data) is not None: model_processor = coordinator_data.model diff --git a/custom_components/proxmoxve/const.py b/custom_components/proxmoxve/const.py index c5d3cfc..03e7b5f 100644 --- a/custom_components/proxmoxve/const.py +++ b/custom_components/proxmoxve/const.py @@ -44,6 +44,7 @@ class ProxmoxType(StrEnum): QEMU = "qemu" LXC = "lxc" Storage = "storage" + Update = "update" class ProxmoxCommand(StrEnum): @@ -81,3 +82,6 @@ class ProxmoxKeyAPIParse(StrEnum): NAME = "name" NETWORK_IN = "network_in" NETWORK_OUT = "network_out" + UPDATE_TOTAL = "total" + UPDATE_LIST = "updates_list" + UPDATE_AVAIL = "update"