Allow to map "Command Line" to a button entity

The command_line integration allows to create switch, cover entities etc, but doesn’t support button entity.
For example, I want to create a button entity that would SSH and suspend my PC. Currently, i do it by creating a switch and mapping that to a button entity, which is a bit hacky.
Here’s how button entity support for the command_line could look like:

command_line:
  - button:
      name: PC Suspend
      unique_id: pc_suspend
      command_press: "ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no user@MY_IP sudo systemctl suspend"

Actually it would be:

shell_command:
  pc_suspend: "ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no user@MY_IP sudo systemctl suspend"

template:
  button:
    - name: PC Suspend
      press:
        - service: shell_command.pc_suspend

Yes, that’s valid, but has unneccesary complexity. I would just like if the command_line integration supported the button natively. I’m sure others have many usecases for this too. And newcomers would need less time to implement this too, since they wouldn’t have to learn how to create button tempalte.

1 Like

Less complexity is better, it works, so why change it?

button.press service calls don’t support variables where the shell_command services do. This is essentially a show stopper for this feature request.