ateodorescu / home-assistant-addons

ipmi-server addon for Home Assistant
MIT License
12 stars 9 forks source link

[feature request] send ipmi commands from HA #11

Closed corgan2222 closed 8 months ago

corgan2222 commented 8 months ago

Hello,

is there a way to send ipmi commands? I have on server, where I switched the default server fans to silent noctua. But these needs higher rpm. So on each server restart I have to send

ipmitool -I lanplus -H 192.168.2.2 -U root -P $pw raw 0x30 0x30 0x01 0x00 so activate the manual fan control

and ipmitool -I lanplus -H 192.168.2.2 -U root -P $pw raw 0x30 0x30 0x02 0xff 0x64 to set all fans to 100%.

and my unraid server sometimes gets a kernel panic, where I have to send a ipmitool -I lanplus -H 192.168.2.241 -U admin -P $pw power cycle to reboot.

atm I have to do this manually. But it would be awesome to use these commands in HA automations.

Thanks in advance! Greetz Stefan

ateodorescu commented 8 months ago

@corgan2222 This is already supported. Check out this one https://github.com/ateodorescu/home-assistant-ipmi/issues/16 Sorry for the lack of documentation on the addon. Cheers, Adrian

corgan2222 commented 8 months ago

Hey Adrian,

fantastic! As an update to the answer from https://github.com/ateodorescu/home-assistant-ipmi/issues/16, the rest commands in HA don't need to be manually url-encoded if the content_type is set to "application/x-www-form-urlencoded".

Here is my config from the configuration.yaml

192.168.2.130 is the IP of my HA

rest_command:
  pf_enable_fan_rpm_cooling:
    url: "http://192.168.2.130:9595/command?params=-I lanplus -H 192.168.2.2 -U root -P password raw 0x30 0x30 0x01 0x00"
    method: put
    content_type: "application/x-www-form-urlencoded"

  pf_set_fan_rpm_100:
    url: "http://192.168.2.130:9595/command?params=-I lanplus -H 192.168.2.2 -U root -P password raw 0x30 0x30 0x02 0xff 0x64"
    method: put
    content_type: "application/x-www-form-urlencoded"

  pf_set_fan_rpm_80:
    url: "http://192.168.2.130:9595/command?params=-I lanplus -H 192.168.2.2 -U root -P password raw 0x30 0x30 0x02 0xff 0x50"
    method: put
    content_type: "application/x-www-form-urlencoded"

  pf_set_fan_rpm_50:
    url: "http://192.168.2.130:9595/command?params=-I lanplus -H 192.168.2.2 -U root -P password raw 0x30 0x30 0x02 0xff 0x32"
    method: put
    content_type: "application/x-www-form-urlencoded"

  unraid_power_cycle:
    url: "http://192.168.2.130:9595/command?params=-I lanplus -H 192.168.2.241 -U admin -P password power cycle"
    method: put
    content_type: "application/x-www-form-urlencoded"

test the service in the dev tools: grafik

Loveace Implementation: example with Grid Card:

grafik

square: true
type: grid
cards:
  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: call-service
      service: rest_command.pf_enable_fan_rpm_cooling
      target: {}
    name: enable pfsense FAN control
    icon: mdi:fan
    show_state: false
  - show_name: true
    show_icon: true
    type: button
    tap_action:
      action: call-service
      service: rest_command.pf_set_fan_rpm_100
      target: {}
    name: pfsense FAN 100%
    icon: mdi:fan-chevron-up
columns: 1

Now we only have to fix https://github.com/ateodorescu/home-assistant-addons/issues/10#issuecomment-1999258689 so that I read the fan speed. :)