Command_line Fail with 0.28.2


I am having trouble with the latest update 0.28.2 with command_line.

I have tried it in quotes and still the same problem.

  platform: command_line
       command_on: sudo python /home/hass/.homeassistant/pyfiles/ porch_on
       command_off: sudo python /home/hass/.homeassistant/pyfiles/ porch_off

and the error is

homeassistant.components.switch.command_line: Command failed: sudo python /home/hass/.homeassistant/pyfiles/ porch_on

It works fine if i login SSH to the RPi3.

Any Help please.

Does your shebang look something like this? #!/usr/bin/python3.4 ?

And you need the double quotes.

Your code looks fine, but the error leads me to believe that your hass user does not have sudo rights.

When you try it by logging in through ssh, are you running the command as the hass user or as root or pi? It will always work when testing from ssh as root or pi, but the hass account by default does not have a password and is not in the sudoers list, so unless you set a password for hass, I assumed you were testing as root or pi.

All commands from within Home Assistant are run as the hass user, so in order to use sudo from any command within Home Assistant, the hass user has to be in the sudoers list.

Edit /etc/sudoers as root, and at the bottom you will see a line:


Add hass down there so that it looks like this:


Now all commands with sudo will run without error

1 Like

@jbardi Wow that worked great.

Thank you very much.

No problem, glad everything is working again :slight_smile:

@jbardi - you are on fire today - that’s 3 solutions in the last 30 mins or so!

lol yeah, I’m an addict… I work from home, so I often take breaks throughout the day to work on my own home automation setup, and the first thing I do is check to see if there are any new updates to Home Assistant, AppDaemon or HADashboard before I get started, then I pop over to the forums to see whats new and I get sucked in reading every single new post, and before I know it, I’ve spent a few hours doddling around, not getting my own crap done in the house and not getting back to the day job LOL

There is still a lot I don’t know, so I’m learning things every day, so the least I can do is help out where I can :smiley:


Yeah, I work from home too - it’s very tempting to just dip in to the forum, or quickly add a new feature to AppDaemon :slight_smile:

1 Like