AndreWohnsland / Coffeetracker

A Python and Qt-App which lets you track the amount of consumables (e.g. coffees) in your department (and more)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coffeetracker

A Python and Qt-App which lets you track the amount of consumables (e.g. coffees) in your department (and more). With this App you can add a quantity to a Database of coworkers and estimate the consumption or similar (in case of this example we use coffee). Later you can even chose to pay your debt (if you need to pay for it) or just generate competition graphs just for fun and to know who is the biggest junkie.

More Features are to come.

Minimal Requirements

- Python 3.6
- PyQt5
- Matplotlib 3.1
- numpy

The packages can usually be installed from Pypi with the pip install 'packagename' or your system according command.

A Raspberry Pi is not directly needed but highly recommended for the use. I use a 3b Model with a 3.5" Screen (480x320 px) and the according casing for that screen to build a cheap an mobile device.

Features

This app gives you the possibility to select your name and then add a quantity of the given item name to it. If it's desired you can also assign a price to that item, which gets added as debt to the user account. Otherwise the cost can also be set to zero, just to track the amount. Furthermore you can pay your debts or load credit to you account, add new accounts (in case you are not there yet), plot leader boards or change existing entries (e.g. change mistakes in naming or disable users who are not active anymore). There is also a threshold where the call to payment message will appear on the mainscreen. If this threshold is exceeded by the factor 1.5 the usere will also get an active message after each entry, until the debts are reduced again.

Mainscreen where you start:

alt text

Build in keyboard and numpad for typing:

alt text alt text

Plotting the leader board:

alt text

Feel free to try it out and give me feedback on it!

Install PyQt5 on RaspberryPi

You will need at least PyQt5 on your RaspberryPi. More information can be found at riverbank.
To install PyQt5 on your Pi run:

sudo apt-get update
sudo apt-get install qt5-default pyqt5-dev pyqt5-dev-tools

Install PyQt5 on other Systems

If you want to run some testing on other systems, you can get PyQt5 here.
As long as you are using a supported version of Python you can install PyQt5 from PyPi by running:

pip3 install PyQt5

Development on Non-Pi Hardware

As long as you are working on another hardware (for example on a Windows or macOS engine) best is to set the devenvironment to True, it will enable your cursor on the touchscreen:

devenvironment = True

Setting up the Program Parameters

There are some options before the first start you can set. For usual testing i recommend setting devenvironment to True for programming and adjustments, otherwise set it to false. The app_width and app_height parameters refer to your touchscreen resolution. In this case its a 3.5" Screen. As a DB name, you can choose whatever name you find fitting or prefer.
For the quantities there are basically three options: First, you can set a price on the quantity, if it costs nothing you can set it to zero. Then you can name the quantity, in our case it's coffee. And lastly, you can set a threshold, at which a call to payment label is shown when the according user is selected. Furthermore, if the threshold is exceeded by factor 1.5 (feel free to change it in you code) the user will also get a messagebox reminding him to pay (we could even go further with emailing or stuff like that, if we implement the email address into our DB).

devenvironment = True           # enables or disables your cursor
app_width = 480
app_height = 320
db_name = "tracker_test"    
paymentcall_threshold = 10      # When the pay message got displayed (critical is 1.5 that value)
quantcosts = 0.25               # cost of one quant (can also be 0)
quantname = "coffee"            # name of your quants 

Optional: Connect your PC with the Raspberry Pi App

In addition to the RPi App, there is a second App for the use on a Windows (or other) engine. The file run_desctopapp.py will start that program. It got the same features as the program for the Pi.

alt text

There are different methods to use that application. Via Config the connection type can be set. It is local and Demo Database by default for demonstration purposes. If you want to set up your own Database you can switch to this option. The program will then use the employees.db file instead of employees_dummy.db. Usually the data and logging happens on the Pi, and only optional via the pc app. Therefore the database is located on the Pi, the PC app will get it via sftp. To enable communication via the PC and the Pi, you need to set up a secure shell (SSC) on the Pi. This option is disabled by default on the Pi, also it is recommended not to use the default Pi password for this process but use an own secure one. The Pi and the PC needs to be in the same Network for this. You can read some further information on this process under the official documentation for SSH as well as for SFTP. To get your ip, connect the Pi with the Internet and use the ifconfig command on the Pi command line. Name and Password are defined by the user, please do not use default ones (at least for the password).

Since this app was developed after the Pi app was finished, this process uses a sqlite DB, which is not optional in terms of speed/performance. In the future it is planned to use another DB (for example PostgreSql).

About

A Python and Qt-App which lets you track the amount of consumables (e.g. coffees) in your department (and more)

License:MIT License


Languages

Language:Python 100.0%