Port of Keg Cop to Home Assistant
Here are the steps that I took to build this port of kegcop to home assistant.
You should have some knowledge of home assistant before starting this project. it is not that hard but it does take some time to learn each step used in this setup.
The first step should be to add the following from the addon store:
- ESPHome
- Mariadb
- Studio code server
- phpmyadmin (not required but need for testing your sql in mariadb)
Next you should set up mariadb and you config.yaml file.
You will need to get some frontend cards from HACS to for the dashboard:
- bar-card
- horizontal-stack
- mini-graph-card
- vertical-stack
- gauge
Check the dashboard YAML for all of the cards that are used.
Install the flowmeter code into the esp32
This is the code that works for me, you will need to test to make sure it works for you type of flow meter:
- platform: pulse_counter
state_class: measurement
name: "count_1"
id: count_1
pin:
number: GPIO4
inverted: true
mode:
input: true
pullup: true
update_interval: 30s
internal_filter: 13us
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
unit_of_measurement: "pulses"
accuracy_decimals: 2
filters:
- debounce: 0.1s
- lambda: return (x / 1);
Next you will need to create a date field and a number field within the device and services helpers tab.
I created one each for each keg, here is a date example:
Here is a number example:
OPERATION:
The tool is managed in the screen below. There are only three functions that need to be managed.
- New Keg Date: enter in the date that the keg is tapped. The tool will add up the pulses based on the start date. Change date when the keg is empty and replaced with a new keg.
- Keg Size: The keg volume will be based off of the amount selected in the slider.
- Pulse per Oz calibration: Pour a measured amount and then change this number to get the correct calculation per pour. For example, pour 8 oz of liquid and check the control panel results for that pour. You can hard code your pulse per oz results in the input_numbers.yaml in the initial field. If your home assistant instance restarts it will reset this number back to the initial value.
box1: name: Keg 1 PPO calibration initial: 27 min: -20 max: 135 step: 1 mode: box