Categories
Home Assistant Linux Raspberry Pi

Home Assistant – How To Run Shell Command

This brief tutorial will show you how to run a shell command and how to use it to mount media from your NAS.

(This is being written because I spent way too much time searching for how to run a Shell Command in Home Assistant.)

First, you need to know what shell command you want to run. For the purpose of this tutorial, I wanted to mount my media from a separate computer into the media section in Home Assistant running Home Assistant OS 5.12 on a Raspberry Pi3.

Put this in the Home Assistant configuration.yaml:

shell_command:

mount_media_folder: mount -t cifs -o username=myname,password=mypassword,domain=WORKGROUP //192.168.50.223/Media /media
  • username=myname (this will be your login name used to access your server hosting the media)
  • password=mypassword (this will be your password used to access your server hosting the media)
  • domain=WORKGROUP (Workgroup is a peer to peer windows computer network and this is what most are named)
  • //192.168.50.223/Media (IP address and folder of your computer/server/NAS where your media is)

mount_media_folder” is going to be the name of your shell command.

This part: mount -t cifs -o username=myname,password=mypassword,domain=WORKGROUP //192.168.50.223/Media is basically what you would put in fstab to mount your share.

This part: /media is where it’s being mounted in Home Assistant. This will make it show up in the Media Browser in HA.

To run Shell Command

In Home Assistant, go to:

  • Developer Tools
  • Services
  • Service drop down box

Find shell_command.mount_media_folder and then click the “Call Service” button.

<end of tutorial!>

Leave a Reply

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