Skip to content

Events & actions ​

CocktailPi can react to what happens on the machine: play a sound when a cocktail is ready, switch on LEDs while the pumps run, or notify your home automation. You set this up under Administration → Events (Super-Admin), as a list of actions, each with a trigger.

Event management

Triggers ​

TriggerWhen
Cocktail production startedAn order starts
Cocktail production manual interaction requestedThe machine waits for someone to add an ingredient or follow an instruction
Cocktail production manual interaction completedSomeone pressed Continue
Cocktail production finishedThe cocktail is ready
Cocktail production canceledThe order was cancelled or failed
Application startedCocktailPi has started

Actions ​

  • Call URL – sends a GET, POST, PUT or DELETE request to a URL, e.g. a webhook of your home automation.
  • Play audio file – plays a .wav file (max. 20 MB) on an Output device of the Pi, with a Volume and optionally On repeat.
  • Execute python script – runs a Python 3 file (max. 20 MB). Its console output can be watched live with View logs.
  • Do nothing – does nothing itself, but can stop other running actions (see execution groups).

Running actions can be stopped with Kill process, and every action can be started by hand with Start to test it.

Python scripts and libraries ​

Scripts run on the Pi with the rights of the CocktailPi service, in a separate Python environment (a venv) in the CocktailPi folder. Libraries are installed into it on the command line; with the standard installation:

bash
sudo -i
/root/cocktailpi/venv/bin/pip3 install <library>

The venv folder is created when the first script runs or when you press the button that lists the Installed Python libraries in the action editor.

WARNING

Don't use GPIO pins in a script that CocktailPi uses for pumps, the load cell or reverse pumping.

Execution groups ​

Execution groups decide what happens when actions overlap:

  • An action without a group runs on its own: it doesn't cancel others and isn't cancelled by others (only by being started again).
  • An action with groups cancels all running actions that have groups but don't share any of its groups. Actions with a common group can run at the same time.

Example: a chime until someone helps ​

The machine waits for a manual step, and nobody notices. Let a sound repeat until someone presses Continue:

  1. Add action → trigger Cocktail production manual interaction requested → Play audio file, choose a short chime .wav, tick On repeat, execution group chime.
  2. Add action → trigger Cocktail production manual interaction completed → Do nothing, execution group silence.
  3. Add the same Do nothing action for Cocktail production canceled, so the chime also stops when the order is cancelled.

When Continue is pressed, the Do nothing action starts. Because it doesn't share a group with the chime, it cancels it.

Try the online demo

Log in with the credentials below. The demo is shared with other visitors and is reset from time to time, so your changes may be lost.

User
Admin
Password
123456