The intent of this post is to show how PowerShell can be leveraged to turn on/off a wemo smart plug via IFTTT webhook integrations.

Assumptions:

  1. You already have an existing Wemo device and account that is working properly
  2. You already have an existing IFTTT account that is working properly
  3. You have PowerShell running on your device

Log in to your IFTTT account, add the Wemo integration and create a webhook

  • Log in to IFTTT and search for Wemo to add the integration with IFTTT
  • Select WeMo smart plug and follow the steps to enable the integration by logging in to your account
  • Once logged in you will have a button available to “Create” an integration
  • Create the integration and then add an “If This” trigger for Webhooks
  • Select “Receive a web request”
    • NOTE: Do not select “Receive a web request with a JSON payload” as we will simple be hitting the webhook, not delivering a payload.
  • Connect the webhook
  • Create your Event Name, this will be embedded in the URI that you are making requests against so make it something obvious for your situation. We will be using “LightTrigger” for our request
  • Add your “Then” action, search for WeMo and select “WeMo Smart Plug”
  • Select “Toggle on/off”
  • Select your account and the switch to trigger (this should be pre-populated with your account and switch info if you logged in previously)
  • Now you should have your completed trigger and action
  • Review and finish the applet
  • Find the URI for the webhook by clicking on your Profile, then going to “My Services” then click on Webhooks.
    • Once there click on the Documentation button to be taken to your page
  • Once there you will see your webhook link and api key, make note of this for later

Use PowerShell to call your webhook

We will be using the Invoke-WebRequest cmdlet. More information on this cmdlet can be found in the Microsoft Documentation here.

You will be submitting a PUT to the webhook API you created in the previous section.

  • Identify your web request by using your webhook URL along with the Event Name you created above.
    • In our example it would be https://maker.ifttt.com/trigger/LightTrigger/json/with/key/{your API Key}
  • Open Powershell and create the web request using the URL above:
    • Invoke-WebRequest -Uri https://maker.ifttt.com/trigger/LightTrigger/json/with/key/{YourAPIKey} -Method Post
  • Your switch should now be triggering on and off when you execute that command and you will receive a http 200 response to your web request in powershell
  • Congratulations! You’re done.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *