
As the attentive reader remembers, there
is a controller in my home that automates some commonplace processes like blinking light, which no doubt is necessary for every Arduino based controller.
But that is not the problem. And the fact that I chose to receive notifications about various events by e-mail, because it was the easiest way at the very beginning. Now, I was tortured periodically to scrape a bunch of statuses from the mailbox (this is optional, but it’s necessary for the order), and I thought that since there is such an excellent Telegram, then why not use his talents for his own purposes.
')
The following are my existential experiences on the crossover of PushingBox, IFTTT and Telegram with
blue tape to get a low-budget (and equally insane) notification system.
Tl / drDear friends! No, I do not have a home server. And no, I do not plan to install a server to service the Arduino Uno notification system. Only if completely squeezed.
First, a few words about the previous configuration. In ancient times, in one of the sleeves of a distant galaxy free mail servers were allowed to send mail via SMTP via HTTP. That is, the Arduino Uno board in a duet with an Ethernet shield worked quite easily with this task.
Then they all switched to HTTPS / SSL together (I hope I set out correctly) and had to invent something else, since Arduino Uno is no longer capable of HTTPS. The
solution to the situation was the
PushingBox notification
service , which receives the usual HTTP-request from Arduino Uno, and uses its parameters to send a notification letter (PushingBox can send letters itself).
By the way, I liked this thing even more - it works much faster than communicating with a POP / SMTP server.
Even better, PushingBox can also perform HTTPS requests. And, therefore, is friends with modern web services. Actually, I was already thinking about the topic that I probably need to make my Telegram bot and try to make friends with PushingBox, when I saw that Telegram was already working successfully with the automation service
IFTTT .
And then I could not resist. The fact is that IFTTT is as interesting to me as it is useless. Those. 99.9% of its capabilities I simply have nowhere to use: in social networks it is inactive, I do not buy smart glasses, boring, in a word, personality.
So I decided, of course, to give IFTTT a chance.
For arbitrary interactions with the outside world, IFTTT
has a Maker service that can send and receive HTTP requests. For the problem being solved, of course, the second is more relevant.
Further, to work with Telegram, IFTTT
generally has a specialized service that allows you to send messages, pictures, music to a chat or group. The most important thing for me is the ability to send a message in a private chat. I don’t need anybody to read the statuses.
It remains only to link everything:
Arduino → PushingBox → IFTTT → Telegram
Sending a request with a notification to PushingBox for me personally looks something like this (of course, there are more statuses and, of course, Ethernet initialization has been added):
#include <Ethernet.h> #include <avr/pgmspace.h> // PROGMEM char servermail[] = "api.pushingbox.com"; // PushingBox // PROGMEM const char statusString_0[] PROGMEM = "Room_softlight_ON"; const char statusString_1[] PROGMEM = "Kitchen_softlight_ON"; const char statusString_2[] PROGMEM = "Humidifier_ON"; // PROGMEM const char * const statusString[] = { statusString_0, statusString_1, statusString_2, }; char statusStringBuf[40]; // void sendMail(byte statusStringN) { mail.stop(); if (mail.connect(servermail, 80)) { strcpy_P(statusStringBuf, (char*)pgm_read_word(&(statusString[statusStringN]))); mail.print("GET /pushingbox?devid=_PUSHINGBOX&status="); mail.print(statusStringBuf); mail.println(" HTTP/1.1"); mail.print("Host: "); mail.println(servermail); mail.println("User-Agent: Arduino"); mail.println(); } delay(1000); mail.stop(); }
As it is easy to see, the notification is transmitted in the & status parameter, which should then be manipulated within PushingBox. To do this, first click My Services and add the Custom URL service with the necessary parameters (they are indicated in the IFTTT campaign) and a memorable name.
Time:

Two:

Three:

Then you need to add a script that will use this service. And this is where the contents of the & status parameter come in handy, which in PushingBox is assigned to the almost the same variable $ status $. In general, any parameter passed to PushingBox is transformed into a variable of the same name, fringed with the icons of our box.

So, click on My Scenarios, where after entering the name you need to add an action. For an action related to IFTTT, you will need to know the authorization key, which is displayed
on the Maker service settings page in IFTTT (you need to log in and / or register with IFTTT to see):

So, after clicking Add an Action, you should select the Custom URL service created earlier in PushingBox, and in the Data parameter specify the remainder of the string that should be sent to IFTTT to trigger the condition.

For example, according to the IFTTT instruction, the request should look like this:
https:
From this already (when adding a service) there is a
maker.ifttt.com/trigger in PushingBox , so it remains to add the event {event} and the final part with the authorization key.
So the following combination of characters is boldly entered into the Data field mentioned above:
$status$/with/key/_
I repeat once again, in this case, $ status $ is not something unshakable. Your variable can be called anything. But in the framework of this example, I will stick to this terminology.
So, PushingBox and IFTTT are related. It remains to become attached to the Telegram, and then begins the burden. The fact is that IFTTT (as opposed to PushingBox) responds to specific conditions and performs specific actions. He cannot be told to transfer all incoming requests that are suitable for the conditions, immediately to Telegram.
No, you need to add a processing rule for each condition. Therefore, the procedure described below will have to be repeated by the number of required notifications.
So go to IFTTT:
1) Add a new applet with the Maker service - Receive a web request



2) In the Event name field, specify the parameter that is passed through the $ status $ variable from the PushingBox. In my case, this, for example, could be Humidifier_ON (or Intercom_unarmed). Accurate to the letter and register.


3) Click on Create trigger and select the Telegram service for the condition triggering action. When using the service for the first time, it will be necessary to authorize the IFTTT bot, but this is not a problem.
Authorization:

Service selection:

4) As an action - Send message. Here, the default parameters will already be specified - the address (chat or group) and a preformatted message. If the message suits you, you can use it or collect something of your own from modifiers. In general, I replaced the entire text with a more understandable explanation of what happened.


Those. instead of say
What: {{EventName}}<br> When: {{OccurredAt}}<br> Extra Data: {{Value1}}, {{Value2}}, {{Value3}},
In the case of the Humidifier_ON, I wrote “Humidifier on” (and in the case of the intercom, as in the screenshot - “On-door speakerphone: unlocked”). This is the message I will receive from the IFTTT bot when the specified condition is triggered.

Done:

And all these torments only in order to finally see:

No, I do not argue. It would be possible to replace the Arduino with something more advanced. Or screw in there an ESP8266, for which there is already a TelegramBot library, which allows you to send messages to Telegram directly, without intermediaries like PushingBox or IFTTT.
Maybe I’ll do just that if PushingBox and IFTTT disappear, like AltaVista and Yahoo! .. But for now my position is firm: it’s easier for me to write a few lines of code or to configure software than to take a soldering iron in my hands.
Sorry.
But I believe that you are better than me, and you will surely do something more impressive. In the meantime, if you have more thoughts and comments, then I and the readers will be very grateful for everything.