Hi everyone,
I have a shell command, which runs fine from the ssh inside Home Assistant OS, but fails when started from an automation.
I guess there’s a problem with authentication.
There is no mention of mandatory authentication at Shell Command - Home Assistant
I want to shutdown my Windows PC or during testing just to create a directory.
My HA OS instance is a VM inside Proxmox.
This is in my configuration.yaml:
wake_on_lan:
switch:
- platform: wake_on_lan
name: mywindows
host: 192.168.1.30
mac: 12:34:56:78:90:ab
turn_off:
service: shell_command.hibernate_mywindows
shell_command:
hibernate_mywindows: '/usr/bin/ssh "My Name"@192.168.1.30 shutdown /h'
I guess only the last two lines are important for my issue. WoL works perfectly and I’m not relying on turn_off
.
This is my automation I’m trying to get to work:
alias: "Hibernate Windows PC"
description: ""
trigger: []
condition: []
action:
- service: shell_command.hibernate_mywindows
data: {}
mode: single
I replaced /usr/bin/ssh
with ssh
and I also replaced shutdown /h
with mkdir test
but they don’t work from the automation. Altough both work when I run them from the HA shell:
(mywindows PC) C:\> ssh homeassistant
[...]
➜ ~ ssh "My Name"@192.168.1.30 mkdir test
The folder test is successfully created (yes, mkdir works in PowerShell). I’m not prompted for a password. Also the PC goes into Hibernate with the other command.
Running the command verbousely tells me the key used is /root/.ssh/id_rsa
.
Running the automation manually results with these Step Details:
Result:
params:
domain: shell_command
service: hibernate_mywindows
service_data: {}
target: {}
running_script: false
The last line is misleading. When I just create an automation to send a notification to my phone it works, though with the same line running_script: false
.
When I create a notification that
- sends a notification to my phone
- runs the shell command
only the notification will be sent, no matter the order.
I read about ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i identityfile
in another thread but my issue isn’t affected by reboots.
Can anybody help? I don’t know where else to look.