Voice control to shutdown / hibernate PC with combinition of Amazon Alexa, IFTTT, PowerShell script, Task Scheduler, and OneDrive/DropBox
Video Demo
This repository is deprecated.
Instead of using going through the effort through IFTTT, I am now using PCIe Wifi Remote Control On/Off switch for my PCs.
There're plenty of brands out there support it with a relatively cheap cost (Tuya / eWeLink) and is able to directly integrate with IoT Platforms like Home Assitant / Alexa.
This script is an modified version of MaxAnderson95's Shutdown-PC-via-IFTTT script by adding in If-Elseif-Else statement so that more use cases can be add in easily.
Currently I am using it to Shutdown and Hibernate my PC.
Login to IFTTT, Click on New Applet
Click on "✚ this"
Search and Choose "Amazon Alexa"
Click on "✚ that"
Search and Choose "OneDrive" or "DropBox"
Click Finish
Repeat step 1 to 10 for Hibernating the PC, only change below information
Download and put the PowerShell Script into desire location
Change line 2 to folder that you set in IFTTT (Should be within OneDrive/DropBox directory)
Change line 3 to desire sleeptime between file checks
Open "Task Scheduler"
On right panel, Click Create Task
In "General" Tab, Change/Insert
Click OK
Click Windows button, type PowerShell, Right click "Run as administrator"
Insert Set-ExecutionPolicy Unrestricted and type A
Speak the magic phrase
Amazon Alexa will create a file in OneDrive/DropBox
PC will
When PC startup, Task Scheduller will run the PowerShell script
The PowerShell script will scan the folder you inserted in "Computer Setup" Step 2 based on internval set in "Computer Setup" Step 3
When you speak the magic phrase to Alexa
Amazon Alexa will create a file in OneDrive/DropBox
Upon interval time, the PowerShell Script will detect the file
The PowerShell script will read the file name and match with IF-Elseif-Else statment
Lastly, command will be executed based on file name detected
To add in more use cases, you will have to create respective IFTTT applet for it, just change the phrase and filename.
In the script file, Add below
Remove-Item -Path "$SearchDirectoryyour_new_filename" -Force -ErrorAction SilentlyContinue
elseif(Test-Path -Path "$SearchDirectoryyour_new_filename")
{
Remove-Item -Path "$SearchDirectoryyour_new_filename"
YOUR_NEW_COMMAND
$FileCheck = $True
}
Kavier Koo Any queries, please contact me here
This project is licensed under the MIT License