Skip to content

Commit

Permalink
Add hibernate functionality #103
Browse files Browse the repository at this point in the history
Add hibernate functionality
Merge pull request #103 from padawarmik/main
  • Loading branch information
dougiteixeira authored Jul 21, 2023
2 parents a784735 + 508890a commit c6a6cdc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
11 changes: 8 additions & 3 deletions custom_components/proxmoxve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,14 @@ def call_api_post_status(
elif api_category is ProxmoxType.Node:
result = proxmox(["nodes", node, "status"]).post(command=command)
else:
result = proxmox(
["nodes", node, api_category, vm_id, "status", command]
).post()
if command == ProxmoxCommand.HIBERNATE:
result = proxmox(
["nodes", node, api_category, vm_id, "status", ProxmoxCommand.SUSPEND]
).post(todisk=1)
else:
result = proxmox(
["nodes", node, api_category, vm_id, "status", command]
).post()

except (ResourceException, ConnectTimeout) as err:
raise ValueError(
Expand Down
8 changes: 8 additions & 0 deletions custom_components/proxmoxve/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ class ProxmoxButtonEntityDescription(ProxmoxEntityDescription, ButtonEntityDescr
entity_registry_enabled_default=False,
translation_key="suspend",
),
ProxmoxButtonEntityDescription(
key=ProxmoxCommand.HIBERNATE,
icon="mdi:bed",
name="Hibernate",
api_category=ProxmoxType.QEMU,
entity_registry_enabled_default=False,
translation_key="hibernate",
),
ProxmoxButtonEntityDescription(
key=ProxmoxCommand.RESET,
icon="mdi:restart-alert",
Expand Down
1 change: 1 addition & 0 deletions custom_components/proxmoxve/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ProxmoxCommand(StrEnum):
RESET = "reset"
START_ALL = "startall"
STOP_ALL = "stopall"
HIBERNATE = "hibernate"


class ProxmoxKeyAPIParse(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/proxmoxve/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"issue_tracker": "https://github.com/dougiteixeira/proxmoxve/issues",
"loggers": ["proxmoxer"],
"requirements": ["proxmoxer==2.0.1"],
"version": "2.0.3"
"version": "2.0.4"
}
3 changes: 3 additions & 0 deletions custom_components/proxmoxve/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
},
"suspend": {
"name": "Suspend"
},
"hibernate": {
"name": "Hibernate"
}
},
"sensor": {
Expand Down
5 changes: 4 additions & 1 deletion custom_components/proxmoxve/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
},
"reset": {
"name": "Resetar"
},
"hibernate": {
"name": "Hibernar"
}
},
"sensor": {
Expand Down Expand Up @@ -224,4 +227,4 @@
}
}
}
}
}

0 comments on commit c6a6cdc

Please sign in to comment.