Monitoring Your Smart Home with InfluxDB and IFTTT

Do you have a bunch of smart home devices, such as IoT devices like smart switches, cameras, doorbells, alarm systems or appliances? Have you ever wanted to monitor and send events from those devices to InfluxDB? And wouldn’t it be amazing if you could do that with zero coding? With IFTTT Webhooks, you can!

Let’s dive in.

What is IFTTT?

To start, we should talk about exactly what IFTTT is. IFTTT stands for “If This, Then That” and it’s a cloud service that allows you to connect IoT devices and services to other IoT devices and services. It’s an incredibly powerful service that can help you automate your perfect smart home.

Do more with the things you love

I’ve used IFTTT to open my garage door when I get close to home and to automatically turn on lights in my home when a motion sensor is triggered. I’ve also used it to send my phone a notification when I’ve left the fridge door open too long and to start camera recording when my home alarm is triggered. But what if I want to keep track of all the motion and sound events from my cameras? Or log my fridge temperature over time? Perhaps I’d like to learn which lights are left on in the house the longest or track how often the temperature in my home goes above or below a certain level – that’s where InfluxDB comes in.

What is InfluxDB?

InfluxDB is a time series database that allows you to track metrics and events from devices and services over time. A common use case for InfluxDB is monitoring IoT devices. InfluxDB accepts data in the form of Line Protocol and is built to scale so you can stream data from all your devices. InfluxDB is an open source project but also offers a cloud service which you can get started with for free! I’ll be using the InfluxDB cloud service in this exercise.

Let's get started

The example I’m going to use for the IFTTT + InfluxDB integration in this instance is monitoring motion and sound events from my Wyze cameras. The Wyze app lets me see this data, but it doesn’t provide a way to aggregate the data. I would like to answer the question, “How often do my cameras capture motion events each minute?” and InfluxDB can help us do that.

The best part is that this integration requires no code! Here’s how it works.

The first step is going to be to create IFTTT and InfluxDB Cloud accounts. Both are free! Once you’ve done that, go into your IFTTT account and “Connect” Wyze. Next, login to your InfluxDB Cloud account and create a bucket. A “bucket” is where you’ll store your time series data. You can create a bucket by visiting the Load Data page and selecting the Buckets tab. You can name this bucket whatever you’d like – I called mine “wyze”. While you’re on this page, click the “API Tokens” tab. Create a new “read/write” token with write permissions to your newly created bucket. This token will give IFTTT permission to write to your InfluxDB bucket.

Generate Read-Write API token

After you’ve created your new token, copy that token to your clipboard. Finally, you’ll need to find your InfluxDB Organization ID. Click the initial icon on the nav bar and select About.

Find your InfluxDB Organization ID

You’ll find your Organization ID on this page – copy that somewhere as well, so you can reference it later.

Alright, now the fun begins! Go back to IFTTT and, after you’re logged in, click the Create button in the top right corner. You’ll then be presented with the “If this &ndash”, “…then that” screen. Click “If this –” and then search for “Wyze”.

Create your own - if this - then that

You’ll be presented with a bunch of events that you can subscribe to. In our case, we’re interested in the motion events from the cameras. Select Motion detected and then choose Any camera in the dropdown. After clicking Create Trigger, you should see this screen showing that half your job is done!

Create Trigger

And now, you guessed it, click the …Then that button! Now search for Webhooks, and choose Make a web request. You should end up on a bright blue screen that looks like this:

Make a web request

Here’s what we’re going to put in each of these fields:

  • URL: This will depend on which InfluxDB region you signed up for. You can figure this out by just copying the domain from your browser's address bar after logging into InfluxDB Cloud. In my case, my region is After finding your region, append "/api/v2/write?orgID=[[your org id]]&bucket=[[your bucket name]]" to the URL
  • Method: Select "POST"
  • Content type: Select "text/plain"
  • Additional headers: Type "Authorization: Token [[your InfluxDB API token]]"
  • Body: Type "<<<activity,type=motion message="{{MotionDetected}}">>>". The <<< and >>> escape the messages so the double quotes are passed through correctly.

What’s happening here is that IFTTT will make an API request to InfluxDB Cloud using your API Token for authorization. In the body of the request, you’re sending some very basic Line Protocol. You’re setting “activity” as the measurement, the value “motion” to the field “type”, and you’re creating the tag “message” with the value of whatever comes from your Wyze camera. In this case, it will be the message “Motion detected on [[camera name]]”. And because there is no timestamp in this line protocol, InfluxDB will automatically attach the current time for you when it receives your message.

Smash that save button! And guess what? You’re done! Go do a happy dance in front of your Wyze cam to start sending those motion events to InfluxDB.

sending motion events to InfluxDB

After you’ve collected some motion events, you can log back into InfluxDB and start to analyze it. I’m going to create a Notebook in InfluxDB to explore this data. You can do the same by selecting the “Notebooks” option from the nav tree.

When you create a new Notebook, you’ll be presented with the query builder and a couple visualization panels below it. Select your bucket and the measurement “activity” in the query builder. Next, click the Run button at the top of the Notebook to run the query.

Build a Query

You should see some data.

Validate the Data

You can see that I have two cameras: Door Cam and Pan Cam. Like I mentioned earlier, I’d like to know which receives more motion events every 10 minutes. Here’s a Flux query I wrote that can help us visualize that:

import "strings"
from(bucket: "wyze")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "activity")
|> filter(fn: (r) => strings.containsStr(v: r["_value"], substr: "Door Cam"))
|> aggregateWindow(every: 10m, fn: count, createEmpty: false)
|> yield(name: "count")

This Flux query finds all the events where the message “Motion detected on Door Cam” appears and aggregates those events over a 10-minute window by counting the number of events that happened in that 10 minutes.

You can add this query into your Notebook by clicking the + button at the bottom and selecting Script. Then, paste the query. Next, click the + button again and select “Graph”. Finally, click the Run button to run the whole Notebook again. You should see a visualization. If you don’t, make sure to check your time window at the top right of the Notebook – I have mine set to “Past 24 hours”. My visualization looked like this:

Door Cam activity

It looks like Door Cam sees at most 2 motion events every 10 minutes. If I repeat the same process and produce another visualization for the Pan Cam, it looks very similar. In fact, it looks like more often than not, both cameras are detecting the same events. So I should probably check to make sure there is not any overlap in their visible field.

check there is not any overlap in their visible field

And that’s it! I’ll leave you with a challenge: repeat this exercise but also capture the “Sound detected” events from your Wyze cameras! You should be able to overlap both the motion and sound data in a visualization and see how often your cameras hear something when they also see something. Here’s a sneak peak of what that looks like for me from both of my cameras combined:

both cameras combined

Try it out yourself

The integration with Wyze demonstrated here is one of many potential integrations you can create with IFTTT and InfluxDB! IFTTT has integrations with hundreds of devices and services and you can send data from any of them into InfluxDB using the IFTTT Webhooks as described above.

Share your smart home projects with me by joining the InfluxDB Community Slack. I’d love to see how you’re using IFTTT and InfluxDB to monitor your smart home!