The Home Assistant Proxmox VE Integration only creates sensors for VM states, and does not yet provide a way to control those VMs. If you want to simply shutdown/startup a VM from Home Assistant, the
rest_command is your friend:
Create the API key in the Datacenter > Permissions > API Tokens. I had to uncheck
Privilege Separation. Replace the token name and UUID in the authorization header with what Proxmox spits out.
This will create a
command_vm service in Home Assistant you can use in automations. I use it to:
- Shutdown crypto mining VMs when incoming solar energy drops below a kW/h.
- Reset frozen MacOS vms after a few minutes of ping failure
The HASS service needs 2 data parameters, while a third called params is optional:
vmid is the qemu vm you’re commanding.
command is any of the appropriate status changes from the PVE API. Finally,
params are any extra data payloads to include, like timeout.
params should be formatted as url params, so multiple would be included like:
boolean values should be sent as 1/0, since ’true’ is sent as a string. You can control LXCs similarly, see the API docs for more