HOW TO SEND MULTIPLE TYPE OF TELEGRAM MESSAGES WITH ILEVIA
INTRODUCTION
In this part of the guide it is explain how to set up multiple kind of messages that can be sent to the recipient. The messages can be sent as multiple selection messages (require a selection from the recipient), as image with description (send a message with an image attached) or as video message (send a video),
Multiple selection messages
The multiple selection messages allows the use to receive a messages that suggest multiple action such as: turn off certain light because no one is detected in a specific room for energy management or suggest to recharge the battery if the energy produced from the sun panel exced on the one consumed.
In this example it is explained how to set up the Telegram messages in order to suggest 3 possible energy management ways to manage the exceded energy produced by the sun panels.
Components configuration
Step 1:
In this example the sun panel will be replaced with a simple copy value logic that will copy a fake value into a info component that will simulate the energy production. Add the following components:
- A Changeable Value component;
- A Info component;
- A Telegram component;
- A Javascript component;
Set the copy value to the Changeable Value component in order to copy its value to the Info component.
Set up the telegram component with your own Telegram ID. Refer to the How to get the Telegram ID part of this guide for further information about getting your telegram ID.
The script to insert within the Javascript component is the following:
{
var consumed= getValueAsBoolean(17);
if(consumed>=4000){
log(res);
return “ok, i will ” +res;
}
}
sendTelegramRequest(“Your_telegram_id”,”You are making a lot of energy, do you want to use it for:”,”Boiler|Charge battery|Make the swimming pool warmer”,”Exceded energy”);
Basically the script will send a message to the specified Telegram ID once the value reaches the set threshold displaying the 3 possibilities set within the parameter sendTelegramRequest.
Add the Changeable value component and the Info component into the user interface.
VISUAL RESULT
This is the visual result within the Telegram app once the threshold is reached by the Energy meter. As you can see from the picture below, the message will display 3 possible choices that once pressed can trigger other logic setup inside the Ilevia server.
Click the link below to download the demo project and try it your self.
Message with image attached
This part of the guide will explain how to set up the telegram message to send an image attached once a component is triggered.
Now add the script that will link the triggering of the Doorbell with the sending of the image to the Recipient.
var doorBell= getValueAsBoolean(19);
if(doorBell==true){
sendTelegramImage(“Your_telegram_id”,”Someone rang the doorbell”,”Http URL or Http string of the ip camera image”);
}
}
setTrigger(19, “doorbellAlert”);
Add the switch component into the user interface and upload the project to the server.
Click the link below to download the demo project and try it your self.