I wanted to add a button to Home Assistant that would turn on my remote server via IPMI. I also did not want to add the ipmitool dependencies to my #HASS container. Since IPMI supports redfish, a simple rest command in home assistant is enough. Add this to your `configuration.yaml`:
```yaml
rest_command:
# Command to turn the server ON
server_power_on:
url: "https://192.168.100.111/redfish/v1/Systems/1/Actions/ComputerSystem.Reset"
method: post
username: "hass"
password: "eX4mP13p455w0Rd"
verify_ssl: false
headers:
Content-Type: "application/json"
payload: '{"ResetType": "On"}'
# Command to gracefully shut down the OS via IPMI (ACPI signal)
server_power_off:
url: "https://192.168.100.111/redfish/v1/Systems/1/Actions/ComputerSystem.Reset"
method: post
username: "hass"
password: "eX4mP13p455w0Rd"
verify_ssl: false
headers:
Content-Type: "application/json"
payload: '{"ResetType": "GracefulShutdown"}'
sensor:
- platform: rest
name: "Server Power State"
resource: "https://192.168.100.111/redfish/v1/Systems/1"
method: GET
username: "hass"
password: "eX4mP13p455w0Rd"
verify_ssl: false
scan_interval: 10 # Checks every 10 seconds
value_template: "{{ value_json.PowerState }}"
template:
- switch:
- name: "Server"
state: "{{ is_state('sensor.server_power_state', 'On') }}"
icon: >-
{% if is_state('sensor.server_power_state', 'On') %}
mdi:server-network
{% else %}
mdi:server-network-off
{% endif %}
turn_on:
action: rest_command.server_power_on
turn_off:
action: rest_command.server_power_off
```
Make sure to create a separate IPMI user with "Operator" privileges (allowed to start/shutdown, but not to modify settings). If you have e.g. #Proxmox on the server, it will receive the IPMI Graceful Shutdown command and cleanly stop all VMs before exiting.
Works great!
#hass #homeassistant #redfish #api #ipmi #supermicro #homelab