To connect the Power of Home-Assistant with Label-Printer to print Froster-Labels and maintain a List of the Content of your Froster.
To print Froster-Labels and add the items to the Content-List of my Froster I use the following Workflow:
- In the Gui I enter the details of a product being added to the froster.
Additional Infos can be entered in my case:- Weight/Amount
- Color of the Container
- Color of the Cover
- Format of the Container
- by pressing a Button
- A label is printed with "Product", "Weight/Amount" and the actual Date and
- the Item is added to a ToDo-List called froster.
Now I am able to see the content of my froster in the ToDo list.
When I take Items out, i can check them and they gonna be deleted from the List.
- Label Printer Brother QL 810W
The Brother QL 810W has the possibility to store a template and print this template with Ad-Hoc provided date with a simple TCP/IP packet.
If you don't own this printer you have to find a possibility to print a label using a shell command e.g.: /usr/local/bin/printlabel -p PRODUCT -m AMMOUNT
My Home-Assistant runs as a Docker-Container, but I think this tutorial can also be applied to other Home-Assistant types of installation.
Howto generate and store Templates for the Brother QL 810W Label Printer.
You'l find my templates is located in the folder p-touch-templates, this should be a good point to start with.
There are two Templates
template_text.lbx
only one textfieldtemplate_froster.lbx
three textfields for product, ammount and date.
- This can be done with the
P-Touch Transfer Manager
(I used Version 2.5.004) or by - starting the
P-Touch Transfer Manager
from theP-Touch Editor
In the German Version it is done viaDatei/Vorlage übertragen/übertragen
- You have to take care, that the
Schlüsselzuordnung
contains the numbers of the template position, wehre it is stored in the printer.- The Printer must bee connected via USB.
- The Field
Schlüsselzuordnung
(maybekeyvalue
in English) contains the numbers of the template as handled by the printer.
- Then you can transfer the Templates to Printer by clicking
Übertragen
(maybetransfer
in English)
<
- Set the Printer that it can be accessed via WiFi and write down his IP-Address e.g.:
203.0.113.80
- To test the Template-Printing via WiFi use any Unix Shell with netcat ant type:
echo -e "^II\n^TS002\nBolognese\t550g\t22.02.2022\n^FF" | nc -N 203.0.113.80 9100
be sure to change the IP-Address to the one of your printer.
- Store the python-scripts
print_t1.py
and
print_t2.py
in the Config-Folder of your Home-Assistant installation (where your configuration.yaml is stored). - Edit the python-scripts
- Change
host = '203.0.113.80'
to match the IP-Address of your Printer
- Change
- Test python-scripts by running the follwing commands
python3 print_t1.py -t "Hello World"
python3 print_t2.py -p "Bolognese" -m "666g"
append this to your configuration.yaml
shell_command:
# Print labels on Brother QL810W
print_t1: 'python print_t1.py -t "{{ states("input_text.label_text") }}"'
print_t2: 'python print_t2.py -p "{{ states("input_text.label_produkt") }}" -m "{{ states("input_text.label_menge") }}"'
I have containers and covers in different colors and in squared and rectangular shapes.
I store Container- and Cover-Color as well as geometry to be able to find a desired container easier in the froster.
To meet this requirements, we need the following helpers, you may change them to meet your needs.
Helper/Add Helper/Text
- "name": "Text"
- "min": 0,
- "max": 100,
- Edit Helper and set ID to
input_text.label_text
Helper/Add Helper/Text
- "name": "Produkt"
- "min": 1,
- "max": 100,
- Edit Helper and set ID to
input_text.label_produkt
Helper/Add Helper/Text
- "name": "Menge"
- "min": 0,
- "max": 10,
- Edit Helper and set ID to
input_text.label_menge
Helper/Add Helper/Dropdown
- "name": "Dose"
- "icon": "mdi:cog-box"
- "options": "transparent", "rot", "grün", "gelb", "blau"
- Edit Helper and set ID to
input_select.dosenfarbe
Helper/Add Helper/Dropdown
- "name": "Deckel"
- "icon": "mdi:checkbox-blank-circle-outline"
- "options": "grün", "gelb", "blau"
- Edit Helper and set ID to
input_select.deckelfarbe
Helper/Add Helper/Dropdown
- "name": "Form"
- "icon": "mdi:rectangle-outline"
- "options": "Originalverpackung", "qwuadratisch", "rechteckig"
- Edit Helper and set ID to
input_select.dosenform
You'll find the yaml-code of the scripts in the /scripts
-directory.
Add the Froster Manager Script:
Settings/Automations & Scenes/Scripts/New ScriptCreate/New Script
- Name: Froster Manager
- Entity-ID: script.froster_manager
- Switch to YAML Mode and paste:
Frostermanager.yaml
,
Add the Print Test Label Script:
Settings/Automations & Scenes/Scripts/New ScriptCreate/New Script
- Name: Print Text Label
- Entity-ID: script.print_text_label
- Switch to YAML Mode and paste:
PrintTextLabel.yaml
,
You'll find the yaml-code of the cards in the /lovelance
-directory.
goto a dashboard of your coice
edit
add card
and choose any- activate
yaml
-mode - paste code from
/lovelance
-directory
Have fun.