I am trying to make a switch wake-up and sleep my Mac.
In order to make it sleep, I have done the following:
1. Install "expect" package on my RPi.
2. Created a script test.sh in domoticz/scripts/ (cf. below)
3. Ran chmod +x test.sh
4. Created a virtual switch and mentioned "script://test.sh" in the "Off action" field.
When turning the switch off, I see in the log that the script was triggered.
Code: Select all
Status: Executing script: /home/pi/domoticz/scripts/test.sh
However, if I ssh to my RPi and manually execute the script, my Mac goes to sleep instantly.
I can't figure out why the script does not work when called from the Domoticz switch.
Can someone help me understand and maybe fix my issue ?
test.sh:
Code: Select all
#!/usr/bin/expect -f
spawn ssh MAC_USER@MAC_IP "pmset sleepnow"
expect "assword:"
send "MAC_USER_PASSWORD\r"
interact