There has been an explosion of IoT devices across consumer and enterprise environments leading to IoT notification system needs. IoT or Internet of things devices comprises sensors, connected industrial equipment, and other hardware that has a network connection and can connect to the Internet.
Since the cost of smart devices has declined, even home users now have multiple devices that are connected and are now “smart” in that they have apps and software that allows users to control, monitor, and configure these devices.
Take a look at my video here covering the basics of getting push notifications running using Apprise and Mailrise:
What is the Internet of Things (IoT)?
Many have heard about the Internet of Things or IoT and may wonder what this includes. It typically includes small, compact, contains sensors, and is connected to the Internet via a hard wire, wireless LAN, or LTE connection through a mobile network connection.
Farmers are using IoT to know when they need to irrigate. A store may have security cameras and trigger IoT-related activities based on the foot traffic detected on an IoT camera.
The IoT platform is often talked about in the realm of home users. However, businesses are using IoT and IoT notification systems more and more in the realm of manufacturing facilities and any other environment where smart devices can be useful.
Cloud IoT
Many cloud providers offer IoT solutions such as Azure IoT and AWS IoT, allowing businesses to take advantage of cloud-managed IoT and extend their capabilities with all the cloud has to offer, regardless of location.
IoT Notification system
One of the capabilities extended to these devices is sending emails and other notifications. Email server notification service systems are getting dated, and email may no longer be the preferred medium for receiving alerts and notifications from devices, including the Internet of things. Let’s look at an IoT notification system with push notifications using apprise.
Why are notification systems useful?
Notification systems are useful for many reasons. Due to the nature of IoT devices, most can send notifications, alerts, statuses, and many other communications. These messages may contain any number of details.
Internet of things devices may have an alert system that can send notification messages when thresholds are crossed or data indicates a condition configured for alerting. If alerts or notifications are triggered, these need a way to be communicated. Once admins create the notification systems themselves, they need the code to handle which technology is used for transmitting the communication.
Notification systems like email and other services are used to receive these notifications. Configuring these is part of the overall notification settings. Historical data may be analyzed and can trigger notifications based on certain parameters when patterns are matched or other information is triggered.
As an example, an IoT device may contain ultrasonic sensor objects. The purpose of these sensors is to monitor readings and other data inputs. These may detect certain thresholds and trigger alerts to notify admins and user-client devices of the readings or a particular event.
Whether on the same device or different devices, notification system implementations are
MQTT broker messages
Modern apps commonly use the MQTT message protocol for Internet of Things (IoT) applications. MQTT is lightweight and has a publish/subscribe architecture allowing devices with very few lines of code to push and pull messaging. It has many use cases, including manufacturing and other sectors.
Configuring an IoT notification system
Setting up an IoT notification system requires a few steps, including setting up the IoT device, configuring the notification system, and creating the necessary code to send and receive notifications. Here is a general outline of the process in the following steps:
Set up the IoT device: The first step is to set up the device to send and receive notifications. This involves connecting the device to the internet and configuring any necessary settings, such as the sensor thresholds or the MQTT broker.
Configure the notification system: Next, you’ll need to set up the notification system, which typically involves choosing a messaging platform (such as AWS IoT or Azure IoT) and creating an account. You’ll also need to create a primary key, which is used to authenticate the device and protect against unauthorized access. With cloud platforms, you can set up rules like the AWS IoT rule.
Create the code: Once the device and notification system are set up, you’ll need to create the code to send and receive notifications. This typically involves using a programming language such as Python or Java and utilizing the messaging platform’s API (Application Programming Interface).
Test the system: Before deploying the notification system, it’s a good idea to test it to ensure it is working correctly. You can do this by sending a test notification.
Email – SMTP systems are now outdated
Traditionally, a notification solution has been made up of the ability to send an email. As a result, email has become a legacy means of communication. Users now use real-time messaging apps, web services, and other immediate communication platforms built into social media services.
Problems with Email/SMTP
Rightly so, email providers are cracking down on SPAM and other problems. With that, sending alerts and other IoT notification system messages may get flagged as SPAM or outright blocked altogether.
Email providers are looking at the source of email traffic and the email content. Without a proper reverse DNS record, DKIM, SPF, and other email security mechanisms, email servers commonly reject mass emails of all types.
What if we can bypass SMTP with an IoT notification system solution? Let’s look at Apprise.
Apprise – Single notification system for all messages
Apprise notifications support notifications to just about every popular notification and messaging platform available. Examples include Telegram, Discord, Amazon SNS, Gotify, Pushover, etc. It means you can use the Apprise platform as a singular platform to push messages to these very popular and common notification services. It provides many advantages as well for an IoT notification system. Note the following:
It provides a centralized notification library
There is only one syntax to learn and use for all the notification services
It supports the images and attachments
Response times are phenomenal since the messages are sent asynchronously
Apprise sounds great. However, many IoT devices and their software only support SMTP notifications. What if we want to use a solution like Apprise, with its many benefits and allow IoT devices that only support SMTP to use it?
Learn more about Apprise here: https://github.com/caronc/apprise
Mailrise
As mentioned earlier, email has become more problematic for my Internet of Things (IoT) and home lab use cases due to the challenges mentioned. I have bounced home lab notifications off the publicly available Gmail SMTP server for a long while.
Solves problems associated with email notification systems
However, if my lab SMTP relay forwards too many mail messages to my public email account bounced off Gmail, it gets sent to the tarpit for a period, and email communications fail until the hold is lifted on my home Internet IP.
Lately, I have been looking for a better way to do this. However, one of the challenges is that many IoT devices and other systems can only send notifications via SMTP and not more modern web-based protocols.
I found Apprise but wondered how I could use Apprise with traditional SMTP requirements. Then it led to Mailrise. It was then I discovered a project called Mailrise.
Overview of Mailrise
Mailrise is a free and open-source solution that spins up an SMTP server you can run in Linux or a Docker container allowing you to send regular SMTP messages to the solution and have these translated into Apprise messages.
According to the official Mailrise Github page, it is an SMTP relay that converts normal emails into Apprise notifications. It is intended for the home lab or network. It allows accepting normal ordinary email from the Internet of Things (IoT) devices that may be running legacy software with only SMTP notification capabilities and converting these to Apprise messages.
The official Github page says it can convert emails to over 60+ IoT notification services. The Mailrise daemon is easily configured by placing simple stanzas for each notification service in the Mailrise configuration file.
Then the email senders send to a specific email address that refers to the service referenced in the Mailrise configuration file, and the email is converted and routed to the appropriate service.
Merges email with modern notification services
This is a golden solution since it allows having the best of both worlds. The devices can still send what they understand, SMTP emails. Then, Mailrise translates these messages to the API calls needed for messaging using more modern solutions, using get and post details.
Mailrise – IoT notification system setup overview
Installing Mailrise is straightforward. You can either pull the latest Docker container or you can install Mailrise in a Linux VM like Ubuntu Server. Also, it is great as there isn’t complex management required with the solution. It is a straightforward setup process involving only the package installation, setting up the service, and creating a Mailrise configuration file.
Install Mailrise
The command to install Mailrise is the following:
pip install mailrise
Mailrise service configuration
After installation, you need to create a service file to start the service, along with a configuration file the service file references.
Let’s create the service file. It is located at /etc/systemd/system. We can name it mailrise.service.
The service file contains the following lines:
[Unit]
Description=Mailrise SMTP notification relay
[Service]
ExecStart=/usr/local/bin/mailrise /etc/mailrise.conf
[Install]
WantedBy=multi-user.target
Mailrise configuration file
As a general overview of the setup of the Mailrise configuration file, it simply needs to reference the target notification system in your Mailrise configuration file. One of the examples they gave was the Pushover notification system.
The Mailrise configuration file is located at /etc/mailrise.conf.
configs:
pushover:
urls:
- pover://user@token
Pushover Notifications
So to follow along with the workflow/communication flow: Mailrise uses Apprise, which then uses a notification system. As mentioned earlier, you can use many different notification solutions.
However, one I found that does exactly what I needed it to is Pushover. Pushover requires a one-time fee of $5 per device type. So you pay $5 for Android devices, $5 for iOS, $5 for Windows computers, etc. This was well worth it to me for home lab notifications.
Wrapping Up
It has been a fantastic move to get away from SMTP for notification purposes. I find the notification solution using Apprise notifications to be liberating, allowing modern messaging communication applications to receive notifications, alerts, and messages from the home lab.
0 Comments