Turn off an outlet after a variable amount of time?

So here’s my dream scenario: I just did maintenance on my pool filter and I want it to run for X number of hours, I push a button on my Apple watch, it prompts me for the number of hours to run and at the right time the outlet just shuts off. (The pool filter is plugged into a GE Z-Wave outdoor module.) I’m new to SmartThings but I’ve used IFTTT before and I’ve done quite a bit with the iOS app Workflows. Right now I’m looking at a full toolbox (SmartApp, Workflow, IFTTT, iOS reminders, etc) and scratching my head trying to figure out which tool(s) are best for the job…

My gut is pointing me to Workflow first because what I’ve been doing (I’m slowing switching from Iris to ST) is using a Workflow to ask me how many hours I want the filter to run then setting a normal iOS reminder for that far in the future that tells me to shut off the filter. At that point, if I’m not in a meeting or otherwise busy, I’d manually launch the Iris app and shut off the outlet. I was hoping with ST there would be a way to have the thing just turn itself off at the appropriate time instead of me having to launch an app to shut it off. Now I’m already happier that I can have a routine that shuts it off that shows up on my Apple Watch so I can more easily/discreetly turn off the outlet when the reminder pops up but it seems like there should be some way for me not to have to take any action other than the initial kick-off.

I looked at SmartApps and I see I can make one with a subscription to the outlet turning on and have it turn it back off again after a certain delay but that delay is just a set number. With my pool the filter run time varies day to day based on weather and how much it has been used (I have an automatic chlorine dispenser so I run the filter longer when it needs more chlorine and less when it is doing pretty good). I see that IFTTT can have a time as the “if” but again I need this to be dynamic based on when I start the filter and how long I want it to run. Workflow can trigger an IFTTT set to turn off the outlet but I don’t really trust an app on my phone to reliably “sleep” for 4-8 hours…

Any suggestions?

Check this out this app, it might be the answer you’re looking for. I don’t know if it works with the apple watch though.

@jwflutterby

You may be able to do this with CoRE, version v0.1.10e and up. Can you have your Apple Watch application (the one you tap on) send an HTTPS request? If not, can you get that number of minutes you want to wait to an IFTTT recipe as an ingredient? If you can, then here’s what you can do:

Install CoRE, see instructions here.

Go to IFTTT and have a recipe send a Maker request to CoRE’s endpoint followed by /ifttt/poolFilter
To find out the endpoint URL, enable OAuth for CoRE in the ST IDE and go to the dashboard (within the CoRE ST app), copy the URL for the dashboard, then replace the /dashboard… with /ifttt/poolFilter, like so:

URL should look like this:
https://graph.api.smartthings.com/api/token/0adfffff-cfff-4fff-8fff-9fffffffffff/smartapps/installations/e76fffff-efff-4fff-afff-5ffffffffff/ifttt/poolFilter

Use application/json as content type. In the body, enter {time: X} where X is the number of minutes. If using IFTTT you may be able to get this as an ingredient from the event (this). Body should look like {time: {{ingredientName}}} You can use the chemical flask icon to select an ingredient. I trust you know how to use that :wink:

Now go back to CoRE and create a new piston. Tap on IF and add a new condition, select the IFTTT capability, enter poolFilter as the value. Scroll down to Set variables on true, enable Import event data on true. Get out of the IF and go to THEN. Add a new action, select to control switches, select your switch. Add a task, Turn on. Get out and save the piston. Then trigger your watch tap and look into the CoRE dashboard, under the piston you just created (tap on it). You will see a list of variables under the piston itself. A variable called “time” should show up once the IFTTT recipe runs and the dashboard piston page refreshes. Go back to the CoRE piston, to the THEN section, tap on the Turn on task. Add a second task (to the same action): Wait (variable). Select the time variable from the list, then select “minutes” from the next select. Add a third task, Turn off. Get out and save using Done. try your watch app again, the switch should turn on, wait for the given number of minutes, then turn off. You don’t need to “remember” to turn it off anymore…

Please let me know how it goes, if you decide to give it a shot.

Thanks

2 Likes

Basic method: send IFTTT a voice text from the watch, using a hashtag to indicate which recipe to use

From the Apple Watch, you can send a text to IFTTT with a hash tag. But the hashtag has to be predefined. I use “House” as a contact name for IFTTT. Because I never could get Siri to understand IFTTT when I said it.

So you could have one recipe with #oneHourFilter for one hour, another recipe with hashtag twoHourFilter for two hours, etc.

Then you set up each recipe with the maker channel as the “that” to send the HTTP request to core.

An example using virtual switches

Alternatively, you use virtual switches as the “that” with the same recipes. Not as powerful, but easy to set up. :sunglasses:

The “that” in the recipe turns on a virtual switch which is set up to turn off after the number of hours that you want for that recipe.

You set the filter up to follow each virtual switch.

So you send a text to your IFTTT account hashtag ThreeHourFilter

You have a recipe that when it gets that text, it turns on your 3 hour virtual switch.

The Filter comes on when that virtual switch comes on.

After three hours, your three hour virtual switch turns itself off.

So the filter turns itself off. :tada:

It’s not elegant, because you have to predefine a recipe for each possible time Option, but it would be pretty easy to use.

This is exactly how we used to do voice control of SmartThings before the echo. Something like “Hey siri, tell house hashtag kitchenlighton”

Or in this case, “hey Siri, tell house hashtag threehourfilter”

2 Likes

Ok, I’m trying out this meathod but I’ve hit a snag… I have the IFTTT/maker stuff setup, I have CoRE installed and tried to go thru the creation of the piston but I’m not seeing where to accept the variable from IFTTT. You said to scroll down on the if and set set variables to true but I’m not seeing that :frowning:

Ok I’m not familiar with virtual switches, do you mean just create different SmartApps with different delays?

Make sure you have the latest version please.

Scroll down until you find this:

Select the Import event data on true. The prefix is optional, if you want the variable names prefixed so they don’t overlap any you’d be using already. Don’t think that’s the case, so you should leave the prefix empty.

I’m not seeing the Individual actions section… I picked a Basic piston, should I be using a different mode?

Oh sorry, go to CoRE’s Settings and under More Options (tap on it to open) you should find Expert Mode - enable that. Then try again. Sorry for the omission.

That helped! :slight_smile:

Since I’m not familiar with CoRE this may be a silly question but is there anywhere I can see a status to make sure it triggered/captured the variable/when it plans to “wake up”/that it woke up and did what I asked it to do?

Enable OAuth and then go to the Dashboard, the first item in the main CoRE page. That should show you a list of pistons. Tap on your pistons and you’ll see timers for next planned actions and a list of variable underneath. Hope that helps.

Perfect! That’s exactly what I was looking for :slight_smile:

1 Like

Ok so my solution for now is this… (If any of you guys use iOS devices & haven’t played with the Workflow app yet I highly recommend it :slight_smile: https://workflow.is/)

I have a Workflow set up to ask me how many hours then pass that to an IFTTT that accepts/passes that along to CoRE via the Maker which triggers a piston with a delay…

Here is my Workflow:

Then I made it an Apple Watch workflow so it shows in my list on my watch:

From there I just tap it, enter the hours & let Workflow/IFTTT/CoRE do the rest :slight_smile:

2 Likes

Smartthings allows you to create a virtual device which has no physical existence. It’s just an entry in your smartthings account. But once you’ve created it, the system will treated exactly the same as a physical device. So you can make a virtual switch which can be turned on and off by other events in the SmartThings system, or even by external systems like IFTTT or harmony.

Once you have created a virtual switch, it will show up in any list of devices for your smartthings account, including in smartapps like core.

And you can use Smart Lighting to have a physical switch get turned on and off when the virtual switch gets turned on and off. This is what we mean by “follows the virtual switch.”

And in case you want to do more than just turn one other switch on and off, there are also two smartapps available in the marketplace section of the smartthings mobile app that are very useful with virtual switches. These have been around for a long time (so long that they use the older terminology of “home phrase” rather than routine, although it’s the same thing) and are very popular. One lets you tie a switch to a mode change, and the other lets you use a switch to run a routine. And, as mentioned above, that switch could be a virtual switch. :sunglasses:

So it’s very common to use virtual SmartThings switches with IFTTT because it allows you to have one IFTTT recipe which actually causes multiple smartthings events because you have the recipe turn on a virtual switch and then you have various things tied to that virtual switch on the smartthings side.

1 Like

I had this same exact question as it related to lights and motion detection. Light comes on, goes off after X amount of time. Downloaded the app and it solved my issue. Thank you very much, I greatly appreciated the info.

2 Likes