# Questions for the agent and equipment event tasks

The agent reads the equipment data the gateway sent to the cloud: the tag catalog, current values, history, alarms, machine states and camera frames. Write in plain language; the agent finds the tags itself by place, name or path.

## What the agent reads

| What to ask | What the agent does |
|---|---|
| Where a tag is, what it is called | searches tags by place, name or path |
| What is happening now | takes the last value and its freshness |
| What happened over a period | reads history in intervals: minimum, maximum, average, last and gaps |
| Which alarms | shows active alarms or the transitions in a window |
| What the machines are doing | lists machines with their state word, freshness and alarms |
| What the area looks like | asks the gateway for an ONVIF camera frame |

By default the agent does not pass off a value of bad source quality as current: it takes the last good one and says that only bad values are newer. A stale value it calls the last known one, with its time. A connection turned off for the agent is not read.

<TryPrompt prompt="What was the supply temperature at the boiler house overnight: minimum, maximum and were there data gaps." />

<TryPrompt prompt="Which machines were idle the longest during yesterday's shift and which alarms fired on them." />

<TryPrompt prompt="Take a frame from the warehouse camera and tell me whether the aisle is blocked." />

A large set of raw points reaches the agent as a file that it works through in code, so you can ask for calculations over a long period.

## Event tasks

A task started **On event** listens to equipment events and runs the agent when the event happens. Describe in the chat what to watch and what to do, and the agent creates the task itself. How tasks work in general: [tasks](/help/tasks).

| Event | When it happens | Example |
|---|---|---|
| Threshold | a tag value is greater than, less than, equal or not equal to a number and held for the time you set | pressure above the setpoint for several minutes |
| Downtime | a machine is idle, stopped or interrupted for the time you set | a machine standing for over half an hour |
| Alarm raised or cleared | the source sent an alarm | an alarm on a CNC controller |
| Gateway gone or back | the gateway stopped coming online or came back | the link to the boiler house dropped |

<TryPrompt prompt="If the pressure in boiler 2 stays above 6 bar for longer than five minutes, message me on Telegram how long it held and what the peak was." />

<TryPrompt prompt="When the boiler house gateway goes offline, message me at once which connections it was reading." />

### How an episode works

Threshold and downtime work in episodes, not points. An episode opens when the condition has held for the time you set, and the task runs once per opening. It closes when the value has come back and stayed back for the time you set. A threshold can have a deadband: how far the value must move back from the threshold for the episode to close. If the value goes past the threshold again while the episode is closing, it is the same episode, not a new event. A value of bad quality neither opens nor closes an episode. If the task's condition is changed, an open episode closes with that reason.

### Alarms: which protocols

OPC UA, MTConnect, FANUC FOCAS and Mitsubishi CNC send alarms as events. For Modbus, S7, Sparkplug and the rest an alarm usually comes as a tag value: put a threshold on it, for example "alarm tag equals 1".

## Exporting data

The whole tag catalog, every sample and every alarm of the organization export as one JSON Lines archive under Integrations, on the Gateways tab, row **Equipment data**. Gateway secrets and connection credentials are never in the archive.
