ECM_Control/SPECS.md

44 lines
2.1 KiB
Markdown

Using https://github.com/lucapinello/pyacaia
I want to control my coffee machine.
I have a relay on GPIO2. It's normally open. The relay closes the circuit that would be driven by the button normally.
It needs to emulate a push in order to start and stop the machine.
So my app needs 2 parts : a web app and a script that will drive the machine.
The webapp need to :
* Create simple recipe : Grams out of timeout which ever comes first. Recipe name
* A link between the 4 buttons and the recipe to trigger the right one
* Show a log of all pulled shots, mapped with what button was pressed and the assossiated recipe
* Allow to find and pair with scales and remember the current scale for the script to use
* Allow the user to drive script parameters : Scale to use, time before a shot is considered pulled (so to add it to the pulled shots log), list of buttons ont the machine and which GPIO it's bind to.
The script needs to :
* Listen for button push on all defined GPIOs
* When a registered button is pushed : Tare the scale, start the machine with the defined values from the target recipe. Take note of the start datetime start a timer
* Look for the set grams out or timeout from the recipe and stop the machine when the first parameter is reached
* Stop the machine
* Keep reading the scale weigth until it goes down significantly or it goes up for less then 0.1g in a second. At that time note the highest gram value and add the shot to the log. Also note the time at which you stopped the machine, the time when the outpout weigth has changed or stopped climbing, the button pressed, the recipe linked to.
If the user pushes the button before the shot is done, and the shot time is lower then the set timeout, log the shot but add a "cancelled" value. If it's above, log it as a succesful shot.
# Technical details
* Use Python
* Use SQLite
* Make the webapp use HTMX, FastAPI
* Create a systemd unit to handle the script
* Have logs and verbosity level for both the script and the webapp. Make sure the script has a DEBUG verbosity level to help with debugging
* Write a Readme
* Use Git
* Use UV