Adafruit IO and CircuitPython make it easy to send data to Adafruit IO feeds. They automatically show up in your Feeds tab, where you can check on the status at anytime, which is excellent! However, you probably want to do something with your data. Adafruit IO has a number of options for that as well!

One way to use your data is through Adafruit IO Actions. Actions allow you to do a variety of things when a situation specified by you occurs. There are three types of Actions. You'll be using the Reactive type Action for two of the alerts needed for this project.

Reactive Actions are more advanced than the other Action types. They can integrate basic logic. At a basic level, they check if a feed value is somehow comparable to a value or to even another feed. If so, you’ll be able to send an email notification, post a webhook or even publish a message to another feed. An example used in this project is that you can set up a reactive trigger to notify you when the battery voltage falls below a certain value. Super useful!

You'll create two Reactive Actions: one for new mail, the other for reporting low battery.

This page walks you through each step necessary for setting up the new mail Reactive Action.

In the last section, you'll find only the final few steps for setting up the low battery Reactive Action, as you can follow the same steps using different options that you followed while setting up the new mail Action.

New Mail Action Set Up

In Adafruit IO, click Actions in the black menu bar.

On the Actions page, click New Action.

Choose the Reactive action type by clicking Choose this Action at the bottom of the Reactive box.

Once you've chosen the Reactive Action type, you'll see the following page. This is the set up page for the Reactive Action, which provides you with a series of dropdowns to choose from to create the Action you want.

This might seem a little confusing. Basically, the top three lines read as a sentence: "If the chosen feed, is compared in a specific way to another feed or a specific feed value, then complete the chosen action." You'll choose the options to update the sentence to read, "If the new-mail feed is equal to New mail! then email me."

The rest of this page shows you how to choose the right options to have Adafruit IO send you an email when the new-mail feed indicates your mailbox door has been open.

In the If section, for Select Action Feed, choose new-mail. This is the main feed that tells you when your mailbox door has been opened.

The Is section contains multiple things to update. For Select Comparison, choose equal to. We'll be comparing it to the value sent to Adafruit IO by the Feather, so we want it to match.

For Comparison Value or Feed, leave it as the default. You are not comparing it to another feed, you'll be comparing it to a value.

For the Value text box, type in, New mail!. This is the value sent to the new-mail feed when the mailbox door is opened.

In the Then menu, choose email me.

Once you choose email me, you'll see the options expand to include more options, as shown here.

For Select Value Feed (the menu shown to the left of value and time.), choose new-mail.

There is default content provided for the email generated by the Action.

  • The subject of the email generated by the default would read, "new-mail feed has a new value: New mail!
  • The body would read, "The new-mail feed has a new value: New mail! at (current date and time)"

You'll notice some text surrounded by double brackets, e.g. {{ text }}. These are values that are provided by Adafruit IO with the value at the point of the Action being triggered. There are multiple options for these values, including feed_id, value, feed_name, created_at and updated_at. See the blue box below for the full list.

The default email content is a bit redundant with the feed name and the resulting value are essentially the same thing. Therefore, it's worth updating the content to something more applicable. The following image shows the email content updated. Feel free to customise this to fit your needs.

Leave the Limit Every at the default of Fifteen Minutes. The Limit Every value limits the amount of time needed between Actions triggering, before the Action can trigger again. The code sends a message every 30 seconds while the mailbox door is open. Someone might need a little time to place mail and packages in the box, so the door might be open for a few minutes. Rather than send you six emails, you can set Limit Every value to a higher amount of time, e.g. 15 minutes. This means you'll most likely only get one email each time the door is opened. In the event that the door is left open for an extended period of time, you will receive an email every 15 minutes until you close it. Feel free to increase or decrease this value as desired.

Leave Notify on Action Reset at the default of unchecked. Checking the box means Adafruit IO would notify you when the conditions that cause the email to be sent are no longer true. In this case, the feed value never changes, the same value is sent when the mailbox door is opened. Therefore, there is never a situation where the feed value would change, which is what would trigger the Reset Notification.

You're almost done! First verify the previous settings all match the options shown below. Once you're certain, click Submit.

Once submitted, you'll see your new Action listed in the Actions list! The listing includes a short description of the Action, the Action Type (Reactive), and the Status (Active).

The status column is important to be aware of. The Status may change from Active to Stopped. This can happen if you stop it (accidentally or otherwise), or if there's an issue on the Adafruit IO end of things. If the status is Stopped, the Action will not run and you will not receive notifications. If you find you haven't been notified in a while, and you see more recent data in your feed, be sure to check the Action Status as your first troubleshooting step.

Battery Voltage Action Set Up

This project is ultimately battery-powered. As there is no charging included in the build, the battery will eventually drain and require either swapping or charging. Therefore, you'll want to set up a notification when the battery is low. This section shows you what settings to chose to receive an email when your battery needs to be swapped or charged.

As the steps are basically outlined above, this section will not go into as much detail.

Update the conditions to match the following.

  • Choose battery-voltage for the Action Feed.
  • This time, you're tracking whether the feed value has dropped below a specific threshold, so you'll choose less than for Select Comparison.
  • The voltage below which your battery is no longer a viable power source is 3.5V, so you'll update the Value to 3.5V.
  • Choose email me, as before.
  • Choose battery-voltage as the Select Value Feed.
  • Finally, update the email content to match what's shown below, or to whatever fits your needs.

The major difference between the new mail set up and the battery voltage set up is found in the final two steps. Above you are instructed to leave the default options.

The battery voltage is sent every twelve hours, and when the mailbox door opens (though, it is not continually sent while the door is open). If the limit on emails was kept short, you would be receiving emails every time the battery voltage is reported to Adafruit IO (up to three times per day). As that's entirely unnecessary, you'll change Limit Every to One Day. This means you'll only receive an email once per day, regardless of how often the data is sent to Adafruit IO.

As before, the Notify on Action Reset should be left at its default of unchecked.

When you're ready, click Submit. You'll now see the new Action added to your list!

Verify both of your Actions are Active before continuing!

This guide was first published on Sep 14, 2022. It was last updated on Apr 23, 2024.

This page (Adafruit IO Reactive Action) was last updated on Mar 08, 2024.

Text editor powered by tinymce.