How can I use ipmitool in a script to power On / Off a server?

I’ve got a Dell PowerEdge server I use as a lab for work. It’s fairly power hungry and doesn’t need to be on all the time (although not neccessarily on a fixed schedule). I’d like to expose a button in HA that I can use to trigger a power down / power up event, and (if possible) monitor it’s current status.

I can achieve this directly from a remote PC using ipmitool and issuing the following commands:

ipmitool -I lanplus -H -U Admin -P <password> power status
ipmitool -I lanplus -H -U Admin -P <password> power on
ipmitool -I lanplus -H -U Admin -P <password> power off

I can’t (currently) run this directly within HA as ipmitool isn’t available locally within the docker container. I thought about running it remotely on an external server but a) feels clunky and more fragile and b) not sure how to achieve this.

I’m also not that familiar with using script command within HA and am not sure on best way to create a switch button with status to achieve this. Any ideas?!

Add chassis before power :slight_smile:

  server_poweron: "ipmitool -I lanplus -H -U username -P password chassis power on"

I cannot run ipmi commands from the shell command. It returns code 127