Earlier in our blog, we examined the process of creating a bot for a «Telegram» messenger that allows to receive the information from sensors and IO lines of a NetPing server room environmental monitoring unit and power distribution unit per request and automatically. In this article, we will examine the example of a practical use of these bots by adding features operating in a link with a UniPing server solution v3 server room monitoring unit to a bot that allows controlling an air conditioner in a server room in any time and in any location (having the access to the Internet).
In our example, a bot mimics clicking the buttons on a remote control of an air conditioner using URL-encoded commands that will be sent to a UniPing server solution v3 server room monitoring unit. In turn, a device sends control commands that have been previously recorded to the memory using an IR module IRC-TR v2 to an air conditioner located in a server room.
Variants of applying this solution are as follows:
- A system administrator can switch on or off a backup conditioner in a server room using «Telegram» when he or she is not in the workplace, for example, during a weekend, holidays, of vacation. A reason to switch on a backup air conditioner must be a «Telegram» notification about temperature exceeding the top threshold of a safe range that is specified in the page "TEMPERATURE" of a device web interface. A reason to switch a backup air conditioner off must be a «Telegram» notification about triggering an airflow sensor that is installed at the air output of a primary air conditioner, which means that its operability has been restored;
- A system administrator can decrease or increase a cooling temperature without entering a server room and control air temperature according to the readings of 1-wire (THS) temperature sensor using «Telegram»;
- A system administrator can change the operation mode of an air conditioner without entering a server room using «Telegram».
Required Equipment, Software, and Preparation for the Development:
To implement the functionality of controlling an air conditioner, we will need the next set of equipment:
- UniPing server solution v3 server room monitoring unit (it is possible to use any model of a NetPing monitoring device and a power distribution block that will support connecting an IR extension module IRC-TR v2) – 1 pc.;
- IR module IRC-TR v2 – 1 pc.;
- 1-wire temperature sensor – 1 pc.;
- Airflow sensor – 1 pc.;
- PC or server with a preinstalled operation system Linux or Windows and an access to the Internet – 1 pc.;
- A local network for a connection between a monitoring device and a PC, on which a bot script is run – 1 pc.;
- A messenger «Telegram» on a PC or a smartphone with the access to the Internet – 1 pc.
Let's consider that a UniPing server solution v3 server room monitoring device is configured for the operation in your local network, and an IR module IRC-TR v2, airflow sensor and a 1-wire temperature sensor are connected. More detailed information about a configuration of a device can be read here. Also, let's consider a UniPing server solution v3 server room monitoring device configured for controlling an air conditioner. Configuration rules can be read here and here.
In our article, we will use the next parameters of a UniPing server solution v3 server room environmental monitoring unit:
A number of a connected temperature sensor
A number of an IO line with a connected airflow sensor
A command number of switching on a backup conditioner
A command number for switching off a backup conditioner
A command number to raise temperature for 1 °C
A command number to decrease temperature for 1 °C
A command number to switch on the mode «Cooling»
A command number to switch on the mode «Heating»
A command number to switch on the mode «Drying»
A command number to switch on the mode «Ventilation»
A command number to switch on a night mode
A command number to change a direction of air conditioner blinds
A command number to block a remote control
In the section «Notification» of a web interface of a monitoring device UniPing server solution v3, specify the notifications that will be sent to «Telegram» when temperature exceeds the top margin of a safe range (1) and when an airflow sensor registers an air flow from a primary air conditioner (2). Unfortunately, Cyrillic is not supported by a «Zapier» system. More detailed information about these settings can be read here and here.
Developing Functions of Controlling an Air Conditioner for a Bot @UniPingSSv4_bot
It is supposed that you have a configured server with OS Ubuntu, and bots are created according to the recommendations of a previous article. Let's develop an extended functionality for out bot @UniPingSSv4_bot. Edit the main script file that controls a bot – «bot.py». Source files of a bot can be downloaded here.
Working with a Bot for Controlling an Air Conditioner
Let's examine a variant of switching on/off a backup air conditioner. If we received a notification about a temperature exceeding a top margin of a safe range from the bot @UniPingSSv4_send_bot (see the article "How to Get the Information from Sensors Connected to NetPing Devices for Monitoring and Remote Control of Power Supply in Telegram?" for the information on the bot):
Enable a dialogue with a bot @UniPingSSv4_bot, in a script of controlling which we added a new functionality. After we send a command «/start» (1) to a bot, a memo will be displayed in a window dialogue (2), and below a field for entering a message, the buttons will appear (3) that duplicate commands for controlling a bot:
To switch on and off a backup air conditioner, a command «/fault» (1) is configured. After choosing it, in a dialogue window a notification about a selected command is displayed, as well as buttons for selecting possible actions(2):
Now, we need to switch on a backup conditioner. Select the button «Fault», afterward receive a message: «Standby air conditioner on»:
Now, we wait for a notification about restoring the operation of the main conditioner from a bot @UniPingSSv4_send_bot. And, if we got it, there is a need to switch off a backup air conditioner:
Return to the dialogue with @UniPingSSv4_bot, click the button «/fault» (1) again, and choose the action «Fault» (2):
Now, let's examine an operation order if there is a need to change the current temperature in a server room. At first, request current temperature using a command «/npstatus». Working with this command is described here in details.
Then, choose a command «/temp» (1), and correct current temperature using the actions of this command (2):
Let's examine the operation order to change the operation mode of an air conditioner. To do this, choose a command «/mode» (1), and specify a necessary operation mode of an air conditioner clicking a corresponding button (2):
On a screen below, there are the results of consequent clicking buttons-actions of a command «/mode»:
As a result of the organization of this integration of a microclimate monitoring device UniPing server solution v3 with a «Telegram» messenger, we get a convenient tool for remote controlling a microclimate of a server room from any location of the world, where there is an Internet connection.