Metadata-Version: 2.4
Name: juracoffeemachine
Version: 1.5.9
Summary: Controls a Jura E6
Author-email: Seb-sti1 <noreply@kerbourch.fr>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/Seb-sti1/juracoffeemachine
Project-URL: Repository, https://github.com/Seb-sti1/juracoffeemachine
Project-URL: Issues, https://github.com/Seb-sti1/juracoffeemachine/issues
Keywords: jura,coffee,coffee-machine,e6,raspberry-pi
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Home Automation
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyserial==3.5
Requires-Dist: RPi.GPIO
Dynamic: license-file

# juracoffeemachine

[![Publish](https://github.com/Seb-sti1/juracoffeemachine/actions/workflows/publish.yml/badge.svg)](https://github.com/Seb-sti1/juracoffeemachine/actions/workflows/publish.yml)
[![PyPI](https://img.shields.io/pypi/v/juracoffeemachine)](https://pypi.org/project/juracoffeemachine/)
[![Python](https://img.shields.io/pypi/pyversions/juracoffeemachine)](https://pypi.org/project/juracoffeemachine/)
[![License](https://img.shields.io/pypi/l/juracoffeemachine)](LICENSE)

Python package to control a Jura E6 coffee machine through its service UART.
It is used by [coffee_tag](https://github.com/Seb-sti1/coffee_tag), an app that tracks how many coffees each person
takes, so it aims for high reliability and low maintenance.

> [!NOTE]
> Tested on a machine answering `ty:EF532M V02.03` to `TY:` and `tl:BL_RL78 V01.31` to `TL:`.
> The driver refuses to talk to any other machine.

## Features

- Brew (or stop) a coffee with a chosen quantity of beans and water.
- Check the machine state before brewing (sleeping, trays, water tank, etc.).
- Read the coffee counters.

## Install

Requires Python >= 3.11.

```shell
pipx install juracoffeemachine
```

## Usage

For the wiring, see the [hardware section of coffee_tag](https://github.com/Seb-sti1/coffee_tag#hardware).

From the command line (`juracoffeemachine -h` lists all the actions):

```shell
juracoffeemachine /dev/ttyUSB0 brew_coffee
```

From python:

```python
from juracoffeemachine import CoffeeMaker

machine = CoffeeMaker.create_from_uart("/dev/ttyUSB0")
machine.brew_coffee(4, 100, lambda result, date: print(result, date))  # 4 beans, 100 mL
```

> [!WARNING]
> Brewing overwrites the default beans/water settings stored in the machine's EEPROM.

## Where to look when something breaks

- Brewing or machine state: [coffee_machine.py](https://github.com/Seb-sti1/juracoffeemachine/blob/master/juracoffeemachine/coffee_machine.py)
- Protocol (encoding, commands, EEPROM addresses): [jura.py](https://github.com/Seb-sti1/juracoffeemachine/blob/master/juracoffeemachine/jura.py)
- Parsing of the machine's status messages (`HZ`, `CS`, `IC`): [response.py](https://github.com/Seb-sti1/juracoffeemachine/blob/master/juracoffeemachine/response.py)
- Serial port errors: [serial.py](https://github.com/Seb-sti1/juracoffeemachine/blob/master/juracoffeemachine/serial.py)

## Development

```shell
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
pytest tests/
```

Every commit on the default branch is published to PyPI by GitHub Actions, so remember to bump the version in
`pyproject.toml`. Bug reports, feature requests and pull requests are welcome.

## Acknowledgments & license

All the protocol used in this project was decoded by [COM8](https://github.com/COM8) in
[protocol-cpp](https://github.com/Jutta-Proto/protocol-cpp) (see also the
[Jutta-Proto](https://github.com/Jutta-Proto) organisation).
[Juramote](https://6xq.net/juramote/), [q42](https://blog.q42.nl/hacking-the-coffee-machine-5802172b17c1/) and
[at.ua](https://protocol-jura.at.ua/index/commands_for_coffeemaker/0-5) were also of great help.

See [LICENSE](LICENSE).
