and in my shell_commands.yaml I have: mac_off: ssh [email protected] sudo shutdown -h now
I’ve configured the system, where HA is running, to access the iMac without password, following this guide: http://www.linuxproblem.org/art_9.html, everything seems working fine.
I can successfully access my mac without using a password and if run ssh [email protected] sudo shutdown -h now from shell the mac turn off, on the contrary if I toggle off the switch from HA nothing happens. What could I check? I didn’t find anything inside home-assistant.log
thanks @magicus, I modified the command in: mac_off: ssh [email protected] sudo shutdown -h now; touch it-worked and it is not working, no file is created. Maybe this is related to the fact that I’m running HA in a virtual environment…
I used the configuration that you can see in my first post. The only difference is that I repeated the procedure for the SSH login without password under the HA user.
In my shell_command.yaml i have a shutdown script to turn off my iMac: turn_off_imac: 'ssh [email protected] sudo /sbin/shutdown -h now'
Unfortunately it isn’t working. When executing this command I get: sudo: no tty present and no askpass program specified
What am I missing?
I created a public and private key on my HA with ssh-keygen and no password
I can login to my mac from ssh via HA commandline with ssh [email protected] without using a password
in configuration.yaml there are two lines for importing the shell command and the switch: shell_command: !include shell_command.yaml and switch: !include switches.yaml
I found a partial solution to the error: sudo: no tty present and no askpass program specified
See here.
The shutdown command will execute from command line now. No sudo error as above The switch however doesn’t work…
I’m starting to think that the Hassio virtual environment doesn’t allow commands at all due to command-line restrictions. Can anyone verify that?
in the last days i tried to get a switch working so i can turn off my iMac with Home Assistant. I also would like to shutdown other Pi’s in my network. One is running Volumio2 (a mediaplayer) and the other one Rasplex.
Unfortunately, i didn’t get the switch working, but i can turn my mac off with the Terminal-Addon and the command in the following config. (i don’t need command_on yet)
Added “PermitRootLogin yes” into “/etc/ssh/ssh_config” (NOT sshd_config as it was described in another thread. there was no file sshd_config…)
Tried variations of the command_off-command (with or without " or ’ )
Thus, these are my questions:
Is there anyone who already got a switch working? @asp What did you do exactly? What is the HA user? Isn’t it root?
Is it better to do this with a WOL-Switch instead of command_line?
Everything I wanted is working as expected. I am putting my Mac to sleep/standby using the Wake On Lan switch. Here is my setup:
script:
macbook__standby:
sequence:
- service: shell_command.macbook__standby
shell_command:
macbook__standby: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'pmset sleepnow'
switch:
- platform: wake_on_lan
name: WoL Macbook Switch
mac_address: !secret switch__wol__macbook_mac_address
host: !secret switch__wol__macbook_host
turn_off:
service: script.macbook__standby ## could be "shell_command.macbook__standby" if you don't want to create a script
To shutdown the Mac immediately, you have to change pmset sleepnow to shutdown -h now. Shutting down the Mac after (for example) 5 minutes would be: sudo shutdown -h +5