Restart button for Home Assistant on the front end

This is a pretty simple tip, but handy nonetheless.  When you’re busy configuring Home Assistant you’ll probably find yourself restarting it all the time.  So I decided to add a convenient button onto the front end to do it for me.

Basically, you just need to add a switch to the configuration file.  If you’ve set up Home Assistant with systemd according to the official documentation, this snippet should work nicely for you.  I found it gave an error “Failed to call service homeassistant/turn_on” when used.  That’s probably because the server has just been restarted and can’t “confirm” the action has been completed to the front end.

Note:  Do NOT use this unless you’re confident no one else is able to read your configuration file as it contains your password in plain text!
switch:
  platform: command_line
  switches:
    restart:
      command_on: "echo '<password>' | sudo -S systemctl restart home-assistant@<username>.service"
      command_off: "echo '<password>' | sudo -S systemctl restart home-assistant@<username>.service"

Leave a Reply

Your email address will not be published. Required fields are marked *