Controlling an Air Conditioner in a Server Room Using Telegram

  • Published In: Tutorial
  • Created Date: 2018-05-29
  • Hits: 2066

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:

IP address192.168.1.208

Login

visor

Password

ping

A number of a connected temperature sensor

1

A number of an IO line with a connected airflow sensor

IO 1

A command number of switching on a backup conditioner

2

A command number for switching off a backup conditioner

3

A command number to raise temperature for 1 °C

4

A command number to decrease temperature for 1 °C

5

A command number to switch on the mode «Cooling»

6

A command number to switch on the mode «Heating»

7

A command number to switch on the mode «Drying»

8

A command number to switch on the mode «Ventilation»

9

A command number to switch on a night mode

10

A command number to change a direction of air conditioner blinds

11

A command number to block a remote control

12

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.

UniPing server solution v3 - configuring notifications for Telegram

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):

Receiving a notification about temperature exceeding a temperature range from UniPing server Solution v3 in Telegram

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:

Telegram starting a dialogue with a bot for controlling a conditioner

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):

Telegram Switching on and off a backup conditioner using UniPing server Solution v3

Now, we need to switch on a backup conditioner. Select the button «Fault», afterward receive a message: «Standby air conditioner on»:

Telegram switching on a backup conditioner using UniPing server Solution v3

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:

Telegram receiving a notification about restoring the operation of a main conditioner from UniPing server Solution v3

Return to the dialogue with @UniPingSSv4_bot, click the button «/fault» (1) again, and choose the action «Fault» (2):

Telegram switching off a main conditioner using UniPing server Solution v3

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.

Telegram UniPing server Solution v3 requesting current temperature

Then, choose a command «/temp» (1), and correct current temperature using the actions of this command (2):

Telegram increasing or decreasing temperature using UniPing server Solution v3 requesting current temperature

Telegram correcting a temperature value using UniPing server Solution v3

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):

Telegram choosing an operation mode of an air conditioner using UniPing server Solution v3

On a screen below, there are the results of consequent clicking buttons-actions of a command «/mode»:

Telegram results of operation of buttons 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.


comments powered by Disqus