# Geofencing function in the Localino system

### **1. Introduction**

Geofencing enables the monitoring of trackers (e.g. tags) within predefined zones. An alarm is triggered when a tracker leaves a zone.

#### **Requirements**

* **Integration:** The Localino app must be correctly integrated into Eliona.
* **Zone definition:** Geofencing zones must be defined in Localino.
* **Action WebSocket:** An Action WebSocket must be set up in Localino.
* **Action port:** The Action port must be entered in the Localino database (schema `localino`, table `config`).
* **Tracker assignment:** The tag to be monitored must be assigned to an asset on which the automatic rule is to be created.

{% hint style="warning" %}
The most important information that must be sent via the `/actionwebsocket` is the **id** (hardwareid) of the tag and ideally the **ts** (timestamp).
{% endhint %}

#### **Additional information that could become relevant in the future:**

In addition to `id` and `ts` the following information could be important in the future:

* **Action Name** (`actionname`): The name of the action that triggers the alarm.
* **Group** (`hardwaregroup`): The group or category of the device.
* **Name** (`hardwarename`): The name of the tracker or the hardware.
* **Zone** (`zone`): The defined zone that is left or entered.
* **Action Trigger** (`trigger`): The specific trigger of the action, e.g. "ZoneLeave" or "ZoneEnter".
* **CrossDirection** (`crossdirection`): Information about the direction of movement, if relevant.

This additional data could be useful for advanced notifications or future features, such as more detailed alarm messages or integration with other systems.

***

### **2. Geofencing alarm process**

If everything is set up correctly, a rule is automatically created for a ZoneLeave event, and an alarm is triggered.

#### **2.1 Leaving a zone (ZoneLeave)**

* A **"ZoneLeave"**-trigger sets the attribute **`geofencing_alarm`** in the assigned asset to **1**.
* An alarm message is automatically triggered:

  ```arduino
  "{{asset.name}} is outside the allowed zone"
  ```

#### **2.2 Entering a zone (ZoneEnter)**

* A **"ZoneEnter"**-trigger sets the attribute **`geofencing_alarm`** on **0**.
* An alarm goes a message is sent confirming the return to the allowed zone:

  ```arduino
  "{{asset.name}} is back within the allowed zone"
  ```
