Skip to content

Commit

Permalink
Fix DeviceInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dougiteixeira committed Jul 20, 2023
1 parent aa6811a commit e3465d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
12 changes: 6 additions & 6 deletions custom_components/proxmoxve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def device_info(
DOMAIN,
f"{config_entry.entry_id}_{ProxmoxType.Node.upper()}_{node}",
)
default_model = api_category.upper()
model = api_category.upper()

elif api_category is ProxmoxType.Node:
coordinator = coordinators[node]
Expand All @@ -514,7 +514,7 @@ def device_info(
identifier = f"{config_entry.entry_id}_{api_category.upper()}_{node}"
url = f"https://{host}:{port}/#v1:0:=node/{node}"
via_device = ("", "")
default_model = model_processor
model = model_processor

if create:
device_registry = dr.async_get(hass)
Expand All @@ -523,9 +523,9 @@ def device_info(
entry_type=dr.DeviceEntryType.SERVICE,
configuration_url=url,
identifiers={(DOMAIN, identifier)},
default_manufacturer="Proxmox VE",
manufacturer="Proxmox VE",
name=name,
default_model=default_model,
model=model,
sw_version=proxmox_version,
hw_version=None,
via_device=via_device,
Expand All @@ -534,9 +534,9 @@ def device_info(
entry_type=dr.DeviceEntryType.SERVICE,
configuration_url=url,
identifiers={(DOMAIN, identifier)},
default_manufacturer="Proxmox VE",
manufacturer="Proxmox VE",
name=name,
default_model=default_model,
model=model,
sw_version=proxmox_version,
hw_version=None,
via_device=via_device,
Expand Down
11 changes: 2 additions & 9 deletions custom_components/proxmoxve/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,8 @@ class ProxmoxSensorEntityDescription(ProxmoxEntityDescription, SensorEntityDescr
value_fn: Callable[[Any], bool | str] | None = None
api_category: ProxmoxType | None = None # Set when the sensor applies to only QEMU or LXC, if None applies to both.


PROXMOX_SENSOR_DISK: Final[tuple[ProxmoxSensorEntityDescription, ...]] = (
ProxmoxSensorEntityDescription(
key=ProxmoxKeyAPIParse.CPU,
name="CPU used",
icon="mdi:cpu-64-bit",
native_unit_of_measurement=PERCENTAGE,
conversion_fn=lambda x: (x * 100) if x > 0 else 0,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
ProxmoxSensorEntityDescription(
key="disk_free",
name="Disk free",
Expand Down Expand Up @@ -307,6 +299,7 @@ class ProxmoxSensorEntityDescription(ProxmoxEntityDescription, SensorEntityDescr
*PROXMOX_SENSOR_UPTIME,
)


async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
Expand Down

0 comments on commit e3465d4

Please sign in to comment.