> For the complete documentation index, see [llms.txt](https://wiki.inels.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.inels.com/inels-bus/inels-design-manager-idm3/tutorial-alarms-and-sms-messaging.md).

# Tutorial 9 — alarms and messaging

*Part 2 — Tutorials. Continues the project from* [*Tutorial 8*](/inels-bus/inels-design-manager-idm3/tutorial-timers-counters-and-conditions.md)*.*

***

## What you will build

* A leak detector that sends you a text message
* An alarm group that reacts when any of its inputs trips
* Control of the building by sending it an SMS

***

## 13.1 Two separate things

They get confused, so be clear about which you need:

|           | **Alarm groups**                           | **Messaging**                         |
| --------- | ------------------------------------------ | ------------------------------------- |
| What      | inputs watched together, with alarm states | SMS, calls, email out of the building |
| Needs     | nothing extra                              | a **GSM3-01M** module                 |
| Set up in | Group manager                              | Communication centrum                 |

You can use either alone. Together they make "the cellar flooded, tell me now".

> **Neither is a certified security system.** The **EZS** module (*elektronická zabezpečovací signalizace* — electronic security system) is the proper alarm subsystem, with zones, arming and tamper detection. This tutorial covers the general-purpose alarm and messaging features. For a real intruder alarm, see the Rev19 installation manual, chapter 11.

***

## 13.2 Alarm groups

An **Alarm** group holds **digital inputs** — as opposed to a Digital group, which holds outputs. Its members are watched together, and any of them can raise the alarm.

### Define it

1. **Managers** → **Group manager** → **Add**.
2. **Unicate name:** `WATER_LEAK`, **Type** `Alarm`.
3. **✓**.

### Fill it

1. **Groups** workspace tab → drag out a group icon → assign it `WATER_LEAK`.
2. Click the icon so it turns blue.
3. Click each leak-sensor input to add it.

Only digital **inputs** will join — an output will refuse.

### Alarm actions and functions

| Action              | Fires when                  |
| ------------------- | --------------------------- |
| `Alarm_Activated`   | the alarm becomes active    |
| `Alarm_Deactivated` | it is switched off          |
| `Alarm_Alert`       | a member trips while active |
| `Alarm_Refeshed`    | it is refreshed             |
| `Alarm_Changed`     | its state changes           |

| Function           | Effect               |
| ------------------ | -------------------- |
| `Alarm activate`   | arm it               |
| `Alarm deactivate` | disarm it            |
| `Alarm refresh`    | refresh it           |
| `Alarm disturb`    | signal a disturbance |
| `Alarm test`       | test it              |

Some functions take an **Alarm secure group** parameter naming the group to act on.

> **The action `Alarm_Refeshed` is missing an "r".** That is what appears on screen in this version. The *function* is spelled correctly as `Alarm refresh` — the two differ, so do not go looking for a consistent spelling.

### Wire it

1. **Add connection** → drag the `WATER_LEAK` group → a valve output or a siren.
2. **Wire manager** → **+**: **Action** `Alarm_Alert`, **User function** `DIGITAL_ON`.

Any sensor in the group now shuts the water off.

***

## 13.3 Add the GSM module

Everything below needs a **GSM3-01M** with a working SIM.

1. **Project** → **Device manager** → select the **central unit** → **New slave**.
2. Choose **GSM3-01M** → **OK**. Address it and describe it.
3. Close and save.

Up to **three** GSM3-01M modules are allowed per project.

***

## 13.4 Communication centrum

**Managers** → **Communication centrum**. Three tabs.

### Contacts — do this first

Nothing sends anything until a phone number exists *and* is bound to a GSM unit.

1. Open the **Contacts** tab.
2. Click the **green** button to add a number. (The red one removes.)
3. In **Value:**, type the number in **international format** — `+420xxxyyyyyy`.
4. **Person:** shows the name if this number came from the **Persons manager**.
5. Click the **red plug** icon next to **GSM:** and choose a GSM unit.

> **The plug must turn green.** A red plug means the number is not bound to a GSM unit, and nothing will be sent or received on it. This is the single most common reason messaging silently does nothing.

6. Confirm with **✓** at the top right.

Removing a number here removes it everywhere it was used — outgoing texts, incoming and outgoing calls.

### Items — the messages themselves

| List             | How many | What it is                                    |
| ---------------- | -------- | --------------------------------------------- |
| **Income SMS**   | 32       | text patterns to recognise on arrival         |
| **Outcome SMS**  | 32       | texts you send, each with up to 8 numbers     |
| **Income call**  | 8        | one number each; a dropped call sets an input |
| **Outcome call** | 8        | one number each; dials for 20 s               |

**Text length is limited to 32 characters** in both directions.

### Send a text when the cellar floods

1. **Items** tab → expand **Outcome SMS** → click a free slot.
2. In **SMS text**, type `CELLAR WATER LEAK`.
3. In **Phones:**, add the number — up to **8** per message, all in international format.
4. Assign the **GSM:** unit if it is not already green.
5. **✓** to confirm.

Then wire it:

6. **Design** tab → place an output icon → **Connect** it to that `SMS OUT` device → name it `SMS cellar leak`.
7. **Function** tab → **Add connection** → drag the `WATER_LEAK` group → `SMS cellar leak`.
8. **Wire manager** → **+**: **Action** `Alarm_Alert`, **User function** `GSM send SMS` (define it in Function manager — **Function type** `System`).
9. Save, upload.

Setting the `SMS OUT` device to ON sends the message.

> **Test with a real phone before you leave site.** Messaging depends on the SIM, the signal, and the contact binding — none of which the Simulation tab can check.

### React to an incoming text

An **Income SMS** slot holds a text to match. When a message arrives:

* the text is compared with your **SMS IN** entry
* the sender must be in **Contacts** with a GSM unit assigned
* on a match, the `SMS IN` device goes **ON for one second**

So: create an Income SMS entry `HEATING ON`, place its `SMS IN` device on the plan, and wire its `Digital IN switch ON` to `HEATING_COOLING_SWITCH_TO_FAVORITE4`. Now texting the house turns the heating up.

> **One second is all you get.** Use the pulse to set a **system bit** if the state needs to persist — see [Tutorial 8](/inels-bus/inels-design-manager-idm3/tutorial-timers-counters-and-conditions.md).

### Calls

A **drop call** is a cheap signal — it costs nothing and needs no text.

|                  | Behaviour                                                     |
| ---------------- | ------------------------------------------------------------- |
| **Income call**  | `CALL IN` is ON for the duration of the call from that number |
| **Outcome call** | setting `CALL OUT` to ON dials that number for 20 seconds     |

One number per slot, eight slots each.

GSM actions: `GSM income call`, `GSM end income call`, `GSM outcome call`, `GSM end outcome call`, `GSM income SMS`, `GSM end income SMS`, `GSM outcome SMS`, `GSM end outcome SMS`. Functions: `GSM send SMS`, `GSM short call`.

### Notices

The **Notices** tab lists **Income SMS**, **Outcome SMS**, **Income call** and **Outcome call** traffic — the first place to look when messaging is not behaving.

***

## 13.5 Email

There is an `Email outcome email` action and an `EmailOUT` device type, so the CU can send email as well as SMS.

***

## 13.6 A useful pattern: alarm with acknowledgement

Combining this chapter with the last one:

| # | Wire                                                        | Effect                             |
| - | ----------------------------------------------------------- | ---------------------------------- |
| 1 | leak group `Alarm_Alert` → water valve, `DIGITAL_OFF`       | shut the water off                 |
| 2 | leak group `Alarm_Alert` → `SMS OUT`, `GSM send SMS`        | tell somebody                      |
| 3 | leak group `Alarm_Alert` → system bit, `System bit set bit` | remember that it happened          |
| 4 | `SMS IN` "OK" → system bit, `System bit null bit`           | acknowledge by replying            |
| 5 | system bit `System bit true` → siren, `DIGITAL_ON`          | keep signalling until acknowledged |

Five wires, and the building now handles a leak by itself and keeps complaining until someone responds.

***

## What you learned

* **Alarm groups hold inputs**; Digital and Analog groups hold outputs
* Messaging needs a **GSM3-01M**, and every number must be bound to it — **the plug must be green**
* Numbers are always in **international format**; texts are limited to **32 characters**
* Incoming SMS gives you a **one-second pulse** — latch it into a system bit if you need it to last
* Drop calls are a free signal in both directions
* The **Notices** tab is your messaging log

***

## Try this before moving on

1. Text yourself when the front door opens while `HOLIDAY_MODE` is on — one wire, one condition.
2. Set up an incoming text that puts the whole house into holiday mode.
3. Use an outgoing drop call instead of an SMS and compare which you notice faster.

***

**Next:** [Chapter 14 — Tutorial 10: reuse your work](/inels-bus/inels-design-manager-idm3/tutorial-macros-and-function-blocks.md) — macros and function blocks.
