I’ve created a button that, when pressed, executes a command (remote via ssh). I wanted it to be a one-time switch, so when pressed, immediately returning to the off state. What I’ve done is the following:
I don’t think you should need the homeassistant.turn_off call? And you should be able to call it directly, something like service: script.reboot_button
For example
type: button
tap_action:
action: call-service
service: script.all_media_off
show_icon: true
show_name: true
name: Media Off
…which should simplify both the script and the lovelace portion. Not sure why you need a custom card?
There may be a better way of running a command line - not sure on that one.
Sorry to revive an old thread, but could you please share your full configuration for the button that calls your shell command? I’m trying to do something similar for a PTZ Camera to move to a Preset and nothing happens when I click my button. I created the Shell Command in my configuration.yaml and it shows in the system when I am setting the button to Call a Service.
The Shell Command documentation explains how to add the various commands to the configuration.yaml but then falls short of telling you how to actually use them in a dashboard.
James, if your shell command works when you test it in the Services tool, you should only need to change the service specified in the button config to your shell command service.