# Guard check-ins and site coverage

> How to make sure every site has a guard on duty with Vigil. An agent checks who is signed in, sounds a sign-in request when nobody is, and escalates.

Source: https://vigilsecure.net/docs/examples/guard-check-ins/

**The scenario.** A site must have a guard on duty from 18:00 to 06:00. You want to know
within the hour if a guard has not arrived, has left early, or has gone quiet, without a
supervisor phoning every site.

## How Vigil represents it

| The real world                        | In Vigil                                                                                          |
| ------------------------------------- | ------------------------------------------------------------------------------------------------- |
| The post                              | A [site](https://vigilsecure.net/docs/concepts/sites.md) with a location                                                   |
| "A guard is on duty"                  | A [user](https://vigilsecure.net/docs/concepts/users.md) is signed in on a [device](https://vigilsecure.net/docs/concepts/devices.md) near the site |
| The hourly check                      | An [agent](https://vigilsecure.net/docs/concepts/agents.md) with a schedule                                                |
| "Is anybody there?"                   | A **sign-in request**, a device command that sounds an alarm on the device                        |
| "Nobody answered"                     | A message from the agent to a supervisor                                                          |
| A shift that ended without a sign-out | A **sign-out** command                                                                            |
| The proof                             | The device's event log: every sign-in and sign-out with its time                                  |

There is no roster to maintain. Coverage is read from what is true on the ground: a device
at the site with somebody signed in on it.

## Set it up

1. Give each site a location, by adding it from the map. The agent finds a site's devices
   by looking for devices within a few hundred metres of it.
2. [Link a device](https://vigilsecure.net/docs/concepts/devices.md#link-a-device) for each site and keep it there.
3. Create an agent with instructions like these:

   ```text
   You watch the night-shift coverage of all our sites.

   Every hour on the hour from 18:00 to 06:00, check each site. If somebody is signed in
   on a device at the site, do nothing. If nobody is, request a sign-in on the nearest
   device.

   If a site has had nobody signed in for two checks in a row, tell Thandi Nkosi in her
   chat: the site, the device and since when.

   At 06:30, sign out anybody who signed in before 19:00 and is still signed in.
   ```

4. Give the agent a role that can view sites and devices, see device locations and send
   device commands. The admin role has these, or create a
   [custom role](https://vigilsecure.net/docs/concepts/roles.md#custom-roles) with only them plus **Create
   channels**, so it can message people.
5. Message the agent once to start it: "Set up your schedules from your instructions."
   Schedules are created by the agent itself, so nothing happens until you ask. Check the
   agent's **Schedules** tab to see them.

## What happens on a shift

1. **18:00.** The agent checks every site. At Rosebank Mall, Sipho signed in at 17:52. It
   does nothing.
2. At the depot, nobody is signed in. The agent sends a sign-in request to the depot's
   device. The device sounds an alarm and shows **Sign In Requested**.
3. Lindiwe, who had arrived but not signed in, taps **Acknowledge** and signs in with her
   ID number.
4. **19:00.** The agent checks again. The depot is covered. The clinic has had nobody
   signed in at 18:00 and at 19:00, so the agent messages Thandi: "Bruntville Clinic: nobody
   signed in since 18:00. Sign-in requested on Clinic gate twice, no answer."
5. **06:30.** Sipho went home without signing out. The agent signs him out, so the day
   guard's sign-in is the one that counts.

A sign-in request never interrupts a working guard: a device with somebody signed in
ignores it.

## What you can see afterwards

- On each device's **Events** tab: every sign-in and sign-out, with the time.
- On the **State log** tab: where the device was through the night, and its battery and
  signal.
- From an agent: "Publish a coverage report for November: for each site and night, when
  the first guard signed in and when the last signed out."

## Limits to know about

- A sign-in request travels to the device over the internet. A device that is off, flat or
  out of signal for more than five minutes does not receive it. The agent's escalation to a
  person covers that case.
- Devices report their position about every ten minutes. A device that has just arrived at
  a site may take a few minutes to count as being there.

## Variations

- **Welfare checks.** For lone workers, have the agent message the guard on the hour, and
  check at ten past whether they replied.
- **Named devices.** For a large estate, name the site's devices in the agent's
  instructions instead of relying on distance.

## Related

- [Guard patrols](https://vigilsecure.net/docs/examples/guard-patrols.md)
- [Device fleet monitoring](https://vigilsecure.net/docs/examples/device-fleet-monitoring.md)
