Problem with executing "net rpc shutdown"

Hey guys.

I have a problem with executing “net rpc shutdown -r -f -I 192.168.X.XX -U user%password” command from Hass.io. I tried to execute command from “pi” user and it works. My yaml configuration is below. No errors from check config Hass.io What I`m doing wrong? Thank you in advance for advice.

  shell_command: !include shell_command.yaml

  script:
    restart_workstation:
       sequence:
         alias: Restart Workstation
         service: shell_command.restart_pc

  shell_command: restart_pc: "net rpc shutdown -r -f -I 192.168.X.XX -U user%password"

  group:
     workstation:
         name: name
         control: hidden
         entities:
            - switch.wol
            - script.restart_workstation

  workstation_view:
    name: name
    view: true
    control: hidden
    icon: mdi:airplay
    entities:
       - group.workstation

O.o

There is no “pi” user on hassio.

No, I mean: I connect to Raspberry Pi from WinSCP as a “pi” user and the command is working. But from Hass.io it doesn`t work.

How do you connect?

As root to port 22 or port 22222?

As user ‘pi’?

What did you install on your Pi? Hassio or Hassbian or Home Assistant on Raspbian?

Hassio does not have a pi user and when you SSH in to the add-on, you are SSHing into a different container than what home assistant is running. If you SSH into 22222 on the host, there is nothing related directly to home assistant there.

Explaining your configuration is important.

I`m connecting to IP address of Pi port 23 as “pi” user and I use Hass.io.

You are not using hassio if you are logging in to Raspbian as pi.

To the error at hand, what do your logs tell you?

I wrote it in my first post :wink: When I am connected as “pi” user from WinSCP the command works. But from Hass.io the same command in my shell script doesn`t work. So my question is: What I have to do for working command :blush:

You never mentioned anything about what the logs say…

Find out what the logs tell you about why it doesn’t run…

Log Details (ERROR)
Error running command: net rpc shutdown -r -f -I 192.168.X.XX -U user%pass, return code: 127
NoneType: None

18:23 /usr/lib/python3.6/site-packages/homeassistant/components/shell_command.py (ERROR)

Just in case you don’t know, you can safely post your internal IP addresses on forums. Nobody can route to your 192.168 subnets. :wink:

First things first, you say it works if you run it manually. You run that exact command manually?

Do you have the SAMBA package installed?

https://prefetch.net/blog/2009/05/31/shutdown-a-windows-machine-from-the-unix-command-line/

Requires samba-common package installed.

Your OP appears to have some mangled yaml. Are you sure your config yaml is correct? Correct spaces?

You list shell_command: and shell_commands:. For what reason?

Yes, I have installed samba packages and Samba add-on too. Shell_script(s) it’s just a mistake, everywhere I have shell_script syntaxis. And It’s still doesn’t work. I fixed it before I posted my configuration scripts.