# Automatic locking of vehicles

## Feature description

The auto lock feature is a service on the backend server of the TMF platform. It's running in a module called the toolbox. It's purpose is to prevent shared vehicles to be left unlocked when not in use.

If a vehicle's central lock or immobilizar is in an unlocked state and if certain conditions are met (see below), an attempt is made by this module to lock the vehicle.

## Auto locking conditions

Every vehicle is checked every 5 minutes unless the vehicle is in use. If a vehicle is in use the next scheduled check is the end time of the current active reservation.

An attempt is made to lock the vehicle's central lock and immobilizer if the following conditions are met:

1. immobilizer or central lock are in unlocked state
2. if there is still an active reservation on the vehicle, the end time has passed by at least 30 minutes
3. no phone is connected via bluetooth to the cloudboxx
4. the vehicle is in at least one home zone
5. the ignition has been off for at least 5 minutes
6. the doors are closed (not known for all vehicles)

## Turning off auto locking of a vehicle

By default, auto locking is turned on for all vehicles. It can be turned off for a specific vehicle in the control center. Open the vehicle in the control center, go to settings. In the settings tab you will find the option to turn on or turn off the autolock.

## Automatic emails

### &#x20;to the helpdesk

When the conditions are met and a locking command is send to a vehicle, a trigger called `auto_lock_doors_to_helpdesk` is fired.&#x20;

This trigger can be used by the messaging system to send an email to the helpdesk team to notify the helpdesk team about this incident. The email template for this is configured in a template called `autoLockDoorsHelpdesk`. The content of this email can be modified in Control Center.&#x20;

Example content with the available dynamic parameters:

> 1XJW617 (Partago Juno) was autolocked on 20210301T153650. The door status of this car is known by the system. The last person driving this car was Tim Alenus on 20210301T152500
>
> View reservation in control center

```json
{
  "content" : {
    "default" : "{car.licensePlate} ({reservation.resource.name}) was autolocked on {timestamp, time, yyyyMMdd'T'HHmmss}.<br>The door status of this car is {doorStatusKnown, select, false {not} other {}} known by the system.<br>The last person driving this car was {reservation.person.firstname} {reservation.person.lastname} on {reservation.startTime, time, yyyyMMdd'T'HHmmss}<br><a href='https://app.partago.be/admin/#/reservation/{reservation.id}'>View reservation in control center</a>"
  },
  "subject" : {
    "default" : "{car.licensePlate} was auto locked on {timestamp, time, yyyyMMdd'T'HHmmss}"
  }
}
```

### to the end user

There is also the possibility to notify the end user and to remind him to lock the car in the future. This feature has to be turned on and is turned off by default.&#x20;

If turned on another trigger is fired called `auto_lock_doors_to_last_user`. Again this trigger can be used by the messaging system to notify the last user. The email template for this email is defined in a template called `autoLockDoorsUser` and can be modified in the control center. Example content with the available dynamic parameters:

> Hi Tim,
>
> This email is to inform you that we have automatically locked the doors of Partago Juno for security reasons. You have used this car on March 1, 2021. We lock the doors automatically when a car is standing still in the home zone, the ending hour of your reservation is passed, and the doors are still unlocked. In this case we automatically lock the doors after 30 minutes and end the reservation. You can avoid this by making sure you set the correct ending hour and locking the doors yourself at the end of your reservation. Not doing this hampers the good working of our service. Thank you for your consideration.
>
> Best regards,
>
> the Partago team.

```json
{
  "content" : {
    "en" : "Hi {reservation.person.firstname},<br><br>This email is to inform you that we have automatically locked the doors of {reservation.resource.name}for security reasons.<br> You have used this car on {reservation.startTime, date, long}.<br> We lock the doors automatically when a car is standing still in the home zone, the ending hour of your reservation is passed, and the doors are still unlocked.<br> In this case we automatically lock the doors after 30 minutes and end the reservation.<br> You can avoid this by making sure you set the correct ending hour and locking the doors yourself at the end of your reservation.<br> Not doing this hampers the good working of our service.<br> Thank you for your consideration.<br><br> Best regards,<br><br>the Partago team."

  },
  "subject" : {
    "en" : "Whoops, you forgot to lock the doors of {reservation.resource.name}",
  }
}
```

Currently you cannot enable or disable the sending of this email in the control center. Contact TMF support for this.&#x20;
