Mapping button to a command line or shell command

Hi,

Running the latest Home Assistant as a VM and have been trying to figure out how to run a remote command via SSH. I have my command working from the terminal but can’t seem to figure out how to map it to a button. I’ve tried configuring both a shell command and command line as seen below:

shell_command:
  wol: "ssh -o UserKnownHostsFile=/config/.ssh/known_hosts_2 USERNAME@IPADDRESS -i /config/.ssh/id_ed25519 'sudo etherwake MAC-ADDRESS'"

command_line:
  - binary_sensor:
      command: "ssh -o UserKnownHostsFile=/config/.ssh/known_hosts_2 USERNAME@IPADDRESS -i /config/.ssh/id_ed25519 'sudo etherwake MAC-ADDRESS'"
      name: "wol"

There’s been a lot of helpful topics I found but either I’m not doing it right or the examples I’m trying to follow are from older versions of HA and might be deprecated? I don’t know but my end goal is to map either a command line or shell command to a button on my dashboard. Any ideas on a way to implement that? Thanks!

Why not use the wake on lan integration. Wake on LAN - Home Assistant

I had been using that and it works great but unfortunately the computer I’m trying to wake connects via wifi. Even though the motherboard is fairly new it doesn’t appear to support WOWLAN so the alternative is to use an old raspberry pi to wake it via ssh.

Looks like I needed to restart home assistant and not just reload the yaml for my shell_command to appear in automations as an available action. Doesn’t appear to be as reliable as WOL. :frowning:

I fought with this for a couple of days as well until I realized I could map a switch instead of a binary_sensor to the command. Try this:

command_line:
  - switch:
      command_on: "ssh -o UserKnownHostsFile=/config/.ssh/known_hosts_2 USERNAME@IPADDRESS -i /config/.ssh/id_ed25519 'sudo etherwake MAC-ADDRESS'"
      name: "wol"