Hi all,
I’m trying to setup a one-tap “Plex Server Off” button in Home Assistant for an Ubuntu Plex Server. Wake on LAN works perfectly via the normal WOL integrations section in HA;, the shutdown side is what I’m stuck on. I’m trying to setup a HA dashboard button that, when pressed, SSHes into the Ubuntu server and runs shutdown -h now, so the machine doesn’t get left running for days.
As regards the environment, I’m running Home Assistant OS (Green) - current 2025.x release., Terminal & SSH add-on is installed and working. And Advanced Mode is enabled. The target machine is an old Dell Optiplex running Ubuntu Server and an XFCE desktop. I can control it with a bluetooth keyboard/trackpad and a 5 inch HDMI monitor in a pinch, but I want my wife to be able to turn it on and off via the ipad in the kitchen (HA app is installed on the ipad). SSH access is working on the ubuntu server and sudo /sbin/shutdown -h now works normally when run manually on the ubuntu/plex server.
-
Passwordless SSH from Home Assistant is confirmed working.
ssh -i /config/ssh/id_ed25519 [email protected] echo ok
returns ok
On the Ubuntu server, sudoers contains:
mccabesplexserver ALL=NOPASSWD: /sbin/shutdown -
The shell_command is defined and visible:
In/config/configuration.yaml:
shell_command:
plex_server_shutdown: >
ssh -i /config/ssh/id_ed25519
[email protected]
sudo /sbin/shutdown -h now
Home Assistant was restarted, and
shell_command.plex_server_shutdown appeared in Developer Tools → Actions.
-
I created an input helper button called “Plex Server off” with an entity ID of input_button.plex_server_off
-
I created an automation via UI, it’s a state trigger input_button.plex_server_off that performs the action: shell_command.plex_server_shutdown
-
I created a button card using shell_command.plex_server_shutdown
It appears and is pressable
When I press the dashboard button (pictured), nothing happens - the plex server doesn’t shut down. Pressing it multiple times has no effect. The Wake-on-LAN command works perfectly fine from the same dashboard so its not a connectivity issue. Appreciate any guidance, thank you in advance.
