Time is precious and must be blurbed wisely.

Switchur gears with IFTTT

In this tutorial, you’ll learn how to turn IF THIS THEN THAT into IF THESE THEN THOSE in minutes. It demonstrates how combining the orchestration power of Switchur with IFTTT unleashes the full potential of your home automation system.

Concepts and basics

In early 2016, a group of friends in the technology industry were searching for a solution to an engineering challenge with stateless distributed events. They weren’t able to find the perfect solution, and long story short… Switchur was created just a few months later.

Although conceived for an unrelated purpose, it wasn’t long before home automation enthusiasts had paired it with IFTTT and shared with us how it helped to automate their home. With Switchur, IFTTT users could create more advanced rules to govern the operation of their connected devices. By outsourcing the automation rule processing to Switchur, the IFTTT connections could be triggered in more controlled and specific scenarios.

Switchur is able do this as it can recall the known state of environments, IoT sensors, and devices. And by constantly watching for state changes, it scans for a desired combination of varied environment, sensor, and device states to decide if there are (IFTTT) actions to process. Essentially, it can enable any “If THIS then THAT” condition to become a multifaceted “If THESE then THOSE” scenario.

Switchur IFTTT Integration

For this to happen, the sensor readings that are received by IFTTT must be passed to Switchur. Switchur stores any reading for future reference and checks all the automation rules where that sensor reading is a component to determine if the updated reading (when combined with saved readings of other sensors) should invoke an automation action. Any resulting action(s) are passed by Switchur back to IFTTT which issues a command to the desired device.

The synchronized dance between IFTTT and Switchur is illustrated in the displayed diagram as events and actions. “If This” events are routed through to Switchur to update Switchboard items, and any resulting actions from Switchur automations are routed back to IFTTT to invoke “Then That” actions.

As you are reading this, there is a good chance that you are in possession of a contemporary smart lighting system (e.g. Philips Hue, C by GE, LIFX, Sengled, etc). Throughout your house, you might even have an assortment of smart bulbs from various manufacturers but for this tutorial we’ll be imagining a house with a Philips Hue system.

Consider this practical example

In our pretend house, Chad would like his living room lights to turn on between sunset and bedtime, but only if a family member is at home. He’d also like the living room lights to dim to 20% brightness if the living room television is on, but only in the evening and only if Sandra is not at home (Chad likes the lights dimmed but Sandra doesn’t).

Within this scenario are four propositional elements.

Time of day
Chad at home
Sandra at home
Television is on

And here’s where IFTTT’s linear limitations become a challenge. Our desired automation rule dictates that these propositional elements need to be considered alongside each other as a combined state. We can’t do this with IFTTT alone, but we can do this if we augment IFTTT’s capabilities with Switchur.

Creating and connecting Switchboard items

First, we need to connect Switchur with the data it needs to monitor these events. In Switchur, these are called Switchboard items and we’ll need four of them for this example.

Add a new keyword item

Chad logs in to Switchur, navigates to Switchboard, and clicks the + Add new button to add a new Switchboard item.

  1. In the label field, he enters “Time of day”.
  2. He chooses the Keyword option as he will be assigning the word “evening” to it later (because there are many possible times of day, it makes sense to use keyword instead of a switch).
  3. He clicks the Create button.
  4. After saving, Switchur provides a link to use for updating this keyword. To the right of the link, he clicks the Copy icon.
Switchur Switchboard item

Connect IFTTT to update keyword to “evening”

Chad logs in to his IFTTT account, he expands the menu by clicking his profile avatar, and chooses Create to make a new applet.

  1. Under the heading, he clicks on the [+]This option. This lists all the services that can perform as a trigger in IFTTT.
    1. To register that it is Sunset, he'll use Weather Underground. He types “weather underground” into the search prompt, and clicks on the WU tile when it appears in results to advance to the next screen.
    2. Then from the list of WU's possible triggers he locates and selects the option Sunset.
    3. Under location he types the name of his city and checks it found the correct area.
    4. He clicks Create trigger.
  2. Under the heading, he clicks on the [+]That option to list all services that provide actions.
    1. He needs to update Switchur by using its webhook. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option, and in the URL field he pastes the link that Switchur gave him to control the Time of day keyword.
    3. Before moving on to the next field, he must edit the link to change the /ABCxyz/ placeholder to /evening/ as the value that he wants assigned to the keyword.
    4. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If Sunset, then update Switchur Time of day and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Connect IFTTT to update keyword to “bedtime”

He needs a second applet that will set the Time of day keyword to “bedtime”. In IFTTT, he expands the menu again and clicks Create to make a new applet.

  1. He clicks on the [+]This option.
    1. To register that it is bedtime, he'll use the Date & Time service. He types “date” into the search prompt, and clicks on the Date & Time tile when it appears.
    2. Then from the list of possible triggers he locates and selects the option Every day at.
    3. They're usually in bed by 11pm and he sets the dropdown field to that time.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. Again, he needs to update Switchur using a webhook. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option and in the URL field, he pastes the link that Switchur provided to control the Time of day keyword.
    3. Before moving on to the next field, he must edit the link to change the /ABCxyz/ placeholder to /bedtime/ as the value that he wants assigned to the keyword.
    4. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If Bedtime, then update Switchur Time of day and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Add a new switch item

Chad logs in to Switchur, navigates to Switchboard, and clicks the + Add new button to add a new Switchboard item.

  1. In the label field, he enters “Chad at home”.
  2. He chooses the Switch option as there are only two conditions possible.
  3. He clicks the Create button.
  4. After saving, Switchur displays three links that he can use to update this switch. To the right of the the On link, he clicks the Copy icon.
Switchur Switchboard item

Connect IFTTT to update switch to On

Chad logs in to his IFTTT account, expands the menu by clicking his profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. To register that Chad is home, he'll use his IFTTT account's location polling. He types “location” into the search prompt, and clicks on the Location tile when it appears in results to advance to the next screen.
    2. As he hasn't used the location service before he first needs to review the instructions, download the IFTTT app to his iOS (or Android) phone, and clicks Connect. Then from the list of Location triggers he selects the option You enter an area.
    3. Under locate an area he types his home address and confirms it finds his house. He scales the map until the target zone encircles the house.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He will update Switchur using a Webhook again. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option, and in the URL field he pastes the link that Switchur gave him to set the Chad is home switch to On.
    3. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    4. He clicks Create action.
  3. Before clicking Finish he renames the applet If You enter an area, then update Switchur Chad at home and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Connect IFTTT to update switch to Off

He needs to add a second applet that will set the Chad is home switch to Off. He expands the menu again and clicks Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He'll use the location service again. He types “location” into the search prompt, and clicks on the Location tile when it appears.
    2. Then from the list possible triggers he selects the option You exit an area.
    3. Under locate an area he types his home address again and confirms it finds his house. He scales the map until the target zone encircles the house.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. Again, he needs to update Switchur using a Webhook. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option and in the URL field, he pastes the link that Switchur gave him to set the Chad is home switch to On.
    3. Before moving on to the next field, he must edit the link to change the /on/ setting to /off/ (or he could open Switchur and copy the Off link for the Chad is home switch).
    4. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If You exit an area, then update Switchur Chad at home and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Add a new switch item

Chad logs in to Switchur, navigates to Switchboard, and clicks the + Add new button to add a new Switchboard item.

  1. In the label field, he enters “Sandra at home”.
  2. He chooses the Switch option as there are only two conditions possible.
  3. He clicks the Create button.
  4. After saving, Switchur displays three links that he can use to update this switch. To the right of the the On link, he clicks the Copy icon.
Switchur Switchboard item

Connect IFTTT to update switch to On

To monitor when Sandra is at home, Chad must either use a different IFTTT account or an alternative services geolocation or wifi events trigger. He opts to create a separate IFTTT account for Sandra, and logs in to her new IFTTT account, expands the menu by clicking the profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. To register that Sandra is home, he'll use her IFTTT account's location polling. He types “location” into the search prompt, and clicks on the Location tile when it appears in results to advance to the next screen.
    2. He downloads the IFTTT app to her Android phone, opens it and logs in with her credentials before he clicks Connect back on the website. Then from the list of Location triggers he selects the option You enter an area.
    3. Under locate an area he types their home address and confirms it finds their house. He scales the map until the target zone encircles the house.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He will update Switchur using a Webhook again. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option, and in the URL field he pastes the link that Switchur gave him to set the Sandra is home switch to On.
    3. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    4. He clicks Create action.
  3. Before clicking Finish he renames the applet If You enter an area, then update Switchur Sandra at home and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Connect IFTTT to update switch to Off

He needs to add a second applet that will set the Sandra is home switch to Off. Whilst still logged in to IFTTT as Sandra he expands the menu again and clicks Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He'll use the location service again. He types “location” into the search prompt, and clicks on the Location tile when it appears.
    2. Then from the list possible triggers he selects the option You exit an area.
    3. Under locate an area he types their home address again and confirms it finds their house. He scales the map until the target zone encircles the house.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. Again, he needs to update Switchur using a Webhook. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option and in the URL field, he pastes the link that Switchur gave him to set the Sandra is home switch to On.
    3. Before moving on to the next field, he must edit the link to change the /on/ setting to /off/ (or he could open Switchur and copy the Off link for the Sandra is home switch).
    4. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If You exit an area, then update Switchur Sandra at home and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Add a new switch item

Chad logs in to Switchur, navigates to Switchboard, and clicks the + Add new button to add a new Switchboard item.

  1. In the label field, he enters “Television”.
  2. He chooses the Switch option as there are only two conditions possible; on or off.
  3. He clicks the Create button.
  4. After saving, Switchur displays three links that he can use to update this switchboard item. To the right of the the On link, he clicks the Copy icon.
Switchur Switchboard item

Connect IFTTT to update switch to On

Chad logs in to his IFTTT account, expands the menu by clicking the profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. To register when the TV is on, he will use his Sense Energy Monitor. He types “sense” into the search prompt, and clicks on the Sense Energy Monitor tile when it appears in results to advance to the next screen.
    2. From the list of triggers he selects the option A device turned on.
    3. Under device he selects Television.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He will update Switchur using a Webhook again. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option, and in the URL field he pastes the link that Switchur gave him to set Television to On.
    3. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    4. He clicks Create action.
  3. Before clicking Finish he renames the applet If Television switches on, then update Switchur Television and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

Connect IFTTT to update switch to Off

He needs to add a second applet that will run when the Television is turned Off. He expands the menu again and clicks Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He'll use the Sense service again. He types “sense” into the search prompt, and clicks on the Sense Energy Monitor tile when it appears.
    2. Then from the list possible triggers he selects the option A device turned off.
    3. Under device he selects Television.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. Again, he needs to update Switchur using a Webhook. He types “webhooks” into the search prompt and selects the Webhooks tile when it appears.
    2. He chooses the Make a web request option and in the URL field, he pastes the link that Switchur gave him to set Television to On.
    3. Before moving on to the next field, he must edit the link to change the /on/ setting to /off/ (or he could open Switchur and copy the Off link for the Television switchboard item).
    4. Under Method, he changes the value from GET to POST, and he leaves Content Type and Body unchanged.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If Television switches off, then update Switchur Television and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT Then screenshot IFTTT Save screenshot

We now have four Switchboard items receiving updates from IFTTT. For transparency and to help with troubleshooting, any request to a Switchboard item is logged and can be viewed by clicking on the View log button.

Review Switchboard values and update history

New Switchboard items are created without any value assigned and stay that way until they receive the first update request. Essentially a POST to https://api.switchur.com/Fresh/Meat/A1B2C3…

Switchboard screenshot

In most cases, IFTTT update events are infrequent and it could take some before all IFTTT applets execute to assign values to all of our Switchboard items. Items with a value assigned will display whatever they have stored. A Switchboard item that has no value is recognisable by its opaque icon.

Should you wish to update Switchboard item values outside of IFTTT, the most secure way is to briefly enable Test mode under an items Advanced options and then enter the update link into the address bar of any web browser. Test mode permits HTTP GET method requests, the same request method browsers use to request content from a server. This is fine for quick tests but as GET requests can be cached it should only ever be enabled temporarily.

Building the Automations

If you remember, Chad wanted his living room lights to turn on in the evening, but only if a family member is at home. Furthermore, he wanted the living room lights to dim to 20% brightness if the living room television is on, but only in the evening and only if Sandra is not at home.

He creates two Switchur Automations that will constantly watch for changes to Switchboard values.

Creating the Lights On automation rule

Chad logs in to Switchur, navigates to Automations, and clicks the + Add new button to add a new Automation.

  1. In the label field, he enters “Living room lights”.
  2. To add Switchboard conditions:
    1. He clicks the Switchboard items button, and chooses Time of day from the list.
    2. Where prompted to enter the word value for Time of day, he enters “evening”.
    3. He clicks the Switchboard items button again, and chooses Chad at home.
    4. Where prompted to select the required value for Chad at home, he clicks On.
    5. He clicks the Switchboard items button again, and chooses Sandra at home.
    6. Where prompted to select the required value for Sandra at home, he clicks On.
  3. As the basic automation rule builder asserts all conditions are compounded by AND he expands Show advanced options and enables the Advanced editor view.
  4. His basic automation rule is converted to it's equivalent logic expression:
    • [[Time of day]] = "evening" and
      [[Chad at home]] = ⊚ ON and
      [[Sandra at home]] = ⊚ ON
    He edits the expression to group the propositions for Chad and Sandra being home and replaces their “and” operator with an “or”:
    • [[Time of day]] = "evening" and
      ( [[Chad at home]] = ⊚ ON or [[Sandra at home]] = ⊚ ON )
  5. He clicks Create.
Switchur Automation Switchur Automation

Getting IFTTT’s event webhook link

To trigger an IFTTT event Chad needs to copy the link from the IFTTT Webhooks documentation page.

Chad logs in to IFTTT, navigates to Webhooks, and clicks the Documentation button.

  1. At the bottom of the page, he drags his cursor to highlight and copy the event trigger url.
IFTTT webhook event

Adding Actions to the Automation

Chad returns to the Automation that he is creating in Switchur.

  1. He clicks the Add Action button.
    1. For When automation is he selects the Thumbs up option so this action can run when the automation evaluates as true.
    2. He pastes the link he copied from IFTTT into the URL address field.
    3. He edits the link to replace “{event}” with “LightsOn”.
    4. He clicks Create.
  2. He clicks the Add Action button again.
    1. For When automation is he selects the Thumbs down option so this action can run when the automation evaluates as false.
    2. He pastes the link he copied from IFTTT into the URL address field.
    3. He edits the link to replace “{event}” with “LightsOff”.
    4. He clicks Test to check the response from IFTTT.
    5. The response looks okay so he closes the test popup and clicks Create.
Switchur Automation Switchur Automation

Connect IFTTT to run the “LightsOn” Action

Chad logs in to his IFTTT account, expands the menu by clicking the profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He types “webhooks” into the search prompt, and clicks on the Webhooks tile when it appears in results to advance to the next screen.
    2. From the list of triggers he selects the option Receive a web request.
    3. Under Event Name he types “LightsOn”.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He types “hue” into the search prompt and selects the Philips Hue tile when it appears.
    2. He chooses the Turn on lights option from the list of actions.
    3. Under Which lights he selects Living room from the list of options.
    4. He clicks Create action.
  3. Before clicking Finish he renames the applet If Switchur calls "LightsOn", then turn Living room lights on and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT That screenshot IFTTT Save screenshot

Connect IFTTT to run the “LightsOff” Action

Chad logs in to his IFTTT account, expands the menu by clicking the profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He types “webhooks” into the search prompt, and clicks on the Webhooks tile when it appears in results to advance to the next screen.
    2. From the list of triggers he selects the option Receive a web request.
    3. Under Event Name he types “LightsOff”.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He types “hue” into the search prompt and selects the Philips Hue tile when it appears.
    2. He chooses the Turn off lights option from the list of actions.
    3. Under Which lights he selects Living room from the list of options.
    4. He clicks Create action.
  3. Before clicking Finish he renames the applet If Switchur calls "LightsOff", then turn Living room lights off and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT That screenshot IFTTT Save screenshot

Creating the Dim Lights automation rule

Chad logs in to Switchur, navigates to Automations, and clicks the + Add new button to add a new Automation.

  1. In the label field, he enters “Dim Living room lights”.
  2. To add Switchboard conditions:
    1. He clicks the Switchboard items button, and chooses Time of day from the list.
    2. Where prompted to enter the word value for Time of day, he enters “evening”.
    3. He clicks the Switchboard items button, and chooses Television from the list.
    4. Where prompted to enter the required value for Television, he clicks On.
    5. He clicks the Switchboard items button again, and chooses Chad at home.
    6. Where prompted to select the required value for Chad at home, he clicks On.
    7. He clicks the Switchboard items button again, and chooses Sandra at home.
    8. Where prompted to select the required value for Sandra at home, he clicks Off.
  3. He clicks Create.
Switchur Automation

Getting IFTTT’s event webhook link

To trigger an IFTTT event Chad needs to copy the link from the IFTTT Webhooks documentation page.

Chad logs in to IFTTT, navigates to Webhooks, and clicks the Documentation button.

  1. At the bottom of the page, he drags his cursor to highlight and copy the event trigger url.
IFTTT webhook event

Adding an Action to the Automation

Chad returns to the Automation that he is creating in Switchur.

  1. He clicks the Add Action button.
    1. For When automation is he selects the Thumbs up option so this action can run when the automation evaluates as true.
    2. He pastes the link he copied from IFTTT into the URL address field.
    3. He edits the link to replace “{event}” with “DimLights”.
    4. He clicks Create.
Switchur Automation

Connect IFTTT to run the “DimLights” Action

Chad logs in to his IFTTT account, expands the menu by clicking the profile avatar, and chooses Create to make a new applet.

  1. He clicks on the [+]This option.
    1. He types “webhooks” into the search prompt, and clicks on the Webhooks tile when it appears in results to advance to the next screen.
    2. From the list of triggers he selects the option Receive a web request.
    3. Under Event Name he types “DimLights”.
    4. He clicks Create trigger.
  2. He clicks on the [+]That option.
    1. He types “hue” into the search prompt and selects the Philips Hue tile when it appears.
    2. He chooses the Dim lights option from the list of actions.
    3. Under Which lights he selects Living room from the list of options.
    4. In the Brightness field he types “20”.
    5. He clicks Create action.
  3. Before clicking Finish he renames the applet If Switchur calls "DimLights", then dim Living room lights to 20% and disables Receive notifications when this Applet runs.
IFTTT This screenshot IFTTT That screenshot IFTTT Save screenshot

These two Automations are now active and ready to process applicable Actions. Every time Switchur processes an Action it saves request and response details to the Automation log.

The Automations screen

The View Log option is displayed for any Automations that have processed an Action at least once. Log entries older than 14 days are automatically purged.

Switchur Automations

If an Automation uses the basic rule builder it will show either a tick or cross next to each proposition. The tick and cross represent the condition of the proposition, not the condition switch values such that the red cross would be displayed where a proposition was switch must be off and the switch was on.

Automations that use an advanced expression have a special option for integrity checking and previewing evaluation outcomes. In the expression editor, there is an button in the corner that when clicked will check the expression parses without error, then change to either or . This option especially useful to test the validity of expressions employing cascading functions. You can learn more about Advanced expressions in the support site.

Automation Actions have several extra options that weren’t required for Chad’s example. Actions can be delayed by up 15mins which can support scenarios where you may want to follow an action with a second subsequent action sometime later e.g. security lighting turning off after x mins. Actions also have advanced options to change request properties such as it’s persistence behaviour, the HTTP method, content type, and customizing the request body with static/dynamic content.

Idea hamster

Here’s a few genius applications of Switchur we’ve heard about from the community.

  • “Friendship beacons”. Two best friends are separated temporarily by secondment out of state. They configured Switchur so whenever either friend was in residence, the other friends lamp would softly glow, and if either wanted to let the other know that they were thinking about them, they simply pressed the IFTTT widget button on their phone to make their friends lamp glow pink for a few minutes.
  • “Healthy rewards”. A fitness regimen requires discipline. Someone determined not to fall of the wagon used incrementing and decrementing Switchur counters to dish out rewards. By using a modulus aka remainder operator ( [[COUNT]] % 5 = 0 ) in an advanced expression, and incrementing a counter when they reached their Fitbit daily steps goal, the automation would Action the snack reward once for every fifth counter increment.

Time for a break?

Right now, your probably thinking “that’s a strange looking hamster”. And that may indicate it’s time to stop worrying about the hamster and explore what entertainment the webiverse has to offer. Doop do do doop do do doop do…

Start orchestrating your smart home with Switchur. Create your account today!

IFTTT Automation Support