Automation

What is an Automation?

“Automation” is a feature which can automate tasks in AAPS.

Automation performs specific actions based on one or more conditions or triggers. Triggers can include irregular events like low or high blood glucose (BG) levels, or a set amount of negative insulin on board (IOB). Automations can also handle recurring events, such as meals or exercise at certain times of day, or when the user is within a specific distance of a GPS location or a Wi-Fi SSID area. Automation can execute AAPS settings backups based on a schedule or on every Pod change.

Automation rules are created and modified from the Automation screen (Manage → Automation). Each rule is defined by two properties:

  • One or more conditions or ‘triggers’ that start an action.

    Think of a certain time schedule, an event or properties value in AAPS

  • One or more actions to perform.

    Such as an alarm or setting a profile percentage or exporting the AAPS settings on Pod change.

There are a wide range of Automation options, and users are encouraged to study these within the AAPS app, in the Automation section. You can also search the AAPS user groups on Facebook and Discord for Automation examples from other users.

How Automation can help

  1. Automate recurring tasks: Automatically executing programmed actions without user interaction.

  2. Decreasing decision fatigue: The primary benefit of Automations is to relieve the user from the burden of having to make manual interventions in AAPS. Research estimates that an average of 180 additional daily decisions have to be made by those living with Type 1 diabetes. Automations can lessen the mental load, freeing up the user’s mental energy for other aspects of life.

  3. Potentially improving glycemic control: for example, Automations can help ensure Temp Targets are always set when needed, even during busy schedules or periods of forgetfulness. For example, if a child with diabetes has sports scheduled at school on Tuesdays at 10am and Thursdays at 2pm and requires a high Temp Target (‘TT’) actioned 30 minutes before the sports activity, the Temp Target can be enabled by way of an Automation.

  4. Enabling AAPS to be highly customized to be more or less aggressive in specific situations, according to a user’s preference. For example, triggering a temporary reduced Profile % for a set period of time if negative IOB develops in the middle of the night, indicating that the existing Profile may be too strong.

The example below illustrates how an Automation can enable steps to be eliminated.

User exercises every morning at 6 am: he needs to remember to manually set a “Temp Target-Activity” in AAPS at 5am, before exercising.

Manual actions without automation

The user has set an Automation to trigger a 5am ‘Temp Target-Activity’ to ensure their BG and IOB are optimal, in preparation for their 6 am exercise:

Actions done by an automation

Key considerations before starting with Automations

  1. Before setting up certain Automations, you should have reasonable BG control with AAPS. Automations should not be used to compensate for sub-optimal basal, ISF or CR settings (discussed further below). Avoid setting an automated Profile switch to compensate for BG rises due to e.g. food, these are better dealt with via other strategies (SMBs etc).

  2. As with any technology, CGMs, Pumps and phones can malfunction: Technical issues or sensor errors can disrupt the Automation actions, and manual intervention may be needed.

  3. Requirements for Automations are likely to change as routines change. When changing between work/school/holiday periods, set a reminder in your calendar to review which Automations are currently active (they are easy to activate and de-activate). For example, if you go on holiday, and no longer need an Automation set up for school sports or daily exercise, or need to adjust the timings.

  4. Automations may conflict with each other, and it is good to review any new Automation(s) setting carefully in a safe environment, and understand why an Automation may or may not have triggered in the way you expect.

  5. If using Autosens, try to use Temp Targets instead of Profile Switches. Temp Targets do not reset Autosens back to 0. Profile Switches reset Autosens.

  6. Most Automations should only be set for a limited time duration, after which AAPS can re-evaluate and repeat the Automation, if necessary, and if the condition is still met. For example, “start temp target of 7.0 mmol/L for 30 min” or “start Profile 110% for 10 min” and “start temp target of 5.0 mmol/L for 10 min”. Using Automations to create permanent changes (e.g. to stronger %profile) risks hypoglycemia.

When can I start using Automation?

Automations can be started in objective 10.

Where are Automations located in AAPS?

Open Manage in the bottom navigation of the main screen and select Automation.

How can I set up an Automation?

To set up an Automation, press the + button on the Automation screen to create a ‘rule’:

Automation create

  • give your ‘rule’ a title (Task name);

  • press “EDIT” under Condition. On the Condition screen, choose how the triggers are combined (And, Or, Exclusive or) and press “Add trigger”:

Automation condition

  • add at least one trigger:

Automation triggers

  • press “ADD” under Action and select one action:

Automation actions

  • save the rule with the Save button, and make sure the checkbox left of the rule name is ‘ticked’ to activate the Automation:

Automation activated

To deactivate an Automation rule, untick the box left of the name of the Automation. The example below shows an Automation as either activated (‘ticked’) or deactivated (‘unticked’):

Automation rules switched on and off

When setting up an Automation, you can first test it by activating the ‘notification’ option under “Actions”. This triggers AAPS to first display a notification rather than actually automating an action. When you are comfortable that the notification has been triggered at the correct time/conditions, the Automation rule can be updated to replace the ‘Notification’ with an ‘Action’.

Alert actions

Important note

Automations are still active when the Loop is disabled!

When rules are checked

AAPS checks all Automation rules each time a new glucose reading has been processed, so rules are evaluated at the pace of your CGM, also while the phone screen is off. Rules are also checked when the phone starts charging, when the network or location changes, and when a Bluetooth device connects. Only one check runs at a time, so a rule whose actions take a while (for example a pump command) cannot be executed twice.

Safety limits

There are safety limits set for Automations:

  • A Temp Target set by an Automation has to be between 72 and 180 mg/dL (or 4 and 10 mmol/L).

  • The Profile Percentage has to be between 50% and 130%.

  • There is a 5 minute time limit between executions of Automation (and first execution).

Correct use of negative values

Warning

Please be careful when selecting a negative value in Automation

Caution must be taken when selecting a ‘negative value’ within the ‘Condition’ like “less than” in Automations. For example:

Comparison operators

Example 1: Creating a Condition “is lesser than” “-0.1mmol/L” (or “-2mg/dL”) will:

Trigger an Automation for any number which is strictly less than -0.1 (-2). This includes numbers like -0.2, -0.3, -0.4 (-4, -6, -8) and so on. Remember that -0.1 (-2) itself is not included in this condition. (The condition “is equal or lesser than -0.1mmol/L (-2 mg/dL)” would include -0.1 mmol/L or -2 mg/dL).

Example 2: Creating a Condition “is greater than” -0.1mmol/L (-2mg/dL) will:

Trigger an Automation for any number which is greater than -0.1mmol/L (-2mg/dL). This includes numbers like 0, 0.2, 0.4mmol/L, (0, 4, 8mg/dL) and any other positive number.

It is important to carefully consider the exact intention of your Automation when choosing these conditions and values.

Automation Triggers

Automation Triggers

Scroll down to see the rest of the list:

Automation Triggers, continued

There are various ‘Triggers’ that can be selected by the user. Triggers are the conditions that must be met in order for the automation to execute. The list below is non-exhaustive:

Trigger: connect conditions

Options:

Several conditions can be linked with

  • “And”

  • “Or”

  • “Exclusive or” (which means that if one - and only one of the - conditions applies, the action(s) will happen)

Trigger: time vs. recurring time

Options:

  • time = single time event

  • recurring time = something that happens regularly (i.e. once a week, every working day etc.)

Trigger: location

Options:

Trigger: location service

Options:

  • Use passive location: AAPS only takes locations when other apps are requesting it.

  • Use network location: Location of your Wi-Fi.

  • Use GPS location (Attention! This can cause excessive battery drain!)

Triggers : pump and sensor data

  • Cannula age trigger: Available for all pumps

  • Insulin age trigger: Available for supported pumps

  • Battery age trigger: Available for supported pumps

  • Sensor age trigger: always available

  • Pod Activation trigger: Available for patch pumps

Note that for all age related triggers the equal comparison is unlikely to trigger, so in that case two triggers are required to create a range

  • Reservoir level trigger: Available for all pumps, comparison “NOT_AVAILABLE” is not working for this trigger as the value is always filled in AAPS

  • Pump battery level trigger: Available for supported pumps, comparison “NOT_AVAILABLE” is not working for this trigger as the value is always filled in AAPS

Action

Automation Actions

Scroll down to see the rest of the list:

Automation Actions, continued

Actions: start Temp Target

Options:

  • BG must be between 72 mg/dL and 180 mg/dL (4 mmol/L and 10 mmol/L)

  • TT works only if there is no previous Temp Target — AAPS adds this automatically as a “Preconditions: Temp target not exists” line to the rule

Actions: stop Temp Target

Options:

none

Actions: Profile Percentage

Options:

  • Profile must be between 50% and 130%

  • works only if the previous Percentage is 100%

Actions: Change smoothing (in the Loop & insulin group)

Options:

  • select the smoothing method to switch to. The list is the same as under Configuration > Smoothing, and the action does exactly what a change there does: the new method is saved, synced to paired clients, and the BG data is smoothed again right away.

  • runs only if that smoothing method is not already active — AAPS adds this automatically as a “Preconditions: Smoothing … is not active” line to the rule. Once the selected smoothing is active, the rule is skipped silently.

  • Example: a new sensor is often noisy during its first day. Two rules with the Sensor age trigger give stronger filtering while the sensor settles, and lag-free smoothing after that:

    • Sensor age less than 24 h: Change smoothing to Unscented Kalman Filter

    • Sensor age more than 24 h: Change smoothing to Average smoothing

Actions: Note (in the Alerts group of the list)

Options:

  • select the event to record: Note, Exercise, Question, Announcement or Pump Site Change, and an optional note. The name of the action changes to the event you select.

  • Duration: used for Note, Exercise and Pump Site Change. Question and Announcement have no duration: they record your current BG instead.

  • Pump Site Change resets the cannula age, as if you had recorded a site change by hand. Example: some pumps (like the Combo) record a reservoir change by themselves, but not the site change. If you always change both together, a rule with Insulin age less than 1 hour and Cannula age more than 24 hours can record the site change for you.

The events of the Note action The Note action set to Pump Site Change

Actions: Send SMS to all numbers (in the Alerts group)

Options:

  • enter the text of the message. It is sent to all the phone numbers allowed in the SMS Communicator settings. The SMS Communicator plugin must be enabled.

Actions: Change profile to (in the Profile group)

Options:

  • select the Profile to activate. It is activated at 100%, without timeshift. If this profile is already active, the action does nothing.

Actions: Enable/disable SMB (in the Loop & insulin group)

Options:

  • choose On or Off. This changes the Enable SMB setting of OpenAPS SMB, exactly as if you had changed it in Settings, and stays until you or another rule change it back.

Actions: Run Autotune (in the Loop & insulin group)

Options:

Actions: Stop processing (in the Loop & insulin group)

Options:

  • none. While the conditions of a rule with this action are true, AAPS does not check the rules below it in the list. As soon as its conditions are false again, the rules below are checked as usual. Add it to a rule that must take priority over the rules below it (see the order of the Automations).

Actions: Run scene, Enable scene, Disable scene (in the Scenes group)

Options:

  • select the scene to run, enable or disable.

Once the ‘Action’ is added, the default values must be changed to the desired number by clicking and adjusting the default values.

Temp target action values

The order of the Automations in the list matters

AAPS will automate the rules created in the order of preference, starting from the top of the Automation list. For example, if the ‘Low’ Automation is the most important Automation, above all other rules, then this Automation should appear at the top of the user’s Automation list as demonstrated below:

List of automation rules

To reprioritize the Automation rules, touch and hold the = handle on the right side of the rule. Reorder the Automations by moving the rules up or down.

Reorder automation rules

How to delete Automation rules

To delete an Automation rule click on the trash icon.

Delete automation rules

Examples of Automations

Below are examples of Automations. Further discussion on Automations and how users have individualised their Automation can be found in Facebook discussions groups or on Discord. The examples below should not be replicated without the user having a good understanding of how the Automation will work.

Low Glucose Temp Target

This Automation triggers an automatic Temp Target when BG falls below a certain threshold — here, when glucose is lesser than 70 mg/dL, a target of 110 mg/dL is started for 30 minutes:

Example: low glucose rule

Lunch Time Temp Target (with ‘Location’)

Example: lunch rule

This Automation has been created for a user who eats their lunch at work around the same time every weekday but triggered only if the user is situated within a set ‘location’. So if the user is not at work one day, this Automation will not activate.

This Automation will set a low Temp Target (Eating Soon) at 13:00 to drive BG to 90 mg/dL (or 5 mmol/L) in preparation for lunch.

The ‘Trigger’ location has a name, a position (tap Pick from map, or use your current location) and a radius in metres, and fires when you are inside (or outside) the area:

Example: lunch rule with location condition

Because of the ‘And’ connection, the Automation only happens during the ‘chosen time’ and if the user is at the selected location.

The Automation will not be triggered on any other time at this location or at this time outside the 50-metre radius around the chosen position.

Wi-Fi SSID Location Automation

Using a Wi-Fi SSID is a good option to trigger an Automation while within range of a specific Wi-Fi network (compared with GPS): it is fairly precise, uses less battery, and works in enclosed spaces where GPS and other location services might not be available.

Here is another example of setting up a Temp Target for work days only before breakfast (1).

The Automation will trigger at 05:30am only on Monday-Friday (2)
and while being connected to a home Wi-Fi network (3).

It will then set a Temp Target of 75 mg/dL for 30 minutes (4). One of the advantages of including the location is that it will not trigger if the user is traveling on vacation, for instance.

Wi-Fi rule: task name (1), weekday time condition (2) and Wi-Fi SSID condition (3)

Scroll down to see the action: a Temp Target of 75 mg/dL for 30 minutes (4).

Wi-Fi rule action: Start temp target of 75 mg/dL for 30 minutes (4)

Here is the screenshot detailing the Automation triggers:

  1. Under the main “AND” (both conditions need to be met to trigger)

  2. Recurring time = M,T,W,T,F At 5:30am

  3. Wi-Fi SSID = My_Home_WiFi_Name

Example: WiFi condition

Automating Preference Settings Export

Unattended Exports: scheduled (daily)

Screenshots detailing the Automation triggers:

  1. Condition: Recurring time = M,T,W,T,F At 8:00am

  2. Action: Settings Export (For “Text in treatments” enter “Daily”)

Scheduled exports

Note: Export execution will be logged on Careportal

Unattended Exports: Pod Activation (patch pump only)

Screenshots detailing the Automation triggers:

  1. Condition: Pod Activation

  2. Action: Settings Export (For “Text in treatments” enter “Pod Activation: settings export”)

Export on Pod activation

Note: Export execution will be logged on Careportal. Note : Automation will not trigger at all if you have not done a manual settings export before. See Settings → Maintenance for proper activation of unattended settings export.

Automation Logs

AAPS shows a log of the most recent Automation events at the bottom of the Automation screen, below the rules. Use it to verify that your rules triggered when you expected them to.

In the example below, the Low glucose temp target rule (1) (see Low Glucose Temp Target above) is enabled. The log (2) shows that at 03:09 PM, glucose fell below 70 mg/dL and the rule triggered:

  • the action was “Start temp target: 110mg/dL@30 min”: a Temp Target of 110 mg/dL for 30 minutes;

  • OK at the end means that the action was carried out successfully.

Automation screen: an enabled rule (1) and its log entry (2)

Troubleshooting

  • Problem: My automations are not being triggered by AAPS?

Check that the box left of the Automation name is ‘ticked’ to ensure the rule is activated:

Automation rules switched on and off

  • Problem: My automations are being triggered in the wrong order.

Check your rule prioritization order as discussed above here.

  • Problem: A condition shows “Unknown trigger … - never true”.

The rule contains a trigger that this version of AAPS cannot read, for example after you went back to an older version or imported settings from a newer one. Such a trigger is never true, so the rule does not run. It is kept unchanged, so a newer version can still use it. Edit the rule and replace the trigger, or update AAPS.

Alternatives to Automations

For advanced users, there are other possibilities to automate tasks using IFTTT or a third party Android app called Automate.