Control a Windows PC with IFTTT and AssistantComputerControl

Tags: #<Tag:0x00007faf8261a588>

I came across an opensource app called AssistantComputerControl (ACC) that enables you to send commands to a Windows PC from a voice assistant via IFTTT. There are 28 different actions available.

IFTTT writes files to a cloud drive of your choosing, which are then synchronized to your computer. The ACC app monitors the synchronized folder, and as soon as it sees a new file it acts on the command. I’ve found it to be pretty quick in my brief tests.

At this point in time, you can’t synchronize openHAB with IFTTT via myopenHAB (due to the strain it was putting on the servers). However, you can use webhooks for one-way control from openHAB to IFTTT. With help from the IFTTT webhooks tutorial by @Jens_M, I’ve done just that.

I’m most interested in having openHAB put my PC to sleep when I turn on my Away or Night modes (meaning that I’m leaving the house or going to bed), so that’s the focus of this tutorial. However, this works for any other ACC command and for IFTTT webhooks in general.

Set up services

  1. Install ACC on your Windows PC and follow the setup instructions for your particular cloud storage. You can use Dropbox, OneDrive, Google Drive, or your own IFTTT-accessible cloud. ACC just needs to know where the synchronized files will be stored on your PC.

    I originally used Google Drive, but switched to OneDrive after the developer told me that Google Drive isn’t reliable.

  2. (optional) Go to the ACC actions list and enable one of the commands in IFTTT for your preferred voice assistant. This will enable you to test that ACC is working, but it’s not strictly necessary.

  3. Activate the Webhook service in IFTTT.

  4. Get your personal IFTTT Maker Key by clicking the “Documentation” button on the IFTTT Webhooks page. You’ll need this when we’re setting up the rule in openHAB.

Create an IFTTT webhook applet

  1. Open the ACC Applet Maker, then pick a cloud service, voice assistant, and action. It doesn’t matter which voice assistant you choose (since we’re not using it), but the instructions won’t generate without it. If you choose OneDrive and Sleep, you’ll get this:

    image

    Note: There’s a mistake in the Applet Maker. It says to use “computerAction” for the file name, but you actually need to use “computerAction.txt”.

    Set this information aside. We’ll use it to create an IFTTT applet with a webhook as the trigger.

  2. Create a new IFTTT applet. Again, I’m using OneDrive and the Sleep action, so modify as needed for your purposes.

  3. Click “+This” to set up the trigger.
    a. Choose a service: Webhooks
    b. Choose a trigger: Receive a web request
    c. Complete trigger fields: whatever you want it to be (I use openhab_pc_sleep)
    d. Click “Create trigger”

  4. Click “+That” to set up the action
    a. Choose action service: OneDrive
    b. Choose action: Create text file
    c. Complete action fields: enter the File Name (“computerAction.txt”), OneDrive Folder Path (“AssistantComputerControl/”), and Content (“sleep”) from the ACC Applet Maker
    d. Click “Create action”

  5. Name your applet, choose if you want to receive notifications when it runs, and click “Finish” to save your work.

Set up an item, sitemap, and rules in openHAB

  1. Create an unbound proxy item to trigger the webhook. I suggest a generic string item that can be used for any IFTTT webhooks you create in the future.

    String IFTTT_Webhooks "IFTTT Webhooks" <switch>
    
  2. Add a selection element in your sitemap (I’ve added a shutdown command to show multiple commands).

    Selection item=IFTTT_Webhooks label="PC Control" mappings=[ Sleep="Sleep", PowerOff="Shut down" ]
    
  3. Create a rule that triggers when IFTTT_Webhooks changes. In the sendHttpGetRequest lines, replace openhab_pc_sleep with the name of your webhook, and Your_Key with the personal IFTTT maker key we got earlier from the IFTTT website.

    rule "Send commands to IFTTT via webhooks"
    when
        Item IFTTT_Webhooks changed
    then
        switch (IFTTT_Webhooks.state) {
            case "Sleep" : {
                logInfo("IFTTT_Webhooks", "Sending sleep command to Windows PC")
                sendHttpGetRequest("https://maker.ifttt.com/trigger/openhab_pc_sleep/with/key/Your_Key")
            }
            case "PowerOff" : {
                logInfo("IFTTT_Webhooks", "Sending shutdown command to Windows PC")
                sendHttpGetRequest("https://maker.ifttt.com/trigger/openhab_pc_shutdown/with/key/Your_Key")
            }
        }
        IFTTT_Webhooks.postUpdate("")
    end
    
  4. Use the IFTTT_Webhooks item to send commands from other rules.

    IFTTT_Webhooks.sendCommand("Sleep")
    

    Alternatively, you can just add the sendHttpGetRequest line wherever you need it in rules.

I would say that it takes about 2-3 seconds from when I trigger IFTTT_Webhooks from my sitemap to when it turns off my PC, but latency is largely going to be dependent on IFTTT and the Internet. IFTTT can lag at times, but it seems to be very quick to respond to webhooks.

There’s at least one other method to control your PC that is handled entirely within your local network, but I found it to be a little beyond my expertise. I like this as a relatively simple approach that can be easily deployed to multiple computers. Also, I’m okay with it being dependent on Internet access, IFTTT, and OneDrive, because it’s no big deal if one of these services is down and I have to press the power button on my computer to turn it off.

3 Likes

I use this Remote Control Windows PC through IOTLink with MQTT I will look at ACC to see if it is a little more reliable.

Cool, I missed seeing that one. I’ll be curious to hear your thoughts on how they compare.

So this works on intranet . Even if internet service is down still on LAN / WAN PC control will work .

I also prefer local control for my home automation, but that’s more about not being dependent on a manufacturer’s cloud than fearing Internet outages. Realistically, if my Internet is down (which rarely happens where I live) then not being able to control my PC with openHAB is a minor concern. So even though this solution is dependent on IFTTT and Google Drive, I’m content with it requiring Internet access.

FYI, I’ve been chatting with the developer on his Discord, and he said that he might remove Google Drive support, because it doesn’t work with IFTTT as well as OneDrive or Dropbox. So I’ll probably switch to using one of those services instead.

I’ve trying the IFTTT webhooks and they worked well… Thanks for the tip!

Unfortunately, currently the webhooks interface seems to be down somehow. Everything worked well, then suddenly it stopped working. I’ve re-created all of my webhooks, but still no operation.

When I switched the webhook to Alexa as trigger, the operation is executed.
(This is why I conclude that IFTTT is having issues)

Is anybody else experiencing this problem?

IFTTT webhooks are working for me, but the issues could be regional (if it’s not solved already).

I’ve been thinking that it might be possible to remove IFTTT to make this a fully local solution. Since ACC just monitors a folder to see if computerAction.txt shows up, we just need to have openHAB create a file in one of the shared SAMBA folders, and then have ACC look for it. This is as far as I’ve gotten, though. Since IFTTT has been reliable for me, I’m not super motivated to mess around with it. If someone else wants to try it before I put in more effort, I’d be happy to test it out.

I’ve had a look into ACC’s C# source code. It’s anything but clean code, but should still be adaptable.

My problem is not with ACC but with SwitchBot. Unfortunately, I cannot use its Bluetooth API, since I require access to scenes configured via SwitchBot Hub Mini (which control my air conditioning).

Sadly, webhooks still don’t work for me. I’ve used https://maker.ifttt.com/use/{api-key} to test the webhook. I’ve even fired the POST request via curl -X POST on command line against the URL shown there. Still, the IFTTT website shows

Connected Aug 03, 2020
Never run

If IFTTT was working correctly it should report that the hook was run, doesn’t it?

Yeah, that’s weird. If you’re using maker.ifttt.com/use to test it, then there shouldn’t be any problems. I just tried it and as expected it shows up in the activity report.

This is a silly question, but are you sure there isn’t a typo in your API key?

That’s beyond my skill set, but if you dig into it the ACC developer is pretty responsive on their Discord channel.

Yes, I’ve used the right API key. Especially since I used maker.ifttt.com/use for testing.

An regarding ACC: if the developer is reacting to request, there’s no need to get into the source :wink:

1 Like

Just to be clear, the developer was quick to respond to my questions, but I don’t know about feature requests. I think you get that, but I don’t want to cause any confusion around language.

Got it :slight_smile:

Here’s an update on IFTTT: Still, IFTTT doesn’t work for the account it used to work with. IFTTT support does not answer on my emails.

I’ve created a new IFTTT account and connected it to SwitchBot again – and it works again! I hope, it will keep working.

One thing I noticed: the new API key is now 44 digits long, before it was 22 digits long. Maybe this helps someone else out there…

1 Like

Continuing the discussion from Control a Windows PC with IFTTT and AssistantComputerControl:

Just got a Google alert about ACC being mentioned in this forum :slight_smile: Feature requests are very welcome, and I have yet to get a suggestion that doesn’t get implemented.

And I beg your pardon @ceedee, anything but clean? :face_with_raised_eyebrow: IFTTT weren’t the most responsive company, but a lot has changed even since your comment, so if you still have an issue, try email them again, or write to their CEO on Twitter.

I’m don’t fully understand just from this thread what you’d want implemented, and it’s been some time since this topic was active, but feel free to reach out in the Discord server if you want anything implemented.

And @rpwong Google Drive support is not being removed, as I got in contact with IFTTT, and they are fixing the issues.

IFTTT is in sort of bad standing right now though, due to the annoncement of the “Pro” plan… Hope they withdraw the “max 3 personal applets” limit :slight_smile:

1 Like

Don’t get me wrong, @AlbertMN – ACC is a nice helper, I especially like the setup wizard which gives a good start. With “clean” I was referring to the “how” it is implemented. If you want, I can explain in more detail in a private conversation, since that is not openHAB related. – Anyway, I’m glad you implemented the software and I’m glad it works as smooth as it does! :+1:

Thanks for bringing us some updates, @AlbertMN! I actually ended up switching to Dropbox, and it has worked flawlessly for me.

Oh yeah, it’s without doubt not the best way to do it, but it’s the way that requires the least amount of setup, and techincal knowledge. The software is used by over 77.000 users, and many of those don’t want to set up a server, port forwarding or anything webrequest-related. It’s a fun little hack that works :smiley: This way it can be kept simple and most importantly; free. ACC only cost me about $30-40 a month to keep alive, and some months ads on the website + donations from kind users cover it completely, meaning I don’t have to charge a thing for it. If any more traffic went through my server, this would not be the case.

If you have an idea on how to make it more “clean”, while still requiring close to 0 techincal knowledge, and where it’s free, do hit me up (DM here or preferably on albert@mollernielsen.dk)

@rpwong awesome! Dropbox is also the best choice for ACC by far - also for general cloud service purposes, but that’s just my personal opinion :stuck_out_tongue:

1 Like

With IFTTT moving to a subscription model, I’m more motivated to look into generating the computerAction.txt on my openHAB server and having ACC monitor it via SAMBA. Do you think ACC would have any troubles with that?

I don’t have an issue with IFTTT charging money (it’s a business), and I’m only using three applets so the standard account still works for me. It’s more about wanting everything to happen locally.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.